Hashes are data structures that store data and allow you to access it using keys. Below is an example how to access the data from a NetCDF file using ncdf_get and hash syntax:
IDL> f = file_which('sample.nc')
IDL> ncdf_get, f, 'image', result
IDL> image_hash = result["image"]
IDL> image_hash.keys()
[
"dim_names",
"value",
"dim_sizes",
"attributes"
]
IDL> data = image_hash["value"]
IDL> help, data
DATA BYTE = Array[768, 512]
IDL> i = image(data)
If you don't want to use hashes, you could also use the STRUCT keyword and use structures instead. An example of this is shown below:
IDL> ncdf_get, f, 'image', result2, /STRUCT
Reading image: BYTE(768,512) . . .
IDL> help, result2
** Structure , 2 tags, length=393304, data length=393304, refs=1:
CREATED STRING ' Created on Thu Apr 21 12:59:33 2016'
IMAGE STRUCT -> Array[1]
IDL> img_struct = result2.IMAGE
IDL> help, img_struct
** Structure , 4 tags, length=393288, data length=393288, refs=2:
DIM_NAMES STRING Array[2]
VALUE BYTE Array[768, 512]
DIM_SIZES LONG Array[2]
ATTRIBUTES STRUCT -> Array[1]
IDL> data = img_struct.value
IDL> i = image(data)
I hope this will be helpful.
David Starbuck
Harris Geospatial Solutions
|