next up previous 393
Next: A faster route (but a little more complicated)
Up: Other Methods
Previous: Other Methods

A simple route (but rather slow)

The simplest route to use when generating data for IDL from NDFs is to create an ASCII copy of the NDF you are interested in using the CONVERT package application NDF2ASCII and then read the resulting file with IDL. The steps taken might be something like:

% ndf2ascii in=imagein out=fileout  
This will create a file, fileout, containing the DATA component of the NDF called imagein. If you want to store the VARIANCE or QUALITY components you would use comp=v or comp=q respectively as additional parameters.

You can then employ a simple IDL batch file such as:

; Create IMAGE an 339x244 single precision floating point array.
IMAGE=FLTARR(339,244)

; Open the existing NDF2ASCII file "fileout" for read only access. 
OPENR, UNIT, 'fileout', /GET_LUN
  
; Read formatted input from the specified file unit and 
; place in the variable "IMAGE".
READF, UNIT, IMAGE
 
; Closes the file unit used.
CLOSE, UNIT

; Display the image after suitable scaling. 
TVSCL, IMAGE
The above example assumes image dimensions of 339$\times$244 pixels. If you are in any doubt as to the dimensions of your image you can determine them using the KAPPA application NDFTRACE.

One advantage of this route is that the ASCII data can instead be read directly into byte, integer or double-precision arrays/structures by simply substituting INTARR, DBLARR or BYTARR for FLTARR. Clearly, it should be remembered that attempting to represent floating-point values within a byte array will not work properly, whereas a double-precision array will accommodate double-precision, floating-point, integer or byte values (though somewhat inefficiently in terms of memory consumption).



next up previous 393
Next: A faster route (but a little more complicated)
Up: Other Methods
Previous: Other Methods

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