2010-12-20 09:40:33 +00:00
|
|
|
function field = GetField_TD2FD(field, freq)
|
|
|
|
% function field = GetField_TD2FD(field, freq)
|
2010-05-25 10:26:04 +00:00
|
|
|
%
|
2010-07-15 09:46:36 +00:00
|
|
|
% Transforms time-domain field data into the frequency domain
|
2019-05-19 20:09:04 +00:00
|
|
|
% Auto-corrects the half-timestep offset of the H-field
|
2010-05-25 10:26:04 +00:00
|
|
|
%
|
|
|
|
% example:
|
2010-07-15 09:46:36 +00:00
|
|
|
% freq = linspace(0,1e9,100); %target frequency vector (Hz)
|
2010-05-25 10:26:04 +00:00
|
|
|
% field = ReadHDF5FieldData('tmp/Ht.h5');
|
|
|
|
% field_FD = GetField_TD2FD(field, freq);
|
|
|
|
%
|
|
|
|
% openEMS matlab interface
|
|
|
|
% -----------------------
|
|
|
|
% author: Thorsten Liebig
|
2010-07-15 09:46:36 +00:00
|
|
|
%
|
|
|
|
% See also ReadHDF5FieldData
|
2010-05-25 10:26:04 +00:00
|
|
|
|
2010-12-20 09:40:33 +00:00
|
|
|
if (~isfield(field,'TD'))
|
|
|
|
warning('openEMS:GetField_TD2FD','field has no time domain data... skipping FD transformation...');
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
t = field.TD.time;
|
2011-04-11 09:43:43 +00:00
|
|
|
dt = t(2)-t(1);
|
2010-12-20 09:40:33 +00:00
|
|
|
|
|
|
|
clear field.FD
|
2010-05-25 10:26:04 +00:00
|
|
|
|
2012-04-27 14:34:35 +00:00
|
|
|
field.FD.frequency = freq;
|
2010-05-25 10:26:04 +00:00
|
|
|
|
|
|
|
for nf = 1:numel(freq)
|
2010-12-20 09:40:33 +00:00
|
|
|
field.FD.values{nf} = 0;
|
2010-05-25 10:26:04 +00:00
|
|
|
end
|
|
|
|
|
2010-12-20 09:40:33 +00:00
|
|
|
numTS = numel(field.TD.values);
|
2010-05-25 10:26:04 +00:00
|
|
|
|
|
|
|
for n=1:numTS
|
|
|
|
for nf = 1:numel(freq)
|
|
|
|
f = freq(nf);
|
2011-04-11 09:43:43 +00:00
|
|
|
field.FD.values{nf} = field.FD.values{nf} + field.TD.values{n}.*exp(-1i*2*pi*f*t(n)) * 2 * dt;
|
2010-07-15 09:46:36 +00:00
|
|
|
% t(n) is absolute time and therefore the half-timestep offset of
|
|
|
|
% the H-field is automatically compensated
|
|
|
|
% openEMS output: E-fields start at t=0
|
|
|
|
% openEMS output: H-fields start at t=delta_t/2
|
2010-05-25 10:26:04 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-09-21 12:18:47 +00:00
|
|
|
field.FD.DataType=1;
|
|
|
|
|