astropy:docs

Executable Scripts

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

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
    

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. Verify and update checksums, tolerating non-standard checksums, updating to standard checksum:

    $ fitscheck --checksum either --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. Verify original nonstandard checksums only:

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

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

    $ fitscheck *.fits
    
  7. Delete checksum keywords:

    $ fitscheck --checksum none --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 fitscheck --help to see the full program usage documentation.