Processing math: 100%

Appendix H
Convert Format from FITS to NDF

It is often useful to utilise data from other wavelengths or instruments (either for a comparison or for an external mask). In the following example, the FITS file called file.fits is converted to NDF format as file.sdf using the Starlink package Convert. Note that the .sdf file extension NDF may be omitted to save typing.

  % convert
  % fits2ndf file.fits file.sdf

FITS files from certain recognised sources have special rules applied when converting from FITS to NDF, as described in the documentation for fits2ndf. For FITS files from other sources, the primary array in the FITS file is stored as the main NDF in the output file. Any FITS extensions present in the FITS file will be placed into NDF extensions called FITS_EXT_<n>, where n counts from one for the first FITS extension. To see a list of the extension NDFs in fred.sdf, do:

  % ndfecho fred.more
  fred.MORE.FITS_EXT_1
  fred.MORE.FITS_EXT_2
  fred.MORE.FITS_EXT_3

When running a Kappa ot smurf command, you can refer to these extension just as they are listed above. So for instance:

  % ndftrace fred.MORE.FITS_EXT_1
  
     NDF structure /home/dsb/fred.MORE.FITS_EXT_1:
        Units:  COUNTS/S
  
     Shape:
        No. of dimensions:  2
        Dimension size(s):  270 x 263
        Pixel bounds     :  1:270, 1:263
        Total pixels     :  71010
  ...
  ...

Alternatively, you can copy the NDF into its own separate file:

  % ndfcopy in=fred.MORE.FITS_EXT_1 out=new_file

If one of the extensions contains a variance array that you would like to as the Variance component of the main NDF, a command like the following will do that:

  % setvar ndf=new_file from=fred.MORE.FITS_EXT_2

The fits2ndf command offers a way of mapping FITS extensions to familiar NDF array components DATA, VARIANCE, and QUALITY through the EXTABLE file, avoiding the ndfcopy and possible setvar steps.

You can convert an NDF to a FITS file using the command ndf2fits:

  % convert
  % ndf2fits file.sdf file.fits