ReadHDF5Dump: new sup-sampling for file reading

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
pull/1/head
Thorsten Liebig 2013-02-06 16:45:09 +01:00
parent 5da669d881
commit 138c094a44
2 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,54 @@
function [field_i mesh_i] = GetField_SubSampling(field, mesh, subsampling, varargin)
% [field_i mesh_i] = GetField_SubSampling(field, mesh, subsampling, varargin)
%
% Get a sub-sampled field, e.g. read by ReadHDF5Dump
%
% sub-sampling e.g. skipping every second line in x/r direction: [2 1 1]
%
% openEMS matlab interface
% -----------------------
% author: Thorsten Liebig
%
% See also ReadHDF5Dump ReadHDF5FieldData ReadHDF5Mesh
if (~isnumeric(subsampling) || numel(subsampling)~=3)
error('openEMS:GetField_Interpolation: numLines for interpolation must be a vector...');
end
x = mesh.lines{1};
y = mesh.lines{2};
z = mesh.lines{3};
ss_idx{1} = 1:subsampling(1):numel(x);
ss_idx{2} = 1:subsampling(2):numel(y);
ss_idx{3} = 1:subsampling(3):numel(z);
x_i = x(ss_idx{1});
y_i = y(ss_idx{2});
z_i = z(ss_idx{3});
field_i = field;
mesh_i = mesh;
mesh_i.lines{1} = x_i;
mesh_i.lines{2} = y_i;
mesh_i.lines{3} = z_i;
if (isfield(field,'TD'))
field_i.TD = subsample_fields(field.TD,ss_idx);
field_i.TD.time = field.TD.time;
field_i.TD.names= field.TD.names;
end
if (isfield(field,'FD'))
field_i.FD = subsample_fields(field.FD,ss_idx);
field_i.FD.frequency = field.FD.frequency;
field_i.FD.DataType = field.FD.DataType;
end
return
function field_i = subsample_fields(field, ss_idx)
for n=1:numel(field.values)
field_i.values{n} = field.values{n}(ss_idx{1},ss_idx{2},ss_idx{3},:);
end

View File

@ -10,6 +10,7 @@ function [field mesh] = ReadHDF5Dump(file, varargin)
% possible arguments:
% 'Range' see GetField_Range
% 'Interpolation' see GetField_Interpolation
% 'SubSampling' see GetField_SubSampling
% 'Frequency' see GetField_TD2FD
% 'CloseAlpha': 0 (default) / 1
%
@ -24,7 +25,7 @@ function [field mesh] = ReadHDF5Dump(file, varargin)
% -----------------------
% author: Thorsten Liebig
%
% See also ReadHDF5Mesh ReadHDF5FieldData GetField_Interpolation
% See also ReadHDF5Mesh ReadHDF5FieldData GetField_Interpolation GetField_SubSampling
% GetField_TD2FD GetField_Range
field = ReadHDF5FieldData(file);
@ -41,6 +42,12 @@ for n=1:2:(nargin-1)
end
end
for n=1:2:(nargin-1)
if (strcmp(varargin{n},'SubSampling')==1);
[field mesh] = GetField_SubSampling(field,mesh,varargin{n+1});
end
end
for n=1:2:(nargin-1)
if (strcmp(varargin{n},'Interpolation')==1);
[field mesh] = GetField_Interpolation(field,mesh,varargin{n+1});