Executable Scripts#

astropy installs a couple of useful utility programs on your system that are built with astropy.

fitsinfo#

fitsinfo is a command-line script based on astropy.io.fits for printing a summary of the HDUs in one or more FITS files(s) to the standard output.

Example usage of fitsinfo:

  1. Print a summary of the HDUs in a FITS file:

    $ fitsinfo filename.fits
    
    Filename: filename.fits
    No.    Name         Type      Cards   Dimensions   Format
    0    PRIMARY     PrimaryHDU     138   ()
    1    SCI         ImageHDU        61   (800, 800)   int16
    2    SCI         ImageHDU        61   (800, 800)   int16
    3    SCI         ImageHDU        61   (800, 800)   int16
    4    SCI         ImageHDU        61   (800, 800)   int16
    
  2. Print a summary of HDUs of all the FITS files in the current directory:

    $ fitsinfo *.fits
    

fitsheader#

fitsheader is a command line script based on astropy.io.fits 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
    
  6. Dump the header keywords of all the files in the current directory into a machine-readable csv file:

    $ fitsheader --table ascii.csv *.fits > keywords.csv
    
  7. Specify hierarchical keywords with the dotted or spaced notation:

    $ fitsheader --keyword ESO.INS.ID filename.fits
    $ fitsheader --keyword "ESO INS ID" filename.fits
    
  8. Compare the headers of different fits files, following ESO’s fitsort format:

    $ fitsheader --fitsort --extension 0 --keyword ESO.INS.ID *.fits
    
  9. Same as above, sorting the output along a specified keyword:

    $ fitsheader -f -s DATE-OBS -e 0 -k DATE-OBS -k ESO.INS.ID *.fits
    
  10. Sort first by OBJECT, then DATE-OBS:

    $ fitsheader -f -s OBJECT -s DATE-OBS *.fits
    

Note that compressed images (HDUs of type 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. Astropy returns the latter by default. You must supply the --compressed option if you require the real header that describes the compression.

With Astropy installed, please run fitsheader --help to see the full usage documentation.

fitscheck#

fitscheck is a command line script based on astropy.io.fits for verifying and updating the CHECKSUM and DATASUM keywords of .fits files. fitscheck can also detect and often fix other FITS standards violations. fitscheck facilitates re-writing the non-standard checksums originally generated by astropy.io.fits with standard checksums which will interoperate with CFITSIO.

fitscheck will refuse to write new checksums if the checksum keywords are missing or their values are bad. Use --force to write new checksums regardless of whether or not they currently exist or pass. Use --ignore-missing to tolerate missing checksum keywords without comment.

Example uses of fitscheck:

  1. Add checksums:

    $ fitscheck --write *.fits
    
  2. Write new checksums, even if existing checksums are bad or missing:

    $ fitscheck --write --force *.fits
    
  3. Verify standard checksums and FITS compliance without changing the files:

    $ fitscheck --compliance *.fits
    
  4. Only check and fix compliance problems, ignoring checksums:

    $ fitscheck --checksum none --compliance --write *.fits
    
  5. Verify standard interoperable checksums:

    $ fitscheck *.fits
    
  6. Delete checksum keywords:

    $ fitscheck --checksum remove --write *.fits
    

With astropy installed, please run fitscheck --help to see the full program usage documentation.

fitsdiff#

fitsdiff provides a thin command-line wrapper around the FITSDiff interface. It outputs the report from a FITSDiff of two FITS files, and like common diff-like commands returns a 0 status code if no differences were found, and 1 if differences were found:

With astropy installed, please run fitsdiff --help to see the full program usage documentation.