bundles / astropy 7.0.1 / astropy / io / fits / convenience / getdata
function
astropy.io.fits.convenience:getdata
source: /astropy/io/fits/convenience.py :131
Signature
def getdata ( filename , * args , header = None , lower = None , upper = None , view = None , ** kwargs ) Summary
Get the data from an HDU of a FITS file (and optionally the header).
Parameters
filename: path-like or file-likeFile to get data from. If opened, mode must be one of the following rb, rb+, or ab+.
extThe rest of the arguments are for HDU specification. They are flexible and are best illustrated by examples.
No extra arguments implies the primary HDU
getdata('in.fits')By HDU number
getdata('in.fits', 0) # the primary HDU getdata('in.fits', 2) # the second extension HDU getdata('in.fits', ext=2) # the second extension HDU
By name, i.e.,
EXTNAMEvalue (if unique)getdata('in.fits', 'sci') getdata('in.fits', extname='sci') # equivalent
Note
EXTNAMEvalues are not case sensitiveBy combination of
EXTNAMEand EXTVER`` as separate arguments or as a tuplegetdata('in.fits', 'sci', 2) # EXTNAME='SCI' & EXTVER=2 getdata('in.fits', extname='sci', extver=2) # equivalent getdata('in.fits', ('sci', 2)) # equivalent
Ambiguous or conflicting specifications will raise an exception
getdata('in.fits', ext=('sci',1), extname='err', extver=2)header: bool, optionalIf
True, return the data and the header of the specified HDU as a tuple.lower, upper: bool, optionalIf
lowerorupperareTrue, the field names in the returned data object will be converted to lower or upper case, respectively.view: ndarray, optionalWhen given, the data will be returned wrapped in the given ndarray subclass by calling
data.view(view)**kwargsAny additional keyword arguments to be passed to astropy.io.fits.open.
Returns
array: ndarray or `~numpy.recarray` or `~astropy.io.fits.Group`Type depends on the type of the extension being referenced.
If the optional keyword
headeris set toTrue, this function will return a (data,header) tuple.
Raises
: IndexErrorIf no data is found in searched HDUs.
Aliases
-
astropy.io.fits.getdata