hdf5/
mg_h5_getdata.pro
file i/o, hdf5, sdf
includes main-level programRoutine for extracting datasets, slices of datasets, or attributes from an HDF 5 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_h5_getdata
Author information
- Author
Michael Galloy
- Copyright
This library is released under a BSD-type license.
Copyright (c) 2007-2012, Michael Galloy <mgalloy@idldev.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
a. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. b. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. c. Neither the name of Michael Galloy nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Other file information
- Todo:
better error messages when items not found
Routines
top mg_h5_getdata
result = mg_h5_getdata(filename, variable [, bounds=lonarr(3, ndims) or string] [, error=long])
Pulls out a section of a HDF5 variable.
Return value
data array
Parameters
- filename in required type=string
filename of the HDF5 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 May 14 15:07:14 2014 |
Lines: | 213 |
Docformat: | rst rst |
Contact me if you have enhancement requests or bug fixes.