I recently came across a nice simple way to access FITS header keywords at the command line via the “Stand-alone FITS tools” provided by ESO. The combination of dfits
and fitsort
work like the IRAF hselect
routine, but they are run at the command line and therefore have access to all of the shell tools like grep
.
To install:
cd /tmp/ ### or anywhere else mkdir ESOFITS cd ESOFITS wget http://archive.eso.org/saft/dfits/dfits.c wget http://archive.eso.org/saft/fitsort/fitsort.c gcc -o dfits dfits.c gcc -o fitsort fitsort.c sudo cp dfits fitsort /usr/local/bin ### or somewhere else in your $PATH
Now you can run it with, e.g.,
dfits f140w.fits | fitsort NAXIS1 NAXIS2 EXPTIME FILE NAXIS1 NAXIS2 EXPTIME f140w.fits 7017 8361 4.058728020E+03
Note that dfits
also works with wildcards, e.g. dfits ib*flt.fits | fitsort FILTER
.
wcstool’s gethead does all this in one command with lots of useful formatting options.
http://tdc-www.harvard.edu/wcstools/
http://tdc-www.harvard.edu/software/wcstools/gethead.ex.html
Yes, gethead also seems to do a good job at this. One benefit of the ESO tools is that they recognize the ESO “HIERARCH” keywords:
dfits HAWKI_IMG_OBS_AutoJitter291_0001.fits |fitsort DET.DIT
FILE DET.DIT
RAW/JITTER/HAWKI_IMG_OBS_AutoJitter291_0001.fits 300.0000000
vs.
gethead HAWKI_IMG_OBS_AutoJitter291_0001.fits DET.DIT
[nothing found]