%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Disclaimer: this info is provided as is and is not part of the IceRadar application. It is provided to help users to %take advantage of the hdf5 file open format, which is the file format used in IceRadar. For more information %about IceRadar, contact Blue System Integration Ltd , Vancouver BC. Canada. http://www.bluesystem.ca ; info@bluesystem.ca . %If modifications and improvements on how to work with IceRadar files with Matlab are made, we would welcome sharing this information. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Return file info fileinfo = hdf5info('glacier2_UTM_may08.h5 '); %it returns: %fileinfo = % % Filename: 'glacier2_UTM_may08.h5 ' % LibVersion: '1.6.2' % Offset: 0 % FileSize: 54318792 % GroupHierarchy: [1x1 struct] % return hierarchy toplevel = fileinfo.GroupHierarchy; %it returns: %toplevel = % % Filename: 'glacier2_UTM_may08.h5 ' % Name: '/' % Groups: [1x12 struct] % Datasets: [] % Datatypes: [] % Links: [] % Attributes: [] % one can see the Groups have 12 elts: these are the 12 "Lines" in the % file. Datasets and so on are nested inside these groups, which may be % why they do not appear for now. %let' s look at the structure Groups in the object Groups lines = fileinfo.GroupHierarchy.Groups %lines = % %1x12 struct array with fields: % Filename % Name % Groups % Datasets % Datatypes % Links % Attributes % it returns a structure with amongst other, another set of groups. %let's look at a particular line's content: fileinfo.GroupHierarchy.Groups(1).Groups(1) %the name will appear, in this case: /line_0/location_0 fileinfo.GroupHierarchy.Groups(1).Groups(1).Groups(1) % Then the dataset will appeart with the command above as: % '/line_0/location_0/datacapture_0' fileinfo.GroupHierarchy.Groups(1).Groups(1).Groups(1).Datasets(1) %will show the dataset name etc... and the existance of attribues % Filename: 'glacier2_UTM_may08.h5 ' % Name: '/line_0/location_0/datacapture_0/echogram_0' % Rank: 1 % Datatype: [1x1 struct] % Dims: 200 % MaxDims: -1 % Layout: 'chunked' % Attributes: [1x4 struct] % Links: [] % Chunksize: [] % FillValue: 0 fileinfo.GroupHierarchy.Groups(1).Groups(1).Groups(1).Datasets(1).Attributes(1) %will show the attribure structure: % Filename: 'glacier2_UTM_may08.h5 ' % Name: [1x58 char] % Value: [1x1 hdf5.h5string] fileinfo.GroupHierarchy.Groups(1).Groups(1).Groups(1).Datasets(1).Attributes(1).Name % will returbn the 1st attribure of the dataset's name % /line_0/location_0/datacapture_0/echogram_0/Save timestamp % same idea for Attributes 2 to 4: the name can be retrieved. fileinfo.GroupHierarchy.Groups(1).Groups(1).Groups(1).Datasets(1).Attributes(2).Value % this will return the value of the attribure %hdf5.h5string: % % Name: '' % Length: 4 % Padding: 'nullterm' % Data: 'Ј' fileinfo.GroupHierarchy.Groups(1).Groups(1).Groups(1).Datasets(1).Attributes(2).Value.data %however the data seems to be binary. %Remembering arrays in Matlab are indexed starting at 1, while index starts at 0 in LabVIEW: %the dataset name is defined this way >> datasetname datasetname = '/line_0/location_0/datacapture_0/echogram_0'; filename = 'E:\Project - Active\5017-01 SFUGlacio - Radar\Software\Data\data_kluane_May08\RadarData_withUTM_withPicking\glacier2_UTM_PICK_may08.h5'; data = hdf5read(filename,datasetname); plot (data); %this will plot echogram from this location. % for the attribures: attributename = '/line_0/location_0/datacapture_0/echogram_0/GPS Cluster- MetaData_xml' hdf5read(filename,attributename) %returns %hdf5.h5string: % Name: '' % Length: 4 % Padding: 'nullterm' % Data: '0Ý ' %which is still binary... %from the HDF5TOOLS librarie found at: %http://www.mathworks.com/matlabcentral/fileexchange/17172 %the following steps can retrieve the attributes, and hence the GPS info, %saving time, scope settings. %we already seen that the following code returns a radargram: datasetname = '/line_0/location_0/datacapture_0/echogram_0'; filename = 'E:\Project - Active\5017-01 SFUGlacio - Radar\Software\Data\data_kluane_May08\RadarData_withUTM_withPicking\glacier2_UTM_PICK_may08.h5'; data = hdf5read(filename,datasetname); plot (data); %now to return the attributes: attributename1 = 'Save timestamp' d=h5attget(filename, datasetname,attributename1) d = '07/05/2008_11:46:07 AM' %Here d is returned as a string. %for the other attribures: attributename2 = 'GPS Cluster- MetaData_xml' attributename2 = GPS Cluster- MetaData_xml d=h5attget(filename, datasetname,attributename2) d = [1x718 char] % The Char has to be converted to a string, in our case an xml string x=char(d) %will return the attribute as a string, xml, that can then be parsed using %xml parsing tools, or some string-based coding. From this GPS data in Lat %etc.. can be retrieved. %last thing to retrieve are the actual names of the lines and location. %these were stored as "comment" of the object. So the HDF5 API function %"H5Gget_comment" should be called for this. No examples found on this so %far. See HDF web site for the command: %http://www.hdfgroup.org/HDF5/doc1.6/RM_H5G.html#Group-GetComment