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
:
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
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:
Print the header of all the HDUs of a .fits file:
$ fitsheader filename.fits
Print the header of the third and fifth HDU extension:
$ fitsheader --extension 3 --extension 5 filename.fits
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
Print only specific keywords:
$ fitsheader --keyword BITPIX --keyword NAXIS filename.fits
Print keywords NAXIS, NAXIS1, NAXIS2, etc using a wildcard:
$ fitsheader --keyword NAXIS* filename.fits
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
Specify hierarchical keywords with the dotted or spaced notation:
$ fitsheader --keyword ESO.INS.ID filename.fits $ fitsheader --keyword "ESO INS ID" filename.fits
Compare the headers of different fits files, following ESO’s
fitsort
format:$ fitsheader --fitsort --extension 0 --keyword ESO.INS.ID *.fits
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
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:
Add checksums:
$ fitscheck --write *.fits
Write new checksums, even if existing checksums are bad or missing:
$ fitscheck --write --force *.fits
Verify standard checksums and FITS compliance without changing the files:
$ fitscheck --compliance *.fits
Only check and fix compliance problems, ignoring checksums:
$ fitscheck --checksum none --compliance --write *.fits
Verify standard interoperable checksums:
$ fitscheck *.fits
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.