SSN/20 describes a system incorporated into the NDF library routines which enables applications written to read or write NDFs to handle any arbitrary ‘foreign’ format for which a conversion utility can be defined. The system operates via environment variables which define the set of permitted conversions and the commands required to do them.
CONVERT startup will define defaults for the NDF-conversion environment variables which permit automatic conversion of files in the formats handled by CONVERT (except for AST, IRCAM, PGM. SPECX and FITS tapes). It also allows data compression.
The list of format names and associated filename extensions defined by CONVERT is set out in Table 1—the filename extensions tell the system which format the file is in. For the unformatted and ASCII conversions the format names and extensions are somewhat arbitrary. This list will nullify any existing list so private conversions must be added after CONVERT startup.
For the unformatted and ASCII conversions the format names and extensions are somewhat arbitrary. The FITS and STREAM formats have synonym file extensions for the conversion to NDF. The standard file extension is required for the conversion to the foreign format.
.fits .fts .FITS .FIT .lilo .lihi .silo .sihi .mxlo .mxhi .rilo .rihi .vdlo .vdhi
|Figaro (Version 2) DST|
|Unformatted direct-access or stream|
|Unformatted with FITS header|
|Unformatted without FITS header|
|ASCII with FITS header|
|ASCII without FITS header|
|Graphics Interchange Format|
|Tag Image File Format|
|gzip compressed NDF|
Table 2 lists the utilities used to perform the conversions. In general the default parameter values are used—non-default parameters (other than the input and output filenames) are listed in the table.
Table 2 also contains a column headed ‘Variable’. Most of the command lines issued to do the automatic conversion will include the translation of an environment variable named NDF_FROM_fmt_PARS or NDF_TO_fmt_PARS as appropriate (where fmt is the format name). This may be used to give additional parameters to the command if you do not want to define a completely new command for yourself.
Where the ‘Variable’ column contains a tick, the variable must be used to supply the SHAPE parameter; where it contains a cross, additional parameters cannot be specified.
For example, suppose application
rdndf uses the NDF library to read one NDF (named by the
first parameter) and write another (named by the second parameter). This application
could be made to read a TEXT file (
data.txt) containing the required values for a 50
array, and write its results as a FITS file (
output.fit) as follows:
The order of the formats in the tables also defines a search path. If you omit the file extension, the
system will search for an NDF of that name. If that is absent, it will try a
.fit FITS file. If neither are
present it tries an IRAF file, and so on. The recognised formats and their order is defined through the
environment variable NDF_FORMATS_IN. The shell
convert startup defines NDF_FORMATS_IN as
but from ICL the
CONVERT command does not define the synonyms due to a limitation of ICL. Thus
NDF_FORMATS_IN is defined to be the following.
When creating an output file, there is a similar list of recognised formats. The CONVERT startup procedures define NDF_FORMATS_OUT as follows.
The leading dot indicates that if you omit the file extension, the output file will be an NDF.
There are some examples of the automatic system in action and use of NDF_FORMATS_IN and NDF_FORMATS_OUT in SUN/95, Section 15.1.