MATLAB's HDF5 Updates John Evans Image and Scientific Data Formats Quick Overview The MATLAB HDF5 low-level interface is divided into “packages” that correspond to.

Download Report

Transcript MATLAB's HDF5 Updates John Evans Image and Scientific Data Formats Quick Overview The MATLAB HDF5 low-level interface is divided into “packages” that correspond to.

MATLAB's HDF5 Updates
John Evans
Image and Scientific Data Formats
Quick Overview
The MATLAB HDF5 low-level interface is divided into “packages” that
correspond to the HDF5 interfaces. One such class is “H5F”, which has
“open” as a member function.
H5, H5A, H5D, H5DS, H5E, H5F, H5G, H5I, H5L, H5ML(??),
H5O, H5P, H5R, H5S, H5T, H5Z.
H5ML is a special MATLAB “helper” package.
R2009b
What's New In R2009b
 HDF5 offerings based on library version 1.8.1
 Support for H5L, H5O, H5DS interfaces
 A little bit more speed!
 Over 300 functions in corresponding to HDF5 C API
3
R2009b
Link Interface
>> help H5L
Contents for H5L: Link interface
H5L.create_hard
- Creates a hard link
H5L.create_soft
- Creates a soft link
H5L.delete
- Deletes a link
H5L.exists
- Checks for the existence of a link
H5L.get_info
- Returns information about a link
H5L.get_val
- Returns the value of a symbolic link
H5L.iterate
- Iterates through links in a group
H5L.iterate_by_name - Iterates through links in a group
H5L.move
- Moves a link from one location to another
H5L.visit
- Iterate through all links in and below a group
H5L.visit_by_name
- Iterate through all links in and below a group
4
R2009b
H5COPY
>> help h5copy
H5COPY copies an object from one HDF5 file to another file.
h5copy(INPUTFILE,OUTPUTFILE,SRCOBJ,DSTOBJ) copies the source
object name SRCOBJ in the input HDF5 file INPUTFILE to the
destination identified by DSTOBJ in OUTPUTFILE.
The behavior of the copy is to recursively copy all objects below
the group, keep soft links as they are, keep external links as
they are, update only the values of object references, and to copy
attributes along with the object.
This program was translated from the source code of "h5copy.c"
written by Pedro Vicente Nunes and Quincey Koziol, THG.
5
R2009b
H5COPY
% open input file
ifid = H5F.open(ifile,'H5F_ACC_RDONLY','H5P_DEFAULT');
% open output file
if exist(ofile,'file')
ofid = H5F.open(ofile,'H5F_ACC_RDWR','H5P_DEFAULT');
else
fcpl = H5P.create('H5P_FILE_CREATE');
ofid = H5F.create(ofile,'H5F_ACC_TRUNC',fcpl,'H5P_DEFAULT');
H5P.close(fcpl);
end
% create property lists for copy
ocpl = H5P.create('H5P_OBJECT_COPY');
6
R2009b
H5COPY
% create link creation property list
lcpl = H5P.create('H5P_LINK_CREATE');
% Set the intermediate creation property
H5P.set_create_intermediate_group(lcpl,true);
% do the copy
H5O.copy(ifid,srcObjName,ofid,dstObjName,ocpl,lcpl);
H5P.close(lcpl);
H5P.close(ocpl);
H5F.close(ifid);
H5F.close(ofid);
7
NetCDF-4? Well, sort of...
 Native support for netCDF-3 since R2008b, not just yet for
netCDF-4…
 … but NetCDF-4 is HDF5 under the hood, so you can read with
low-level HDF5 interface now.
 Java? Yep, it's possible to use netcdf-java right now in MATLAB.
 3rd party mex-file mexcdf recompiled statically with HDF5
and NetCDF-4.
References
 MathWorks: http://www.mathworks.com
 HDF5TOOLS: go to
http://www.mathworks.com/matlabcentral/fileexchange/ and
search for HDF5TOOLS
 NetCDF Java Library:
http://www.unidata.ucar.edu/software/netcdf-java/
 SNCTOOLS: http://mexcdf.sourceforge.net/
 HDF5 Group: go to
http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/
and look for the MATLAB examples