wget http://fits.gsfc.nasa.gov/samples/IUElwp25637mxlo.fitsNow, you can launch your favorite python command line interface (IPython for instance). Inside, python type:
from fitsutils import *
d = mrdfits("IUElwp25637mxlo.fits")
print d.keys()
You should get something like this :
['DELTAW', 'QUALITY', 'FLUX', 'NPOINTS', 'BACKGROUND', 'APERTURE', 'WAVELENGTH', 'NET', 'SIGMA']This is the list of variables contained in the binary table. Each variable is a Numpy ndarray. So you can access your data as usual in Numpy:
# get the shape of the FLUX array: print d['FLUX'].shape # get the first 10 FLUX values: print d['FLUX'][:10] # etc ...
Note that dimension orders are different in IDL and Python. Indeed, IDL has column-major ordering (Fortran ordering) while Python has row-major ordering (C ordering) of dimensions.
For instance, writing a FITS in IDL and reading it in Python.
In IDL, type:
IDL> data={data:indgen(4,5)}
IDL> print, size(data.data, /dim)
; 4 5
IDL> print, data.data[3, 2]
;11
IDL> print, data.data[2, 3]
;14
IDL> print, data.data
; 0 1 2 3
; 4 5 6 7
; 8 9 10 11
; 12 13 14 15
; 16 17 18 19
IDL> mwrfits, data, 'stamp.fits'
Now, in Python:
In [1]: from fitsutils.fitstables import *
In [2]: data = mrdfits('stamp.fits')
In [3]: data
Out[3]:
{'DATA': array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11],
[12, 13, 14, 15],
[16, 17, 18, 19]], dtype=int16)}
In [4]: data['DATA'][2, 3]
Out[4]: 11
wget https://github.com/nbarbey/fitsutils/raw/master/fitsutils/fitstables.py chmod +x fitstables.py