next up previous 393
Next: Using the IDL Astronomy Users' Library
Up: Other Methods
Previous: A simple route (but rather slow)

A faster route (but a little more complicated)

However, the NDF2ASCII routine is not fast and makes this route awkward if time is important. Consequently, you may want to use NDF2UNF to create an F77 unformatted sequential file thus:

% ndf2unf in=imagein out=fileout noperec=339
Where the noperec number should be the size of the first axis of the image.

You can then read the created file using an IDL batch file similar to:

; Supply the name of the image and its dimensions.
FNAME='fileout'
SD1=339
SD2=244
  
; Set up the main array and temporary array
; use NOZERO option to avoid initialisation 
IMAGE=INTARR(SD1,SD2,/NOZERO)
TEMP= INTARR(SD1,    /NOZERO)
 
; Display what is going on.
PRINT, "Converting file: ", FNAME
 
; Open the file generated by NDF2UNF for read access only.
OPENR, UNIT, fname, /GET_LUN, /F77_UNFORMATTED
 
; Read the image one record at a time.
FOR I=0,SD2-1  DO BEGIN  READU, UNIT, TEMP & $
  ; Transfer each line into the main image array.
  FOR J=0,SD1-1 DO BEGIN IMAGE(J,I)=TEMP(J) & $ 
ENDFOR & ENDFOR 
 
; Close the opened file unit.
CLOSE, 1
 
; Scale the image for display.
IMAGE=CONGRID(IMAGE,SD1,SD2,/INTERP)
WINDOW, 0,XSIZE=SD1,YSIZE=SD2
 
; Display the image.
TVSCL, IMAGE

The image is then contained in the integer array IMAGE and may be manipulated by IDL. This would allow such operations as storing it as a UNIX unformatted file where the image might subsequently be read in from disc in one go.

It should be remembered that the data type of the F77 unformatted file created by NDF2UNF may differ depending on the type of data stored in the original NDF. If this is the case you might need to change the type definition of the arrays image and temp to reflect this. The data type used within each component of an NDF may be determined using NDFTRACE.



next up previous 393
Next: Using the IDL Astronomy Users' Library
Up: Other Methods
Previous: A simple route (but rather slow)

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