netcdf/
mg_nc_getdata.pro
file i/o, netcdf, sdf
includes main-level programRoutine for extracting datasets, slices of datasets, or attributes from an netCDF file with simple notation.
Examples
An example file is provided with the IDL distribution:
IDL> f = filepath('hdf5_test.h5', subdir=['examples', 'data'])
IDL> fullResult = mg_h5_getdata(f, '/arrays/3D int array')
IDL> bounds = [[3, 3, 1], [5, 49, 2], [0, 49, 3]]
IDL> res1 = mg_h5_getdata(f, '/arrays/3D int array', bounds=bounds)
IDL> help, res1
RESULT1 LONG = Array[1, 23, 17]
IDL> same = array_equal(fullResult[3, 5:*:2, 0:49:3], res1)
IDL> print, same ? 'equal' : 'error'
equal
IDL> bounds = '3, 5:*:2, 0:49:3'
IDL> res2 = mg_h5_getdata(f, '/arrays/3D int array', bounds=bounds)
IDL> print, array_equal(res1, res2) ? 'equal' : 'error'
equal
IDL> res3 = mg_h5_getdata(f, '/arrays/3D int array[3, 5:*:2, 0:49:3]')
IDL> print, array_equal(res1, res3) ? 'equal' : 'error'
equal
IDL> print, mg_h5_getdata(f, '/images/Eskimo.CLASS')
IMAGE
IDL> .run mg_nc_getdata
Author information
- Author
Michael Galloy
Other file information
- Todo:
better error messages when items not found access for global attributes
top source mg_nc_getdata
result = mg_nc_getdata(filename, variable [, bounds=lonarr(3, ndims) or string] [, error=long])
Pulls out a section of a netCDF variable.
Return value
data array
Parameters
- filename in required type=string
filename of the netCDF file
- variable in required type=string
variable name (with path if inside a group)
Keywords
- bounds in optional type=lonarr(3, ndims) or string
gives start value, end value, and stride for each dimension of the variable
- error out optional type=long
error value
File attributes
Modification date: | Wed Sep 28 16:19:14 2011 |
Lines: | 417 |
Docformat: | rst rst |
Contact me if you have enhancement requests or bug fixes.