astropy 5.0

ParametersRaisesReturnsBackRef
getdata(filename, *args, header=None, lower=None, upper=None, view=None, **kwargs)

Parameters

filename : path-like or file-like

File to get data from. If opened, mode must be one of the following rb, rb+, or ab+.

ext :

The rest of the arguments are for extension specification. They are flexible and are best illustrated by examples.

No extra arguments implies the primary header:

getdata('in.fits')
note

Exclusive to getdata : if extension is not specified and primary header contains no data, getdata attempts to retrieve data from first extension.

By extension number:

getdata('in.fits', 0)      # the primary header
getdata('in.fits', 2)      # the second extension
getdata('in.fits', ext=2)  # the second extension

By name, i.e., EXTNAME value (if unique):

getdata('in.fits', 'sci')
getdata('in.fits', extname='sci')  # equivalent

Note EXTNAME values are not case sensitive

By combination of EXTNAME and EXTVER`` as separate arguments or as a tuple:

getdata('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, optional

If :None:None:`True`, return the data and the header of the specified HDU as a tuple.

lower, upper : bool, optional

If lower or upper are :None:None:`True`, the field names in the returned data object will be converted to lower or upper case, respectively.

view : ndarray, optional

When given, the data will be returned wrapped in the given ndarray subclass by calling:

data.view(view)
kwargs :

Any additional keyword arguments to be passed to astropy.io.fits.open .

Raises

IndexError

If no data is found in searched extensions.

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 header is set to :None:None:`True`, this function will return a ( data , header ) tuple.

Get the data from an extension of a FITS file (and optionally the header).

Examples

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

astropy.io.fits.convenience.delval astropy.io.fits.convenience.getheader astropy.io.fits.convenience.setval astropy.io.fits.convenience.getval astropy.io.fits.convenience

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /astropy/io/fits/convenience.py#119
type: <class 'function'>
Commit: