2012-02-02 11:23:50 +00:00
|
|
|
function nf2ff = ReadNF2FF(nf2ff)
|
|
|
|
% function nf2ff = ReadNF2FF(nf2ff)
|
|
|
|
%
|
|
|
|
% internal function to read calculated nf2ff data, use CalcNF2FF to read
|
|
|
|
% existing nf2ff data
|
|
|
|
%
|
|
|
|
% See also: CalcNF2FF, CreateNF2FFBox
|
|
|
|
%
|
|
|
|
% openEMS matlab interface
|
|
|
|
% -----------------------
|
|
|
|
% author: Thorsten Liebig, 2012
|
|
|
|
|
|
|
|
file = nf2ff.hdf5;
|
|
|
|
|
|
|
|
hdf_mesh = ReadHDF5Mesh(file);
|
|
|
|
|
|
|
|
nf2ff.r = double(hdf_mesh.lines{1});
|
|
|
|
nf2ff.theta = double(hdf_mesh.lines{2});
|
|
|
|
nf2ff.phi = double(hdf_mesh.lines{3});
|
|
|
|
|
2012-09-21 12:16:13 +00:00
|
|
|
% read attributes
|
|
|
|
nf2ff.freq = ReadHDF5Attribute(file,'/nf2ff','Frequency');
|
|
|
|
nf2ff.Prad = ReadHDF5Attribute(file,'/nf2ff','Prad');
|
|
|
|
nf2ff.Dmax = ReadHDF5Attribute(file,'/nf2ff','Dmax');
|
|
|
|
|
2013-06-03 19:44:12 +00:00
|
|
|
try
|
|
|
|
nf2ff.Eps_r = ReadHDF5Attribute(file,'/nf2ff','Eps_r');
|
|
|
|
catch
|
|
|
|
nf2ff.Eps_r = ones(size(nf2ff.freq));
|
|
|
|
end
|
|
|
|
try
|
|
|
|
nf2ff.Mue_r = ReadHDF5Attribute(file,'/nf2ff','Mue_r');
|
|
|
|
catch
|
|
|
|
nf2ff.Mue_r = ones(size(nf2ff.freq));
|
|
|
|
end
|
|
|
|
|
2012-02-02 11:23:50 +00:00
|
|
|
if isOctave
|
|
|
|
hdf = load( '-hdf5', file );
|
|
|
|
for n=1:numel(nf2ff.freq)
|
2012-02-13 08:58:15 +00:00
|
|
|
nf2ff.E_theta{n} = double(hdf.nf2ff.E_theta.FD.(['f' int2str(n-1) '_real']) +1i*hdf.nf2ff.E_theta.FD.(['f' int2str(n-1) '_imag']) );
|
|
|
|
nf2ff.E_phi{n} = double(hdf.nf2ff.E_phi.FD.(['f' int2str(n-1) '_real']) +1i*hdf.nf2ff.E_phi.FD.(['f' int2str(n-1) '_imag']) );
|
|
|
|
nf2ff.E_norm{n} = double(sqrt(abs(nf2ff.E_theta{n}).^2+abs(nf2ff.E_phi{n}).^2));
|
2012-07-18 13:45:37 +00:00
|
|
|
nf2ff.P_rad{n} = double(hdf.nf2ff.P_rad.FD.(['f' int2str(n-1)]));
|
2012-02-02 11:23:50 +00:00
|
|
|
end
|
|
|
|
else
|
2012-09-17 09:52:26 +00:00
|
|
|
% matlab compatibility to older versions
|
|
|
|
if verLessThan('matlab','7.12')
|
|
|
|
% read data
|
2012-02-13 08:58:15 +00:00
|
|
|
for n=1:numel(nf2ff.freq)
|
|
|
|
nf2ff.E_theta{n} = double(hdf5read(file,['/nf2ff/E_theta/FD/f' int2str(n-1) '_real']) + 1i*hdf5read(file,['/nf2ff/E_theta/FD/f' int2str(n-1) '_imag']));
|
|
|
|
nf2ff.E_phi{n} = double(hdf5read(file,['/nf2ff/E_phi/FD/f' int2str(n-1) '_real']) + 1i*hdf5read(file,['/nf2ff/E_phi/FD/f' int2str(n-1) '_imag']));
|
|
|
|
nf2ff.E_norm{n} = double(sqrt(abs(nf2ff.E_theta{n}).^2+abs(nf2ff.E_phi{n}).^2));
|
2012-07-18 13:45:37 +00:00
|
|
|
nf2ff.P_rad{n} = double(hdf5read(file,['/nf2ff/P_rad/FD/f' int2str(n-1)]));
|
2012-02-13 08:58:15 +00:00
|
|
|
end
|
2013-01-02 18:23:25 +00:00
|
|
|
else
|
|
|
|
% read data
|
|
|
|
for n=1:numel(nf2ff.freq)
|
|
|
|
nf2ff.E_theta{n} = double(h5read(file,['/nf2ff/E_theta/FD/f' int2str(n-1) '_real']) + 1i*h5read(file,['/nf2ff/E_theta/FD/f' int2str(n-1) '_imag']));
|
|
|
|
nf2ff.E_phi{n} = double(h5read(file,['/nf2ff/E_phi/FD/f' int2str(n-1) '_real']) + 1i*h5read(file,['/nf2ff/E_phi/FD/f' int2str(n-1) '_imag']));
|
|
|
|
nf2ff.E_norm{n} = double(sqrt(abs(nf2ff.E_theta{n}).^2+abs(nf2ff.E_phi{n}).^2));
|
|
|
|
nf2ff.P_rad{n} = double(h5read(file,['/nf2ff/P_rad/FD/f' int2str(n-1)]));
|
|
|
|
end
|
2012-02-13 08:58:15 +00:00
|
|
|
end
|
2013-01-02 18:23:25 +00:00
|
|
|
end
|
2012-02-13 08:58:15 +00:00
|
|
|
|
2013-01-02 18:23:25 +00:00
|
|
|
% Calculation of right- and left-handed circular polarization
|
|
|
|
% adopted from
|
|
|
|
% 2012, Tim Pegg <teepegg@gmail.com>
|
|
|
|
|
2013-01-07 11:31:14 +00:00
|
|
|
% cleanup (if exist)
|
|
|
|
nf2ff.E_cprh = [];
|
|
|
|
nf2ff.E_cplh = [];
|
|
|
|
|
2013-01-02 18:23:25 +00:00
|
|
|
% Setup vectors for converting to LHCP and RHCP polarization senses
|
2013-02-13 12:56:18 +00:00
|
|
|
[THETHA PHI] = ndgrid(nf2ff.theta,nf2ff.phi);
|
|
|
|
cosphi = cos(PHI);
|
|
|
|
sinphi = sin(PHI);
|
2013-01-02 18:23:25 +00:00
|
|
|
|
|
|
|
for f=1:numel(nf2ff.freq)
|
2013-02-13 12:56:18 +00:00
|
|
|
nf2ff.E_cprh{f} = (cosphi+1i*sinphi) .* (nf2ff.E_theta{f}+1i*nf2ff.E_phi{f})/sqrt(2);
|
|
|
|
nf2ff.E_cplh{f} = (cosphi-1i*sinphi) .* (nf2ff.E_theta{f}-1i*nf2ff.E_phi{f})/sqrt(2);
|
2012-02-02 11:23:50 +00:00
|
|
|
end
|