[AstroPy] Re: functional interface for PyFITS?

Peter Erwin erwin at iac.es
Tue Mar 22 14:18:13 EST 2005


At 5:57 PM -0500 3/21/05, Victoria G. Laidler wrote:

[snip]

>>  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?
>
>Can I suggest dropping "getdataheader" and replacing it with a 
>keyword argument to getdata?
>img=getdata('foo.fits')
>img,h=getdata('foo.fits',hdr=True)

This seems reasonable, though I would like the option of a separate "getheader"
function which just retrieves the header.


>I like Peter's suggested addition too, with a couple of comments:
>
>>>>>/  getheadervalue(filename, keyword, ...)  # returns header 
>>>>>value as a string/
>>
>How about pyfits.getval(filename,keyword, ...) for its name?
>
>And please, how about returning the keyword value in a properly 
>typed variable? The data type is encoded in the FITS header after 
>all! Might as well make use of it,instead of making the user float 
>it, int it, or whathaveyou.

Oops.  I've been spending too much time trying to parse string output from
IRAF commands, that's why I assumed string output.  Yes, given that 
the data type
*is* in the FITS header, properly typed output makes sense.

(And "getval" would work as a function name, as long as no one is planning on
implementing a function to directly retrieve, say, *pixel* values from the data
itself...)

    -- Peter
-- 
=============================================================
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 mailing list