What's what in .sdf headers

If you don't have a log file telling you what each image is meant to be, then you can construct one using a shell script and the starlink command hdstrace, which is a useful tool for accessing headers in .sdf files. These files are hierarchical structures, so some things are kept in progressively lower levels. Remember that filenames in starlink commands should normally be specified without the .sdf suffix.

The lower levels of a header in a file are accessed by adding a dot and then their name (e.g., more and fits) to the name of the file on the comand line (remember that there should not be .sdf after filenames). Also, nlines=all gives you all the entries in a level, and eachline causes them to be outputted one per line:

hdstrace 2004-03-19_04-03-22.more.fits nlines=all eachline

If you want to get (e.g.) the exposure time then pipe the output of this command through grep:

hdstrace 2004-03-19_04-03-22.more.fits nlines=all eachline | grep "EXPTIME"

To create a rough log file of the observations, you could use a script like this (but the patterns for the grep command, and the character counts for the cut command might need modifying):

#/bin/tcsh
starlink
if ( -e obslog.txt ) then
  echo '### File obslog.txt already exists. No action taken.'
else
  foreach file ($argv)
    set target  = `hdstrace $file:r".more.fits" nlines=all eachline | grep "TARG"     | cut -c 38-47`
    set mjdobs  = `hdstrace $file:r".more.fits" nlines=all eachline | grep "'MJD-OBS" | cut -c 22-35`
    set exptime = `hdstrace $file:r".more.fits" nlines=all eachline | grep "'EXPTIME" | cut -c 27-35`
    set ra      = `hdstrace $file:r".more.fits" nlines=all eachline | grep "'RA     " | cut -c 26-35`
    set dec     = `hdstrace $file:r".more.fits" nlines=all eachline | grep "'DEC    " | cut -c 26-35`
    set airmass = `hdstrace $file:r".more.fits" nlines=all eachline | grep "AIRM STA" | cut -c 44-48`
    echo $file:r $mjdobs $exptime $target $ra $dec $airmass >> obslog.txt
  end
endif
exit

fitskeys

The starlink package figaro command fitskeys outputs the fits headers of a .sdf file. As it is a starlink command, remember to remove the .sdf part of the filename when you type it on the command line.