| 1 |
function [data,xax,yax,time,pltslc] = ... |
function [data,xax,yax,time,pltslc] = ... |
| 2 |
DiagLoad(fln,trl,dat,dad,grd,itr,tst,flu,ddf,gdf,avg,slc,pst,... |
DiagLoad(fln,trl,dat,dad,grd,itr,tst,flu,ddf,gdf,avg,slc,pst,... |
| 3 |
LoadGridData,DiagDebug,GridSuffix,ZcordFile,Index,Dim,... |
LoadGridData,DiagDebug,GridSuffix,ZcordFile,Index,Dim,Vector,Mate,... |
| 4 |
Grads,Year0Iter,Months); |
Grads,Year0Iter,SecPerYear,Months,FieldName); |
| 5 |
|
|
| 6 |
|
|
| 7 |
% Load parameters. |
% Load parameters. |
| 25 |
else , mnchandle = 'tave.*' ; end |
else , mnchandle = 'tave.*' ; end |
| 26 |
elseif isequal(dat,'Ins') |
elseif isequal(dat,'Ins') |
| 27 |
filesuffix = ''; mnchandle = 'state.*'; |
filesuffix = ''; mnchandle = 'state.*'; |
| 28 |
|
elseif isequal(dat(1:2),'Mn') |
| 29 |
|
filesuffix = ''; |
| 30 |
|
if ismember(dat,{'MnA','MnO'}), mnchandle = 'monitor.*'; end |
| 31 |
|
if isequal(dat,'MnI'), mnchandle = 'monitor_sice.*'; end |
| 32 |
|
if isequal(dat,'MnL'), mnchandle = 'monitor_land.*'; end |
| 33 |
elseif ismember(dat,{'','Non','None'}) |
elseif ismember(dat,{'','Non','None'}) |
| 34 |
filesuffix = ''; mnchandle = ''; |
filesuffix = ''; mnchandle = ''; |
| 35 |
else |
else |
| 51 |
% Open grads files |
% Open grads files |
| 52 |
if ~isequal(Grads,0) |
if ~isequal(Grads,0) |
| 53 |
if DiagDebug, disp([' Debug -- Loading GRADS field.']); end |
if DiagDebug, disp([' Debug -- Loading GRADS field.']); end |
| 54 |
[data,xax,yax,zax,months,time,dim] = DiagLoadGradsData(Grads,dad,fln,DiagDebug); |
[data,xax,yax,zax,months,time,dim] = ... |
| 55 |
|
DiagLoadGradsData(Grads,dad,fln,DiagDebug); |
| 56 |
if DiagDebug, disp([' Debug -- ''data'' size after load: ',mat2str(size(data))]); end |
if DiagDebug, disp([' Debug -- ''data'' size after load: ',mat2str(size(data))]); end |
| 57 |
data = DiagAverage(data,fln,avg,months,ddf,dim); |
data = DiagAverage(data,fln,avg,months,ddf,dim); |
| 58 |
if DiagDebug, disp([' Debug -- ''data'' size after averaging: ',mat2str(size(data))]); end |
if DiagDebug, disp([' Debug -- ''data'' size after averaging: ',mat2str(size(data))]); end |
| 62 |
else |
else |
| 63 |
error('Loading grads data only set to handle surface plots!'); |
error('Loading grads data only set to handle surface plots!'); |
| 64 |
end |
end |
| 65 |
|
|
| 66 |
|
% Load monitor data. |
| 67 |
|
elseif isequal(dat(1:2),'Mn') |
| 68 |
|
[data,time] = ... |
| 69 |
|
DiagLoadMonitor(fln,mnchandle,dad,itr,tst,SecPerYear,DiagDebug); |
| 70 |
|
xax = time; yax = NaN; pltslc = 'timfld'; |
| 71 |
|
|
| 72 |
% Load AIM physics data. The data is all stuffed into one file called |
% Load AIM physics data. The data is all stuffed into one file called |
| 73 |
% 'aimPhy' which currently only comes in MDS format. When loading a field, |
% 'aimPhy' which currently only comes in MDS format. When loading a field, |
| 80 |
% stresses (on atmosphere) must converted to a lat-lon grid. |
% stresses (on atmosphere) must converted to a lat-lon grid. |
| 81 |
elseif ismember(fln,aimparameters) |
elseif ismember(fln,aimparameters) |
| 82 |
if isequal(ddf,'MNC') |
if isequal(ddf,'MNC') |
| 83 |
error('Aim physics reader not set to hande ''MNC'' data format.') |
error('Aim physics reader not set to handle ''MNC'' data format.') |
| 84 |
end |
end |
| 85 |
data = DiagLoad_Local('aimPhy',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
data = DiagLoad_Local('aimPhy',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 86 |
if isequal(fln,'TotP') |
if isequal(fln,'TotP') |
| 173 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
| 174 |
|
|
| 175 |
% Load horizontal velocities, convert to lat-lon grid. |
% Load horizontal velocities, convert to lat-lon grid. |
| 176 |
elseif ismember(fln,{'U','V','uVel','vVel'}) |
elseif ismember(fln,{'U','V','uVel','vVel','fizhi_U','fizhi_V'}) |
| 177 |
if isequal(dat,'Tav') |
if isequal(dat,'Tav') |
| 178 |
U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 179 |
V = DiagLoad_Local('vVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
V = DiagLoad_Local('vVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 180 |
else isequal(dat,'Ins') |
else isequal(dat,'Ins') |
| 181 |
U = DiagLoad_Local('U',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
U = DiagLoad_Local([fln(1:end-1),'U'],dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 182 |
V = DiagLoad_Local('V',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
V = DiagLoad_Local([fln(1:end-1),'V'],dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 183 |
end |
end |
| 184 |
if isequal(ddf,'MNC') |
if isequal(ddf,'MNC') |
| 185 |
U = U(1:end-1,:,:,:); |
U = U(1:end-1,:,:,:); |
| 190 |
[XC,XG,YC,YG,Ylat,ZC,ZG,RAC,drC,drF,HFacC,HFacW,HFacS,dxG,dyG,dxC,dyC] = ... |
[XC,XG,YC,YG,Ylat,ZC,ZG,RAC,drC,drF,HFacC,HFacW,HFacS,dxG,dyG,dxC,dyC] = ... |
| 191 |
DiagLoadGridData(LoadGridData,grd,gdf,flu,GridSuffix,ZcordFile); |
DiagLoadGridData(LoadGridData,grd,gdf,flu,GridSuffix,ZcordFile); |
| 192 |
[U,V]=uvcube2latlon(XC,YC,U,V,XL,YL); |
[U,V]=uvcube2latlon(XC,YC,U,V,XL,YL); |
| 193 |
if ismember(fln,{'U','uVel'}) |
if ismember(fln,{'U','uVel','fizhi_U'}) |
| 194 |
data = U; |
data = U; |
| 195 |
elseif ismember(fln,{'V','vVel'}) |
elseif ismember(fln,{'V','vVel','fizhi_V'}) |
| 196 |
data = V; |
data = V; |
| 197 |
end |
end |
| 198 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 330 |
disp([' Unknown field, attempting to load.']); |
disp([' Unknown field, attempting to load.']); |
| 331 |
data = DiagLoad_Local(fln,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
data = DiagLoad_Local(fln,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 332 |
if DiagDebug, disp([' Debug -- ''data'' size after load: ',mat2str(size(data))]); end |
if DiagDebug, disp([' Debug -- ''data'' size after load: ',mat2str(size(data))]); end |
| 333 |
if ~isequal(Index,0) |
if isequal(Vector,1) | isequal(Vector,2) | isequal(Vector,3) |
| 334 |
|
if isequal(Vector,1) | isequal(Vector,3) |
| 335 |
|
if ~isequal(Index,0) |
| 336 |
|
if isequal(Dim,2), U = squeeze(data(:,:,Index,:)); |
| 337 |
|
elseif isequal(Dim,3), U = squeeze(data(:,:,:,Index,:)); end |
| 338 |
|
end |
| 339 |
|
if ~isequal(Mate,0) |
| 340 |
|
if isequal(Dim,2), V = squeeze(data(:,:,Mate,:)); |
| 341 |
|
elseif isequal(Dim,3), V = squeeze(data(:,:,:,Mate,:)); end |
| 342 |
|
end |
| 343 |
|
elseif isequal(Vector,2) |
| 344 |
|
if ~isequal(Index,0) |
| 345 |
|
if isequal(Dim,2), V = squeeze(data(:,:,Index,:)); |
| 346 |
|
elseif isequal(Dim,3), V = squeeze(data(:,:,:,Index,:)); end |
| 347 |
|
end |
| 348 |
|
if ~isequal(Mate,0) |
| 349 |
|
if isequal(Dim,2), U = squeeze(data(:,:,Mate,:)); |
| 350 |
|
elseif isequal(Dim,3), U = squeeze(data(:,:,:,Mate,:)); end |
| 351 |
|
end |
| 352 |
|
end |
| 353 |
|
U = DiagAverage(U,fln,avg,months,ddf,Dim); |
| 354 |
|
V = DiagAverage(V,fln,avg,months,ddf,Dim); |
| 355 |
|
[XC,XG,YC,YG,Ylat,ZC,ZG,RAC,drC,drF,HFacC,HFacW,HFacS,dxG,dyG,dxC,dyC] = ... |
| 356 |
|
DiagLoadGridData(LoadGridData,grd,gdf,flu,GridSuffix,ZcordFile); |
| 357 |
|
if isequal(Vector,1) | isequal(Vector,2) |
| 358 |
|
[U,V]=uvcube2latlon(XC,YC,U,V,XL,YL); |
| 359 |
|
end |
| 360 |
|
if isequal(Vector,1) |
| 361 |
|
data = U; |
| 362 |
|
elseif isequal(Vector,2) |
| 363 |
|
data = V; |
| 364 |
|
elseif isequal(Vector,3) |
| 365 |
|
if isequal(flu,'A'), delM = - 1000*drF ./ g; |
| 366 |
|
elseif isequal(flu,'O'), delM = drF; end |
| 367 |
|
[psiavg,mskG,ylat]=calc_PsiCube(delM,U.*HFacW,V.*HFacS,dxG,dyG); |
| 368 |
|
data = psiavg(2:end-1,:)'; |
| 369 |
|
if isequal(flu,'A'), data = data./1e6; end |
| 370 |
|
xax = ylat; yax = ZG; pltslc = 'lathgt'; |
| 371 |
|
end |
| 372 |
|
if DiagDebug, disp([' Debug -- ''data'' size after vector manipulation: ',mat2str(size(data))]); end |
| 373 |
|
else |
| 374 |
|
% Sequence here for Vector = 0 |
| 375 |
|
if ~isequal(Index,0) |
| 376 |
if isequal(Dim,2), data = squeeze(data(:,:,Index,:)); |
if isequal(Dim,2), data = squeeze(data(:,:,Index,:)); |
| 377 |
elseif isequal(Dim,3), data = squeeze(data(:,:,:,Index,:)); end |
elseif isequal(Dim,3), data = squeeze(data(:,:,:,Index,:)); end |
| 378 |
|
end |
| 379 |
|
if DiagDebug, disp([' Debug -- ''data'' size after indexing: ',mat2str(size(data))]); end |
| 380 |
|
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 381 |
|
% Actual Temperature -- When the FieldName says ActT we assume that |
| 382 |
|
% the field that is pointed to in Index is potential temperature |
| 383 |
|
if isequal(FieldName,'ActT') |
| 384 |
|
[XC,XG,YC,YG,Ylat,ZC,ZG,RAC,drC,drF,HFacC,HFacW,HFacS,dxG,dyG,dxC,dyC] = ... |
| 385 |
|
DiagLoadGridData(LoadGridData,grd,gdf,flu,GridSuffix,ZcordFile); |
| 386 |
|
pres = NaN.*zeros(size(data)); |
| 387 |
|
for iz=1:length(ZC), pres(:,:,iz)=ZC(iz); end |
| 388 |
|
temp=data.*(pres./presrefA).^(RdA/cpA); |
| 389 |
|
data=temp; |
| 390 |
|
end |
| 391 |
|
|
| 392 |
|
if DiagDebug, disp([' Debug -- ''data'' size after average: ',mat2str(size(data))]); end |
| 393 |
end |
end |
| 394 |
if DiagDebug, disp([' Debug -- ''data'' size after indexing: ',mat2str(size(data))]); end |
if ~isequal(Vector,3) |
|
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
|
|
if DiagDebug, disp([' Debug -- ''data'' size after average: ',mat2str(size(data))]); end |
|
| 395 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 396 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
| 397 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
| 399 |
if DiagDebug, disp([' Debug -- ''xax'' size: ',mat2str(size(xax))]); end |
if DiagDebug, disp([' Debug -- ''xax'' size: ',mat2str(size(xax))]); end |
| 400 |
if DiagDebug, disp([' Debug -- ''yax'' size: ',mat2str(size(yax))]); end |
if DiagDebug, disp([' Debug -- ''yax'' size: ',mat2str(size(yax))]); end |
| 401 |
if DiagDebug, disp([' Debug -- ''pltslc'': ',pltslc]); end |
if DiagDebug, disp([' Debug -- ''pltslc'': ',pltslc]); end |
| 402 |
|
end |
| 403 |
end |
end |
| 404 |
|
|
|
|
|
| 405 |
%-------------------------------------------------------------------------% |
%-------------------------------------------------------------------------% |
| 406 |
% Local functions % |
% Local functions % |
| 407 |
%-------------------------------------------------------------------------% |
%-------------------------------------------------------------------------% |