File: GetField_SubSampling.m

package info (click to toggle)
openems 0.0.35+dfsg.1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,288 kB
  • sloc: cpp: 40,259; yacc: 580; lex: 350; makefile: 258; sh: 169; ruby: 19
file content (63 lines) | stat: -rw-r--r-- 1,635 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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;

% store original indices
if (isfield(mesh_i,'original_indices'))
    for n=1:3
        mesh_i.original_indices{n} = mesh_i.original_indices{n}(ss_idx{n});
    end
else
    mesh_i.original_indices = ss_idx;
end

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