IDL function READ_NDF is available to convert a component of an NDF to an IDL array, and IDL procedure WRITE_NDF will create an NDF component from an IDL array. So, for example:
IDL> tv,read_ndf('comwest')
will display the data array of the NDF, comwest.sdf, using the IDL
command, TV, and:
will create an NDF, stars.sdf, of a suitable type and size, and write the IDL array, field, to its DATA_ARRAY component.IDL> write_ndf,field,'stars'
will write the IDL array, q, to the QUALITY component of an existing NDF, stars.sdf.IDL> write_ndf,q,'stars','QUALITY'
Both READ_NDF and WRITE_NDF can take special action on bad values. For a full description of their arguments see Specifications of CONVERT IDL Procedure.
Complete structures can be handled by function HDS2IDL and procedure IDL2HDS. So, for example:
IDL> comwest=hds2idl('comwest')
% Loaded DLM: HDS2IDL.
IDL> help,comwest,/str
** Structure <40071208>, 5 tags, length=262184, refs=1:
HDSSTRUCTYPE STRING 'IMAGE'
TITLE STRING 'Comet West, low resolution'
DATA_ARRAY FLOAT Array[256, 256]
DATA_MIN FLOAT 3.89062
DATA_MAX FLOAT 245.937
IDL>tv,comwest.data_array
will display the same image as the READ_NDF example above, but the other
components of the NDF are also available in the IDL structure,
comwest, so that:
will create a duplicate of comwest.sdf in newcomwest.sdf. Exact duplication of the type and structure is not always possible - see the routine descriptions for details.IDL> idl2hds,comwest,'newcomwest'
When CONVERT is installed, the converter procedures and routines are placed in $CONVERT_DIR so, to make them available to IDL, that directory must be added to the IDL search paths, IDL_PATH and IDL_DLM_PATH. This will be done if the environment variable IDL_PATH has been set (usually by `sourcing' the idl_setup script) when you start the CONVERT package by typing:
Note that convert must be run after sourcing the idl_setup script.% convert
Note also that having started CONVERT the NDF library, which is ultimately used by READ_NDF and WRITE_NDF, will allow them (but not HDS2IDL and IDL2HDS) to do on-the-fly conversion of any files given as parameters. This opens up the possibility of using almost any data format with IDL.
As an example:
IDL> tv,read_ndf('moon.imh')
will display the IRAF file, moon.imh.
CONVERT A Format-conversion Package