Module Expr Str ImportFrom alias alias alias alias Import alias Import alias Import alias Assign NameStore Call AttributeLoad NameLoad attr Str ClassDef bases NameLoad body Expr Str Pass decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore Call NameLoad Call NameLoad AttributeLoad NameLoad attr orelse Assign NameStore ListLoad For NameStore NameLoad body TryExcept body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad handlers ExceptHandler type NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Str If CompareGt Call NameLoad NameLoad Num body Assign NameStore Call AttributeLoad Str attr SubscriptLoad NameLoad Slice Num Num Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Num Expr Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad orelse Expr Call AttributeLoad NameLoad attr NameLoad Return Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore ListLoad For TupleStore NameStore NameStore Call NameLoad NameLoad body TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad If CompareGt NameLoad Num body Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr keyword AttributeLoad NameLoad attr keyword NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr Call AttributeLoad Str attr ListComp Call NameLoad NameLoad comprehension NameStore NameLoad handlers ExceptHandler type NameLoad body Pass Return Call AttributeLoad Str attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str TryExcept body If NameLoad body Assign NameStore AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad attr orelse Assign NameStore AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad attr handlers ExceptHandler type TupleLoad NameLoad NameLoad body Assign NameStore Call AttributeLoad Str attr AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Raise Call NameLoad NameLoad If UnaryOpNot NameLoad body Assign NameStore AttributeLoad NameLoad attr orelse Assign NameStore ListLoad For NameStore NameLoad body TryExcept body Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad If Call NameLoad NameLoad AttributeLoad AttributeLoad NameLoad attr attr body Expr Call AttributeLoad NameLoad attr NameLoad orelse Expr Call AttributeLoad NameLoad attr NameLoad handlers ExceptHandler type NameLoad name NameStore body Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr keyword AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad Return NameLoad decorator_list decorator_list FunctionDef arguments args NameParam defaults body Expr Str For TupleStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr body If BoolOpAnd CompareGt NameLoad Num UnaryOpNot AttributeLoad NameLoad attr body Expr Call NameLoad TryExcept body Assign NameStore Call NameLoad NameLoad Expr Call NameLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword Str handlers ExceptHandler type NameLoad name NameStore body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults NameLoad body Expr Str Assign NameStore Call AttributeLoad NameLoad attr keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str keyword Str keyword Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad TryExcept body Expr Call NameLoad NameLoad handlers ExceptHandler type NameLoad name NameStore body Pass decorator_list
N/A N/A 
``fitsheader`` is a command line script based on pyfits for printing the
header(s) of one or more FITS file(s) to the standard output in a human-
readable format.

Example uses of fitsheader:

1. Print the header of all the HDUs of a .fits file::

    $ fitsheader filename.fits

2. Print the header of the third and fifth HDU extension::

    $ fitsheader --extension 3 --extension 5 filename.fits

3. Print the header of a named extension, e.g. select the HDU containing
   keywords EXTNAME='SCI' and EXTVER='2'::

    $ fitsheader --extension "SCI,2" filename.fits

4. Print only specific keywords::

    $ fitsheader --keyword BITPIX --keyword NAXIS filename.fits

5. Print keywords NAXIS, NAXIS1, NAXIS2, etc using a wildcard::

    $ fitsheader --keyword NAXIS* filename.fits

Note that compressed images (HDUs of type
:class:`~pyfits.CompImageHDU`) really have two headers: a real
BINTABLE header to describe the compressed data, and a fake IMAGE header
representing the image that was compressed. PyFITS returns the latter by
default. You must supply the ``--compressed`` option if you require the real
header that describes the compression.

With PyFITS installed, please run ``fitsheader --help`` to see the full usage
documentation.
 __future__ absolute_import division print_function unicode_literals N/A optparse N/A logging N/A pyfits N/A log N/A N/A logging getLogger fitscheck ExtensionNotFoundException N/A Exception N/A N/A Raised if an HDU extension requested by the user does not exist. N/A N/A HeaderFormatter N/A object N/A N/A Class to format the header(s) of a FITS file for display by the
    `fitsheader` tool; essentially a wrapper around a `HDUList` object.

    Example usage:
    fmt = HeaderFormatter('/path/to/file.fits')
    print(fmt.parse(extensions=[0, 3], keywords=['NAXIS', 'BITPIX']))

    Parameters
    ----------
    filename : str
        Path to a single FITS file.

    Raises
    ------
    IOError
        If `filename` does not exist or cannot be read.
     __init__ N/A N/A self filename N/A N/A N/A N/A self filename filename N/A N/A self _hdulist N/A N/A pyfits open filename N/A parse N/A N/A self extensions keywords compressed N/A None None False N/A N/A Returns the FITS file header(s) in a readable format.

        Parameters
        ----------
        extensions : list of int or str, optional
            Format only specific HDU(s), identified by number or name.
            The name can be composed of the "EXTNAME" or "EXTNAME,EXTVER"
            keywords.

        keywords : list of str, optional
            Keywords for which the value(s) should be returned.
            If not specified, then the entire header is returned.

        compressed : boolean, optional
            If True, shows the header describing the compression, rather than
            the header obtained after decompression. (Affects FITS files
            containing `CompImageHDU` extensions only.)

        Returns
        -------
        formatted_header : str or astropy.table.Table
            Traditional 80-char wide format in the case of `HeaderFormatter`;
            an Astropy Table object in the case of `TableHeaderFormatter`.
         N/A N/A extensions None N/A N/A hdukeys N/A range N/A len N/A self _hdulist N/A N/A hdukeys N/A N/A ext extensions N/A N/A N/A N/A N/A N/A hdukeys append N/A int ext N/A N/A N/A ValueError N/A N/A parts N/A N/A ext split , N/A N/A N/A len parts 1 N/A N/A extname N/A N/A , join N/A parts N/A 0 -1 N/A extver N/A int N/A parts N/A -1 N/A N/A N/A hdukeys append N/A extname extver N/A N/A N/A N/A hdukeys append ext N/A N/A N/A self _parse_internal hdukeys keywords compressed N/A _parse_internal N/A N/A self hdukeys keywords compressed N/A N/A N/A The meat of the formatting; in a separate method to allow overriding.
         N/A result N/A N/A N/A idx hdu N/A enumerate hdukeys N/A N/A N/A N/A cards N/A N/A self _get_cards hdu keywords compressed N/A N/A idx 0 N/A N/A N/A N/A result append N/A N/A N/A result append N/A N/A # HDU {hdu} in {filename}:
 format filename N/A self filename hdu hdu N/A N/A N/A result append N/A N/A {0}
 format N/A N/A join N/A N/A str c N/A c cards N/A N/A N/A ExtensionNotFoundException N/A N/A N/A N/A N/A join result N/A _get_cards N/A N/A self hdukey keywords compressed N/A N/A N/A Returns a list of `pyfits.card.Card` objects.

        This function will return the desired header cards, taking into
        account the user's preference to see the compressed or uncompressed
        version.

        Parameters
        ----------
        hdukey : int or str
            Key of a single HDU in the HDUList.

        keywords : list of str, optional
            Keywords for which the cards should be returned.

        compressed : boolean, optional
            If True, shows the header describing the compression.

        Raises
        ------
        ExtensionNotFoundException
            If the hdukey does not correspond to an extension.
         N/A N/A N/A compressed N/A N/A header N/A N/A N/A self _hdulist N/A hdukey _header N/A N/A header N/A N/A N/A self _hdulist N/A hdukey header N/A N/A N/A N/A IndexError KeyError N/A N/A message N/A N/A {0}: Extension {1} not found. format N/A self filename hdukey N/A N/A N/A log warning message N/A N/A ExtensionNotFoundException message N/A N/A keywords N/A N/A cards N/A header cards N/A N/A cards N/A N/A kw keywords N/A N/A N/A N/A crd N/A N/A header cards N/A kw N/A N/A isinstance crd N/A N/A pyfits card Card N/A N/A N/A N/A cards append crd N/A N/A N/A N/A cards extend crd N/A N/A N/A KeyError N/A e N/A N/A N/A N/A log warning N/A N/A {filename} (HDU {hdukey}): Keyword {kw} not found. format filename N/A self filename hdukey hdukey kw kw N/A cards N/A N/A print_headers_traditional N/A N/A args N/A N/A N/A Prints FITS header(s) using the traditional 80-char format.

    Parameters
    ----------
    args : argparse.Namespace
        Arguments passed from the command-line as defined below.
     N/A N/A idx filename N/A enumerate N/A args filename N/A N/A N/A N/A idx 0 N/A N/A args keywords N/A N/A N/A print N/A N/A N/A formatter N/A HeaderFormatter filename N/A N/A print N/A N/A formatter parse N/A args extensions N/A args keywords N/A args compressed end N/A N/A N/A IOError N/A e N/A N/A N/A N/A log error N/A str e N/A main N/A N/A args N/A None N/A N/A This is the main function called by the `fitsheader` script. N/A parser N/A N/A argparse OptionParser description Print the header(s) of a FITS file. Optional arguments allow the desired extension(s), keyword(s), and output format to be specified. Note that in the case of a compressed image, the decompressed header is shown by default. N/A N/A N/A parser add_option -e --ext metavar HDU action append dest extensions help specify the extension by name or number; this argument can be repeated to select multiple extensions N/A N/A N/A parser add_option -k --keyword metavar KEYWORD action append dest keywords help specify a keyword; this argument can be repeated to select multiple keywords; also supports wildcards N/A N/A N/A parser add_option -c --compressed action store_true help for compressed image data, show the true header which describes the compression rather than the data N/A N/A N/A parser add_option filename nargs + help path to one or more files; wildcards are supported N/A args N/A N/A parser parse_args args N/A N/A N/A N/A print_headers_traditional args N/A N/A N/A IOError N/A e N/A N/A N/A