2010-04-05 21:16:52 +00:00
|
|
|
function PlotHDF5FieldData(file, PlotArgs)
|
2010-04-24 14:43:22 +00:00
|
|
|
% function PlotHDF5FieldData(file, PlotArgs)
|
|
|
|
%
|
|
|
|
% e.g.
|
|
|
|
% PlotArgs.slice = {0 [10 20] 0};
|
|
|
|
% PlotArgs.pauseTime=0.01;
|
|
|
|
% PlotArgs.component=2;
|
|
|
|
% PlotArgs.Limit = 'auto';
|
|
|
|
%
|
|
|
|
% PlotHDF5FieldData('tmp/Et.h5',PlotArgs)
|
|
|
|
%
|
|
|
|
% openEMS matlab interface
|
|
|
|
% -----------------------
|
|
|
|
% author: Thorsten Liebig
|
2010-04-05 21:16:52 +00:00
|
|
|
|
|
|
|
component = PlotArgs.component;
|
|
|
|
|
|
|
|
if (isfield(PlotArgs,'pauseTime'))
|
|
|
|
pauseT = PlotArgs.pauseTime;
|
|
|
|
else
|
|
|
|
pauseT = 0.01;
|
|
|
|
end
|
|
|
|
|
|
|
|
mesh = ReadHDF5Mesh(file);
|
|
|
|
fields = ReadHDF5FieldData(file);
|
|
|
|
|
2010-04-23 06:17:42 +00:00
|
|
|
if (mesh.type==0)
|
|
|
|
[X Y Z] = meshgrid(double(mesh.lines{1}),double(mesh.lines{2}),double(mesh.lines{3}));
|
|
|
|
else
|
|
|
|
disp(['PlotHDF5FieldData:: Error: unknown mesh type ' num2str(mesh.type)]);
|
|
|
|
end
|
2010-04-07 14:32:22 +00:00
|
|
|
|
2010-04-05 21:16:52 +00:00
|
|
|
max_amp = 0;
|
|
|
|
|
2010-04-07 14:32:22 +00:00
|
|
|
if (component>0)
|
|
|
|
for n=1:numel(fields.values)
|
|
|
|
Field{n} = double(fields.values{n}(:,:,:,component));
|
2010-04-05 21:16:52 +00:00
|
|
|
end
|
2010-04-07 14:32:22 +00:00
|
|
|
else
|
|
|
|
for n=1:numel(fields.values)
|
|
|
|
fx = double(fields.values{n}(:,:,:,1));
|
|
|
|
fy = double(fields.values{n}(:,:,:,2));
|
|
|
|
fz = double(fields.values{n}(:,:,:,3));
|
|
|
|
Field{n} = sqrt(fx.^2 + fy.^2 + fz.^2);
|
|
|
|
end
|
2010-04-05 21:16:52 +00:00
|
|
|
end
|
|
|
|
|
2010-04-07 14:32:22 +00:00
|
|
|
for n=1:numel(Field)
|
|
|
|
amp = max(max(max(abs(Field{n}))));
|
2010-04-05 21:16:52 +00:00
|
|
|
if (amp>max_amp)
|
|
|
|
max_amp = amp;
|
|
|
|
end
|
|
|
|
end
|
2010-04-07 14:32:22 +00:00
|
|
|
|
2010-04-05 21:16:52 +00:00
|
|
|
if (max_amp==0)
|
|
|
|
disp('max found amplitude was 0 --> nothing to plot');
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2010-04-07 14:32:22 +00:00
|
|
|
for n=1:numel(Field)
|
|
|
|
hsurfaces = slice(X,Y,Z, Field{n} , PlotArgs.slice{:});
|
|
|
|
set(hsurfaces,'FaceColor','interp','EdgeColor','none');
|
2010-04-05 21:16:52 +00:00
|
|
|
title(fields.names{n});
|
2010-04-07 14:32:22 +00:00
|
|
|
%view(3)
|
|
|
|
axis equal
|
2010-04-24 14:43:22 +00:00
|
|
|
if (isfield(PlotArgs,'Limit'))
|
|
|
|
if ~ischar(PlotArgs.Limit)
|
|
|
|
caxis(PlotArgs.Limit);
|
|
|
|
elseif strcmp(PlotArgs.Limit,'auto')
|
|
|
|
if (component>0)
|
|
|
|
caxis([-max_amp,max_amp]);
|
|
|
|
else
|
|
|
|
caxis([0,max_amp]);
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-04-07 14:32:22 +00:00
|
|
|
drawnow
|
2010-04-05 21:16:52 +00:00
|
|
|
pause(pauseT)
|
|
|
|
end
|