Parent Directory
|
Revision Log
|
Revision Graph
|
Patch
--- MITgcm_contrib/enderton/Diagnostics/DiagLoadGradsData.m 2005/01/31 15:43:26 1.1
+++ MITgcm_contrib/enderton/Diagnostics/DiagLoadGradsData.m 2005/01/31 19:58:15 1.2
@@ -1,10 +1,16 @@
function [data,xax,yax,zax,months,time,dim] = ...
- DiagLoadGradsData(Grads,dad,fln)
+ DiagLoadGradsData(Grads,dad,fln,DiagDebug)
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Parse table file %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+format = 'NONSEQUENTIAL';
-% Read table file.
tablfile = [dad,'/',Grads,'.tabl'];
-datafile = [dad,'/',Grads,'.data'];
file = textread(tablfile,'%s','delimiter','\n','whitespace','');
+
for iline = 1:length(file)
rem = file{iline}; tokens = {}; itoken = 0;
while isstr(rem)
@@ -74,7 +80,8 @@
elseif isequal(monchar,'NOV'), inimonth = 11;
elseif isequal(monchar,'DEC'), inimonth = 12; end
num = str2num(tokens{2});
- months=[inimonth:num]; time=months/12; nt = length(months);
+ months=[inimonth:num+inimonth-1];
+ time=months/12; nt = length(months);
end
@@ -82,21 +89,39 @@
nv = str2num(tokens{2});
VARSline = iline;
end
-
if isequal(tokens{1},fln)
FIELDline = iline;
- index = iline - VARSline;
+ ivar = iline - VARSline;
end
if isequal(tokens{1},'UNDEF')
undef = str2num(tokens{2});
end
+ if isequal(tokens{1},'FORMAT')
+ if isequal(tokens{2},'SEQUENTIAL')
+ format = 'SEQUENTIAL';
+ else
+ disp(['Unrecognized grads FORMAT: ',tokens{2}]);
+ end
+ end
+
+ if isequal(tokens{1},'DSET')
+ datafile = [dad,tokens{2}(2:end)];
+ end
+
end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Verification and debugging %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+if DiagDebug, disp([' Debug -- grads data format: ',format]); end
+
% Verify that things are there.
-parameters = {'xax' ,'yax' ,'zax' ,'time','nv' ,'undef','index'};
-GRADSnames = {'XDEF','YDEF','ZDEF','TDEF','VARS','UNDEF',fln };
+parameters = {'xax' ,'yax' ,'zax' ,'time','nv' ,'undef','ivar'};
+GRADSnames = {'XDEF','YDEF','ZDEF','TDEF','VARS','UNDEF',fln };
for ii = 1:length(parameters)
try
eval([parameters{ii},';']);
@@ -105,11 +130,21 @@
end
end
-% Read in grads data using axis infomation.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Read data file %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
tol = 1e-5;
fid=fopen(datafile,'r','b');
data = fread(fid,'real*4');
fclose(fid);
+if isequal(format,'SEQUENTIAL')
+ index=true([nx*ny*nz*nv*nt+2*nv*nt,1]);
+ index([1:nx*ny*nz+2:end])=false;
+ index([2:nx*ny*nz+2:end])=false;
+ data = data(index);
+end
data = reshape(data,[nx,ny,nz,nv,nt]);
-data = squeeze(data(:,:,:,index,:));
+data = squeeze(data(:,:,:,ivar,:));
data( abs((data-undef)/undef) < tol ) = NaN;
\ No newline at end of file
| ViewVC Help | |
| Powered by ViewVC 1.1.22 |