astropy 5.0

To remove in the future –– astropy.io.fits.convenience

Convenience functions

The functions in this module provide shortcuts for some of the most basic operations on FITS files, such as reading and updating the header. They are included directly in the 'astropy.io.fits' namespace so that they can be used like:

astropy.io.fits.getheader(...)

These functions are primarily for convenience when working with FITS files in the command-line interpreter. If performing several operations on the same file, such as in a script, it is better to not use these functions, as each one must open and re-parse the file. In such cases it is better to use astropy.io.fits.open and work directly with the astropy.io.fits.HDUList object and underlying HDU objects.

Several of the convenience functions, such as getheader and getdata support special arguments for selecting which extension HDU to use when working with a multi-extension FITS file. There are a few supported argument formats for selecting the extension. See the documentation for getdata for an explanation of all the different formats.

warning

All arguments to convenience functions other than the filename that are not for selecting the extension HDU should be passed in as keyword arguments. This is to avoid ambiguity and conflicts with the extension arguments. For example, to set NAXIS=1 on the Primary HDU:

Wrong:

astropy.io.fits.setval('myimage.fits', 'NAXIS', 1)

The above example will try to set the NAXIS value on the first extension HDU to blank. That is, the argument '1' is assumed to specify an extension HDU.

Right:

astropy.io.fits.setval('myimage.fits', 'NAXIS', value=1)

This will set the NAXIS keyword to 1 on the primary HDU (the default). To specify the first extension HDU use:

astropy.io.fits.setval('myimage.fits', 'NAXIS', value=1, ext=1)

This complexity arises out of the attempt to simultaneously support multiple argument formats that were used in past versions of PyFITS. Unfortunately, it is not possible to support all formats without introducing some ambiguity. A future Astropy release may standardize around a single format and officially deprecate the other formats.

Examples

See :

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#0
type: <class 'module'>
Commit: