[AstroPy] Re: functional interface for PyFITS?
Joe Harrington
jh at oobleck.astro.cornell.edu
Tue Mar 22 09:30:42 EST 2005
In IDL, it is very common to inline a FITS keyword read into a math
expression:
x = 7 * sxpar(file, keyword) + sqrt(grandmothersage)
So, I strongly agree that having the python equivalent return a
properly-typed value is important. There might also be an option to
return the naked string.
> img=getdata('foo.fits[2]') for the 2nd extension, as a valid alternative to
Be careful here. How do you distinguish that from a file whose name
is literally foo.fits[2]? And if you do 'foo.fits'[2], how do you
distinguish that from the second element of a string array (bar, in
this case): getdata(bar[2])? The first is contrived but possible in
the grand universe of file-naming schemes. The second I use *all the
time* to address a list of filenames in sequence. Stick with
getdata('foo.fits', ext=2). It's just a few extra characters longer
than the shorthand, and is much clearer.
--jh--
More information about the AstroPy
mailing list