Accessing Non-Image Data Programmatically
There are a number of options available for reading non-image data into IDL. Depending upon the file type, consider using one of the following:
- Formatted data — use a data-type-specific routine (such as READ_ASCII or READ_BINARY). See Reading Binary Data in a Volume for more information.
- Unformatted data — use a general data access routines (such as OPEN or WRITE). For complete details about reading, writing and formatting unformatted data, see Files and Input/Output (Application Programming).
- SAVE file data — use the RESTORE procedure to access variable data in a SAVE file. See Reading Contour Data from a SAVE File for an example.
Note
These sections describe how to load data into a variable and includes examples of passing variable data to an iTool programmatically. See Importing Data from the IDL Session (iTool User's Guide) if you want information on how you can access variable data from the iTools Data Manager.
Reading Binary Data in a Volume
The following example uses READ_BINARY to access binary data (head.dat) consisting of a stack of 57 images slices of the human head. After reading the data, create a display using IVOLUME. Enter the following at the IDL command prompt:
file = FILEPATH('head.dat', $
SUBDIRECTORY = ['examples', 'data'])
dataSize = [80,100,57]
volume= READ_BINARY(file, DATA_DIMS = dataSize)
iVolume, volume, /AUTO_RENDER
Note
You can also create a template for binary file access. See Reading Binary Data for options.
Reading Contour Data from a SAVE File
You can also access information from a SAVE file. This example restores a SAVE file containing variable data (marbells.dat), configures the data, and displays it using ICONTOUR.
PRO maroonBellsContour_doc ; Restore Maroon Bells data into the IDL variable "elev". RESTORE, FILEPATH('marbells.dat', SUBDIR=['examples','data']) ; Create x and y vectors giving the position of each ; column and row. X = 326.850 + .030 * FINDGEN(72) Y = 4318.500 + .030 * FINDGEN(92) ; Set missing data points to a large value. Reduce to a ; 72 x 92 matrix. elev (WHERE (elev EQ 0)) = 1E6 new = REBIN(elev, 360/5, 460/5) iContour, new, X, Y, C_VALUE = 2750 + FINDGEN(6) * 250.,$ XSTYLE = 1, YSTYLE = 1, YMARGIN = 5, MAX_VALUE = 5000, $ C_LINESTYLE = [1, 0], $ C_THICK = [1, 1, 1, 1, 1, 3], $ XTITLE = 'UTM Coordinates (KM)' End
Note
See Creating SAVE Files of Programs and Data (Application Programming) for complete details on creating and restoring SAVE files.