From 65c835dbf2223dc6d217da40c282953c77361362 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Fri, 27 Apr 2012 16:34:35 +0200 Subject: [PATCH] matlab: changes in reading hdf5 dumps * can now read additional attributes * API has changed regarding frequency attribute --- matlab/GetField_TD2FD.m | 2 +- matlab/ReadHDF5FieldData.m | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/matlab/GetField_TD2FD.m b/matlab/GetField_TD2FD.m index e4dc60f..1c3f216 100644 --- a/matlab/GetField_TD2FD.m +++ b/matlab/GetField_TD2FD.m @@ -25,7 +25,7 @@ dt = t(2)-t(1); clear field.FD -field.FD.freq = freq; +field.FD.frequency = freq; for nf = 1:numel(freq) field.FD.values{nf} = 0; diff --git a/matlab/ReadHDF5FieldData.m b/matlab/ReadHDF5FieldData.m index decd92e..2d49c41 100644 --- a/matlab/ReadHDF5FieldData.m +++ b/matlab/ReadHDF5FieldData.m @@ -43,14 +43,20 @@ for n=1:numel(info.GroupHierarchy.Groups) if strcmp(info.GroupHierarchy.Groups(n).Groups(nGroup).Name,'/FieldData/TD') for m=1:numel(info.GroupHierarchy.Groups(n).Groups(nGroup).Datasets) TD.names{m} = info.GroupHierarchy.Groups(n).Groups(nGroup).Datasets(m).Name; - TD.time(m) = double(info.GroupHierarchy.Groups(n).Groups(nGroup).Datasets(m).Attributes.Value); + for a = 1:numel(info.GroupHierarchy.Groups(n).Groups(nGroup).Datasets(m).Attributes) + str = regexp(info.GroupHierarchy.Groups(n).Groups(nGroup).Datasets(m).Attributes(a).Name,'\w/*\w*','match'); + TD.(str{end})(m) = double(info.GroupHierarchy.Groups(n).Groups(nGroup).Datasets(m).Attributes(a).Value); + end end end %search and read FD data if strcmp(info.GroupHierarchy.Groups(n).Groups(nGroup).Name,'/FieldData/FD') for m=1:numel(info.GroupHierarchy.Groups(n).Groups(nGroup).Datasets) FD.names{m} = info.GroupHierarchy.Groups(n).Groups(nGroup).Datasets(m).Name; - FD.freq(m) = double(info.GroupHierarchy.Groups(n).Groups(nGroup).Datasets(m).Attributes.Value); + for a = 1:numel(info.GroupHierarchy.Groups(n).Groups(nGroup).Datasets(m).Attributes) + str = regexp(info.GroupHierarchy.Groups(n).Groups(nGroup).Datasets(m).Attributes(a).Name,'\w/*\w*','match'); + FD.(str{end})(m) = double(info.GroupHierarchy.Groups(n).Groups(nGroup).Datasets(m).Attributes(a).Value); + end end end end @@ -59,14 +65,14 @@ for n=1:numel(info.GroupHierarchy.Groups) end if (numel(TD.names)>0) - hdf_fielddata.TD.names=TD.names; - hdf_fielddata.TD.time=TD.time; + hdf_fielddata.TD=TD; for n=1:numel(hdf_fielddata.TD.names) hdf_fielddata.TD.values{n} = double(hdf5read(file,hdf_fielddata.TD.names{n})); end end if (numel(FD.names)>0) + hdf_fielddata.FD=FD; Nr_freq = numel(FD.names); for n=1:Nr_freq name = ['/FieldData/FD/f' int2str(n-1) '_real']; @@ -75,11 +81,9 @@ if (numel(FD.names)>0) ind = find(strcmp(FD.names,['/FieldData/FD/f' int2str(n-1)])); if ~isempty(ind) hdf_fielddata.FD.values{n} = double(hdf5read(file,FD.names{ind})); - hdf_fielddata.FD.freq(n) = FD.freq(ind); end else hdf_fielddata.FD.values{n} = double(hdf5read(file,FD.names{ind})); - hdf_fielddata.FD.freq(n) = FD.freq(ind); name = ['/FieldData/FD/f' int2str(n-1) '_imag']; ind = find(strcmp(FD.names,name)); hdf_fielddata.FD.values{n} = hdf_fielddata.FD.values{n} + 1j*double(hdf5read(file,FD.names{ind})); @@ -107,6 +111,6 @@ if isfield(hdf.FieldData,'FD') for n=1:numel(hdf_fielddata_names)/2 hdf_fielddata.FD.values{n} = hdf.FieldData.FD.(hdf_fielddata_names{2*n}) + 1j*hdf.FieldData.FD.(hdf_fielddata_names{2*n-1}); hdf_fielddata.FD.names{n} = ['/FieldData/FD/' hdf_fielddata_names{2*n-1}(1:end-5)]; - hdf_fielddata.FD.freq(n) = h5readatt_octave(file,['/FieldData/FD/' hdf_fielddata_names{2*n}],'frequency'); + hdf_fielddata.FD.frequencies(n) = h5readatt_octave(file,['/FieldData/FD/' hdf_fielddata_names{2*n}],'frequency'); end end