[AstroPy] functional interface for PyFITS?
erwin at iac.es
Mon Mar 21 15:23:32 CST 2005
>Vicki Laidler has persuaded me that PyFITS should have a more
>functional interface as well as it's more object-oriented current
>interface. The gist of the argument is that many astronomers would
>like a simple call to get data or a header and not mess with
>opening, then digging down in the object structure to get at the
>data. I find that hard to argue with. Here are some proposed
>getdata(filename, [ext, extname, extver, etc])
>getheader(filename, [ext, extname, extver, etc])
>getdataheader( [ext, extname, extver, etc]) # returns the data and
>header as a tuple
> # i.e., im, hdr = pyfits.getdataheader('mydata.fits')
> # Shorter name better? getdatahdr? getdh?
I think this is an excellent idea!
As for "getdataheader":
I'd avoid making the name *too* short and cryptic ("getdh" is too short); one
of the nice things about Python is that if you want to avoid typing too much,
you can define your own shorthand names, e.g.:
>>> gdh = pyfits.getdataheader
>>> im, hdr = gdh('mydata.fits')
(Stick it in your PYTHONSTARTUP file if you think you'll be using it a lot.)
>Comments? Any missing functions?
It might be nice to have direct functional access to header values; something
along the lines of
>>> getheadervalue(filename, keyword, ...) # returns header value as a string
(There are often times when that's all I want out of a FITS file.)
Peter Erwin Instituto de Astrofisica de Canarias
erwin at iac.es C/ Via Lactea s/n
tel. +34 922 605 238 38200 La Laguna, Tenerife, Spain
fax +34 922 605 210 http://www.iac.es/galeria/erwin
More information about the AstroPy