next up previous
Next: How do I create an NDF file from an ASCII file?
Up: Writing csh scripts
Previous: How do I use scientific notation in bc?


My file has been converted to NDF. How do I access FITS header keywords?

You may need to access information that was contained in the FITS header to carry out your data analysis, having converted your data to NDF format to make use of the Starlink software the FITS header keywords are still accessible as part of an NDF extension. KAPPA has a number of tools specifically written to handle FITS keywords.

The recommended way to find the value of a FITS header keyword is by using the fitsval application. For instance, you could obtain the value of the FITS keyword CRVAL3 as follows.

   % fitsval ifu_file CRVAL3
   7302.2918645
   %

This could be used in a script to take appropriate action along with other KAPPA FITS manipulation tools.

   # Get the input file name.
   echo -n "NDF input file: "
   set infile = $<

   # Check to see if the CTYPE3 keyword exists.
   set status = `fitsexist ${infile} CTYPE3`

   # If the keyword exists...
   if ( ${status} == "TRUE" ) then

      # get the value of CTYPE3.
      set ctype3 = `fitsval ${infile} CTYPE3`

      # Warn the user if its value is not LAMBDA.
      if ( ${ctype3} != "LAMBDA" ) then
         echo "Warning: Axis 3 not type LAMBDA"
      endif

   # The keyword does not exist.
   else

      # Warn the user that the keyword is missing.
      echo "Warning: Axis 3 type keyword missing"

   endif

Here we use KAPPA fitsexist comtmnd to check that the the keyword we are interested in exists, then the fitsval command to query its value and act on the information.


next up previous
Next: How do I create an NDF file from an ASCII file?
Up: Writing csh scripts
Previous: How do I use scientific notation in bc?

The IFU Data-Product Cookbook
Starlink Cookbook 16
A. Allan & Malcolm J. Currie
2008 July 4
E-mail:starlink@jiscmail.ac.uk

Copyright © 2014 Science and Technology Facilities Council