资源简介
不再维护或支持gprMax的先前版本(V2),这是最后一个更新版本,GprMax 2.0 最终更新版
代码片段和文件信息
function [HeaderFields]=gprmax(name);
% GPRMAX3D Read binary data generated by ‘GprMax3D‘ and ‘GprMax2D‘
% simulators for ground probing radar.
%
% [Header Fields] = gprmax( ‘filename‘ )
% filename is the name of a binary format file generated either
% from ‘GprMax3D‘ or ‘GprMax2D‘
%
% Header is a structure containing details of the model
%
% Fields is a structure containing the electromagnetic fields at
% the requested output points for a number of requested
% steps
%
%
% (NOTE: The field matrices of snapshots cary 3D data
% Copyright: Antonis Giannopoulos 1997 2002 2005
% This file is not part of the ‘GprMax3D‘ programme for ground probing
% radar simulation and can be freely distributed.
FT_3D=30200;
FT_2D=20200;
SMALL=0;
BIG=0;
if(nargin==0)
error(‘GprMax3D requires at least one argument‘);
end;
if(nargin==1)
type=‘native‘;
end;
if(isstr(name)~=1)
error(‘First argument is not a filename‘);
end;
fid=fopen(name‘rb‘);
if(fid==-1)
error([‘Can not open =‘name]);
end;
ECHECK1=fread(fid1‘char‘);
if(strcmp(setstr(dec2hex(ECHECK1))‘2B‘)==1 )
SMALL=0;
BIG=1;
end;
if(strcmp(setstr(dec2hex(ECHECK1))‘67‘)==1 )
SMALL=1;
BIG=0;
end;
ECHECK2=fread(fid1‘char‘);
if(BIG==1)
if(strcmp(setstr(dec2hex(ECHECK2))‘67‘) == 0)
error([‘This is not a GprMax2D/3D file.‘]);
end;
end;
if(SMALL==1)
if(strcmp(setstr(dec2hex(ECHECK2))‘2B‘) == 0)
error([‘This is not a GprMax2D/3D file.‘]);
end;
end;
% If you are here you have a valid file. Unless someone is playing a but joke !!
% Close and open again to make sure you will read it properly.
fclose(fid);
if(SMALL==1)
fid=fopen(name‘rb‘‘ieee-le‘);
end;
if(BIG==1)
fid=fopen(name‘rb‘‘ieee-be‘);
end;
% Read Endian again but no check !
temp=fread(fid1‘short‘);
% Read type of file
FileType=fread(fid1‘short‘);
SWORD=fread(fid1‘short‘);
SREAL=fread(fid1‘short‘);
titleLENGTH=fread(fid1‘short‘);
SOURCELENGTH=fread(fid1‘short‘);
MEDIALENGTH=fread(fid1‘short‘);
RESERVED=fread(fid2‘char‘);
if(SWORD==2)
word=‘short‘;
end;
if(SWORD==4)
word=‘long‘;
end;
if(SREAL==4)
real=‘float‘;
end;
if(SREAL==8)
real=‘double‘;
end;
% Set Defaults for all
Model=struct([]);
Rx=struct([]);
% Set title to none
%Model(1).title=‘No title‘;
switch FileType
case FT_2D+4 % 2D snapshot
disp([‘Reading GprMax2D #snapshot: file ...‘name]);
Model(1).title=fread(fidtitleLENGTH‘char‘);
Model(1).title=setstr(Model(1).title‘);
Model(1).iterations=fread(fid1real);
Model(1).dx=fread(fid1real);
Model(1).dy=fread(fid1real);
Model(1).dt=fread(fid1real);
Model(1).globalTx=fread(fid1word);
Model(1).Snapx1=fread(fid1word);
Model(1).Snapy1=fread(fid1word);
Model(1).Snapx2=fread(fid1word);
Model(1).Snapy2=fread(fid1word);
Model(1).Snapxs=fread(fi
评论
共有 条评论