matlab: new option for ConvertHDF5_VTK to choose a field weighting
Signed-off-by: Thorsten Liebig <thorsten.liebig@gmx.de>pull/1/head
parent
42f0a6dc59
commit
183d5f2899
|
@ -13,6 +13,7 @@ function ConvertHDF5_VTK(hdf_file, vtk_prefix, varargin)
|
|||
% 'NumPhase': number of phase to dump frequency domain data animation
|
||||
% (default is 36 --> 10°)
|
||||
% 'FieldName': field name written to vtk, e.g. 'E-Field'
|
||||
% 'weight': field weighting
|
||||
%
|
||||
% example:
|
||||
% % read time-domian data from hdf5, perform dft and dump as vtk
|
||||
|
@ -27,6 +28,7 @@ function ConvertHDF5_VTK(hdf_file, vtk_prefix, varargin)
|
|||
do_FD_dump = 1;
|
||||
do_TD_dump = 0;
|
||||
phase_N = 36;
|
||||
weight = 1;
|
||||
|
||||
fieldname = 'unknown';
|
||||
|
||||
|
@ -43,6 +45,9 @@ for n=1:2:numel(varargin)
|
|||
if (strcmp(varargin{n},'FieldName')==1);
|
||||
fieldname = varargin{n+1};
|
||||
end
|
||||
if (strcmp(varargin{n},'weight')==1);
|
||||
weight = varargin{n+1};
|
||||
end
|
||||
end
|
||||
|
||||
[field mesh] = ReadHDF5Dump(hdf_file, varargin{:});
|
||||
|
@ -55,23 +60,29 @@ if (do_FD_dump)
|
|||
if (~isfield(field,'FD'))
|
||||
warning('openEMS:ConvertHDF5_VTK','no FD data found skipping frequency domian vtk dump...');
|
||||
else
|
||||
%set weighting
|
||||
if (numel(weight)~=numel(field.FD.frequency))
|
||||
FD_weight = ones(size(field.FD.frequency))*weight(1);
|
||||
else
|
||||
FD_weight = weight;
|
||||
end
|
||||
if (field.FD.DataType==1) % dump complex value FD data
|
||||
ph = linspace(0,360,phase_N+1);
|
||||
ph = ph(1:end-1);
|
||||
for n = 1:numel(field.FD.frequency)
|
||||
for p = ph
|
||||
filename = [vtk_prefix '_' num2str(field.FD.frequency(n)) '_' num2str(p,'%03d') '.vtk' ];
|
||||
Dump2VTK(filename, real(field.FD.values{n}*exp(1j*p*pi/180)), mesh, fieldname, varargin{:});
|
||||
Dump2VTK(filename, real(FD_weight(n)*field.FD.values{n}*exp(1j*p*pi/180)), mesh, fieldname, varargin{:});
|
||||
end
|
||||
filename = [vtk_prefix '_' num2str(field.FD.frequency(n)) '_abs.vtk' ];
|
||||
Dump2VTK(filename, abs(field.FD.values{n}), mesh, fieldname, varargin{:});
|
||||
Dump2VTK(filename, abs(FD_weight(n)*field.FD.values{n}), mesh, fieldname, varargin{:});
|
||||
filename = [vtk_prefix '_' num2str(field.FD.frequency(n)) '_ang.vtk' ];
|
||||
Dump2VTK(filename, angle(field.FD.values{n}), mesh, fieldname, varargin{:});
|
||||
Dump2VTK(filename, angle(FD_weight(n)*field.FD.values{n}), mesh, fieldname, varargin{:});
|
||||
end
|
||||
else % dump real value FD data
|
||||
for n = 1:numel(field.FD.frequency)
|
||||
filename = [vtk_prefix '_' num2str(field.FD.frequency(n)) '.vtk' ];
|
||||
Dump2VTK(filename, real(field.FD.values{n}), mesh, fieldname, varargin{:});
|
||||
Dump2VTK(filename, real(FD_weight(n)*field.FD.values{n}), mesh, fieldname, varargin{:});
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -85,7 +96,7 @@ if (do_TD_dump)
|
|||
acc = ['%0' int2str(ceil(log10(numel(field.TD.time)+1))) 'd'];
|
||||
for n = 1:numel(field.TD.time)
|
||||
filename = [vtk_prefix '_TD_' num2str(n,acc) '.vtk' ];
|
||||
Dump2VTK(filename, field.TD.values{n}, mesh, fieldname, varargin{:});
|
||||
Dump2VTK(filename, abs(weight(1))*field.TD.values{n}, mesh, fieldname, varargin{:});
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue