next up previous 393
Next: Other Methods
Up: Handling NDFs in IDL
Previous: Handling NDFs in IDL


The Easy Way

Note that this method cannot be used with the 64-bit Solaris version of IDL (use % idl -32).

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:
IDL> write_ndf,field,'stars'
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,q,'stars','QUALITY'
will write the IDL array, q, to the QUALITY component of an existing NDF, stars.sdf.

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:
IDL> idl2hds,comwest,'newcomwest'
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.

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:

% convert
Note that convert must be run after sourcing the idl_setup script.

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.

next up previous 393
Next: Other Methods
Up: Handling NDFs in IDL
Previous: Handling NDFs in IDL

CONVERT A Format-conversion Package
Starlink User Note 55
Malcolm J. Currie
G.J.Privett
A.J.Chipperfield
D.S.Berry
A.C.Davenhall
2008 May 19
E-mail:ussc@star.rl.ac.uk

Copyright © 2005 Council for the Central Laboratory of the Research Councils