Skip to content

Instantly share code, notes, and snippets.

View astrofrog's full-sized avatar

Thomas Robitaille astrofrog

View GitHub Profile
@astrofrog
astrofrog / patch.diff
Created December 29, 2010 17:17
Patch to be able to compile HDF5 with NAG Fortran compiler. To apply, place in hdf5-1.8.5-patch1 and run "patch --dry-run -p1 < patch". When configuring, add FC="f95 -kind=byte" or FC="nagfor -kind=byte" to the configure command.
diff -rupN hdf5-1.8.5-patch1_original/fortran/test/tH5A_1_8.f90 hdf5-1.8.5-patch1/fortran/test/tH5A_1_8.f90
--- hdf5-1.8.5-patch1_original/fortran/test/tH5A_1_8.f90 2010-08-26 16:21:54.000000000 +0200
+++ hdf5-1.8.5-patch1/fortran/test/tH5A_1_8.f90 2010-12-29 18:09:41.000000000 +0100
@@ -158,13 +158,13 @@ SUBROUTINE attribute_test_1_8(cleanup, t
!!$ CALL test_attr_corder_transition(my_fcpl, my_fapl)
!!$ CALL test_attr_corder_delete(my_fcpl, my_fapl)
ret_total_error = 0
- CALL test_attr_info_by_idx(new_format, my_fcpl, my_fapl, ret_total_error)
+ CALL test_attr_info_by_idx(new_format(i), my_fcpl, my_fapl, ret_total_error)
CALL write_test_status(ret_total_error, &
@astrofrog
astrofrog / hselect.py
Created February 1, 2011 17:00
Create an ATpy table in IRAF hselect style
# Create an ATpy table in IRAF hselect style
# Example:
#
# >>> files = glob.glob(os.path.join('.', '*.fits'))
# >>> t = hselect(files)
import glob
import os
@astrofrog
astrofrog / irsa_cutout.py
Created February 12, 2011 17:44
Example of how to download cutouts from IRSA
import os
import urllib
import urllib2
from xml.etree.ElementTree import ElementTree
mission = 'GLIMPSE'
base_url = 'http://irsa.ipac.caltech.edu/cgi-bin/Cutouts/nph-cutouts'
options = {}
@astrofrog
astrofrog / test_oo.py
Created February 13, 2011 18:48
Diagnosing Memory Leaks in Matplotlib
# Object-oriented API
#
# Memory usage (iteration, object count, memory size)
# 100 5637 1562216
# 200 5529 1491528
# 300 5422 1426264
# 400 5758 1587376
# 500 5422 1426288
# 600 5416 1440456
# 700 5610 1515056
@astrofrog
astrofrog / ccfits_read_table.cxx
Created February 19, 2011 15:34
Read FITS table using CCFits
#include <CCfits>
int main()
{
CCfits::FITS::setVerboseMode(true);
try
{
@astrofrog
astrofrog / nan_convolve.py
Created February 21, 2011 15:31
NaN-friendly 2D convolution using Weave. Also very useful for convolving with big kernels, where scipy's convolve routines run out of RAM.
from scipy.weave import converters
import scipy.weave as weave
import numpy as np
def convolve(image, kernel):
image = image.astype(float)
kernel = kernel.astype(float)
@astrofrog
astrofrog / convert_2mass.py
Created February 22, 2011 22:24
Convert 2MASS ALTAS images into MJy/sr (and subtract background)
# Convert 2MASS ATLAS images into MJy/sr, and subtract background value
# estimated by 2MASS pipeline.
#
# Example:
#
# >>> atlas_to_MJysr('glimpse_k_test.fits', 'glimpse_k_cal.fits')
#
import pyfits
import pywcs
@astrofrog
astrofrog / hselect.py
Created February 23, 2011 20:55
Command-line hselect utility (rename to hselect and place in $PATH)
#!/usr/bin/env python
#
# Simple command-line IRAF-style hselect. To use:
#
# $ hselect CDELT1 *.fits
import sys
import pyfits
keyword = sys.argv[1]
@astrofrog
astrofrog / sampy_send.py
Created March 4, 2011 20:46
Broadcast a table from Python over SAMP
from sampy import *
import time
import urllib
myhub = SAMPHubProxy()
myhub.connect()
client = SAMPClient(myhub)
@astrofrog
astrofrog / sampy_receive.py
Created March 4, 2011 20:47
Receive table.load.votable SAMP command from Python
from sampy import *
import time
import urllib
myhub=SAMPHubProxy()
myhub.connect()
client=SAMPClient(myhub)