| 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,SecPerYear,Months); |
Grads,Year0Iter,SecPerYear,Months,FieldName); |
| 5 |
|
|
| 6 |
|
|
| 7 |
% Load parameters. |
% Load parameters. |
| 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 |
| 59 |
if isequal(slc,'Sur') |
% if isequal(slc,'Sur') |
| 60 |
data = data'; |
% data = data'; |
| 61 |
pltslc='lonlat'; |
% pltslc='lonlat'; |
| 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 |
|
[data,xax,yax,pltslc] = ... |
| 66 |
|
DiagSliceGradsData(fln,flu,slc,data,xax,yax,zax); |
| 67 |
|
|
| 68 |
% Load monitor data. |
% Load monitor data. |
| 69 |
elseif isequal(dat(1:2),'Mn') |
elseif isequal(dat(1:2),'Mn') |
| 107 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 108 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 109 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
| 110 |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
| 111 |
|
|
| 112 |
% Load coupled fields. Like AIM, the data is all stuffed into one file |
% Load coupled fields. Like AIM, the data is all stuffed into one file |
| 113 |
% called either 'cplFld.*' (MDS) or 'cpl_tave.*' (MNC). Variables within |
% called either 'cplFldtave.*' (MDS) or 'cpl_tave.*' (MNC). Variables within |
| 114 |
% the MDS files given in 'DiagGenParam', accessed directly with MNC. TX |
% the MDS files given in 'DiagGenParam', accessed directly with MNC. TX |
| 115 |
% and TY (stress on ocean) must be converted to lat-lon grid. |
% and TY (stress on ocean) must be converted to lat-lon grid. |
| 116 |
elseif ismember(fln,cplparameters) |
elseif ismember(fln,cplparameters) |
| 140 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 141 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 142 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
| 143 |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
| 144 |
|
|
| 145 |
% Load ice parameters. Note that as the ice variable names appear to be in |
% Load ice parameters. Note that as the ice variable names appear to be in |
| 146 |
% constant flux, this part quickly becomes out of date. |
% constant flux, this part quickly becomes out of date. |
| 155 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 156 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 157 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
| 158 |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
| 159 |
|
|
| 160 |
% Load generic fields where no modifications are needed. |
% Load generic fields where no modifications are needed. |
| 161 |
elseif ismember(fln,{'S','T','Temp','aim_RH','phiHyd','Conv'}) |
elseif ismember(fln,{'S','T','Temp','aim_RH','phiHyd','Conv'}) |
| 163 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 164 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 165 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
| 166 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
| 167 |
|
|
| 168 |
% Read vertical velocities, eta. Convert from [P] to [hPa] in atmosphere. |
% Read vertical velocities, eta. Convert from [P] to [hPa] in atmosphere. |
| 169 |
elseif ismember(fln,{'W','wVel','Eta','ETA'}) |
elseif ismember(fln,{'W','wVel','Eta','ETA'}) |
| 172 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 173 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 174 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
| 175 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
| 176 |
|
|
| 177 |
% Load horizontal velocities, convert to lat-lon grid. |
% Load horizontal velocities, convert to lat-lon grid. |
| 178 |
elseif ismember(fln,{'U','V','uVel','vVel','fizhi_U','fizhi_V'}) |
elseif ismember(fln,{'U','V','uVel','vVel','fizhi_U','fizhi_V'}) |
| 199 |
end |
end |
| 200 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 201 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
| 202 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
| 203 |
|
|
| 204 |
% Meridional overturning. |
% Meridional overturning. |
| 205 |
elseif ismember(fln,{'Bol','Psi','Res'}) |
elseif ismember(fln,{'Bol','Psi','Res'}) |
| 282 |
end |
end |
| 283 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 284 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,ddf,gdf,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,ddf,gdf,... |
| 285 |
avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
| 286 |
|
|
| 287 |
|
|
| 288 |
% Read in variabilities. Here we must make some simple calculations. For |
% Read in variabilities. Here we must make some simple calculations. For |
| 298 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 299 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 300 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
| 301 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
| 302 |
elseif isequal(fln,'Tstd') |
elseif isequal(fln,'Tstd') |
| 303 |
T = DiagLoad_Local('T' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
T = DiagLoad_Local('T' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 304 |
TT = DiagLoad_Local('TT',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
TT = DiagLoad_Local('TT',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 306 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 307 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 308 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
| 309 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
| 310 |
elseif isequal(fln,'KEpri') |
elseif isequal(fln,'KEpri') |
| 311 |
U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 312 |
V = DiagLoad_Local('vVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
V = DiagLoad_Local('vVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 313 |
UU = DiagLoad_Local('UU' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
UU = DiagLoad_Local('UU' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 314 |
VV = DiagLoad_Local('VV' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
VV = DiagLoad_Local('VV' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 315 |
if isequal(ddf,'MNC') |
if isequal(ddf,'MNC') |
| 316 |
U = .5*( U(2:end,:,:,:) + U(1:end-1,:,:,:) ); |
U = U(1:end-1,:,:,:); UU = UU(1:end-1,:,:,:); |
| 317 |
V = .5*( V(:,2:end,:,:) + V(:,1:end-1,:,:) ); |
V = V(:,1:end-1,:,:); VV = VV(:,1:end-1,:,:); |
|
%UU = .5*( UU(2:end,:,:,:) + UU(1:end-1,:,:,:) ); % UU and VV might be incorrect. |
|
|
%VV = .5*( VV(:,2:end,:,:) + VV(:,1:end-1,:,:) ); |
|
| 318 |
end |
end |
| 319 |
U = DiagAverage(U,fln,avg,months,ddf,Dim); |
U = DiagAverage(U ,fln,avg,months,ddf,Dim); |
| 320 |
V = DiagAverage(V,fln,avg,months,ddf,Dim); |
V = DiagAverage(V ,fln,avg,months,ddf,Dim); |
| 321 |
UU = DiagAverage(UU,fln,avg,months,ddf,Dim); |
UU = DiagAverage(UU,fln,avg,months,ddf,Dim); |
| 322 |
VV = DiagAverage(VV,fln,avg,months,ddf,Dim); |
VV = DiagAverage(VV,fln,avg,months,ddf,Dim); |
| 323 |
data = sqrt(abs((U.*U + V.*V) - (UU + VV))); |
data = sqrt(abs((U.*U + V.*V) - (UU + VV))); |
| 324 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 325 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
| 326 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
| 327 |
|
|
| 328 |
% If the field is not recognized, try best to try and open it. |
% If the field is not recognized, try best to try and open it. |
| 329 |
else |
else |
| 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) & isequal(size(Index),[1 1]) & isequal(sign(Index),1) |
| 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 |
|
elseif isequal(size(Index),[1 1]) & ~isequal(sign(Index),1) |
| 379 |
|
if isequal(Dim,2), data = sign(Index(1)).*squeeze(data(:,:,abs(Index(1)),:)); |
| 380 |
|
elseif isequal(Dim,3), data = sign(Index(1)).*squeeze(data(:,:,:,abs(Index(1)),:)); end |
| 381 |
|
elseif isequal(size(Index),[1 2]) |
| 382 |
|
if isequal(Dim,2), data = sign(Index(1)).*squeeze(data(:,:,abs(Index(1)),:)) + sign(Index(2)).*squeeze(data(:,:,abs(Index(2)),:)); |
| 383 |
|
elseif isequal(Dim,3), data = sign(Index(1)).*squeeze(data(:,:,:,abs(Index(1)),:)) + sign(Index(2)).*squeeze(data(:,:,:,abs(Index(2)),:)); end |
| 384 |
|
end |
| 385 |
|
if DiagDebug, disp([' Debug -- ''data'' size after indexing: ',mat2str(size(data))]); end |
| 386 |
|
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 387 |
|
% Actual Temperature -- When the FieldName says ActT we assume that |
| 388 |
|
% the field that is pointed to in Index is potential temperature |
| 389 |
|
if isequal(FieldName,'ActT') |
| 390 |
|
[XC,XG,YC,YG,Ylat,ZC,ZG,RAC,drC,drF,HFacC,HFacW,HFacS,dxG,dyG,dxC,dyC] = ... |
| 391 |
|
DiagLoadGridData(LoadGridData,grd,gdf,flu,GridSuffix,ZcordFile); |
| 392 |
|
pres = NaN.*zeros(size(data)); |
| 393 |
|
for iz=1:length(ZC), pres(:,:,iz)=ZC(iz); end |
| 394 |
|
temp=data.*(pres./presrefA).^(RdA/cpA); |
| 395 |
|
data=temp; |
| 396 |
|
end |
| 397 |
|
|
| 398 |
|
if DiagDebug, disp([' Debug -- ''data'' size after average: ',mat2str(size(data))]); end |
| 399 |
end |
end |
| 400 |
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 |
|
| 401 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 402 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
| 403 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
| 404 |
if DiagDebug, disp([' Debug -- ''data'' size after slice: ',mat2str(size(data))]); end |
if DiagDebug, disp([' Debug -- ''data'' size after slice: ',mat2str(size(data))]); end |
| 405 |
if DiagDebug, disp([' Debug -- ''xax'' size: ',mat2str(size(xax))]); end |
if DiagDebug, disp([' Debug -- ''xax'' size: ',mat2str(size(xax))]); end |
| 406 |
if DiagDebug, disp([' Debug -- ''yax'' size: ',mat2str(size(yax))]); end |
if DiagDebug, disp([' Debug -- ''yax'' size: ',mat2str(size(yax))]); end |
| 407 |
if DiagDebug, disp([' Debug -- ''pltslc'': ',pltslc]); end |
if DiagDebug, disp([' Debug -- ''pltslc'': ',pltslc]); end |
| 408 |
|
end |
| 409 |
end |
end |
| 410 |
|
|
|
|
|
| 411 |
%-------------------------------------------------------------------------% |
%-------------------------------------------------------------------------% |
| 412 |
% Local functions % |
% Local functions % |
| 413 |
%-------------------------------------------------------------------------% |
%-------------------------------------------------------------------------% |
| 415 |
% Thus is merely a local function that calls the load data functions |
% Thus is merely a local function that calls the load data functions |
| 416 |
% according to the DataFormat for the data specified by dfm. |
% according to the DataFormat for the data specified by dfm. |
| 417 |
function data = DiagLoad_Local(fln,dat,dad,grd,itr,dfm,filesuffix,mnchandle) |
function data = DiagLoad_Local(fln,dat,dad,grd,itr,dfm,filesuffix,mnchandle) |
|
|
|
| 418 |
if isequal(dfm,'MDS') |
if isequal(dfm,'MDS') |
| 419 |
data = rdmds([dad,'/',fln,filesuffix],itr); |
data = rdmds([dad,'/',fln,filesuffix],itr); |
| 420 |
elseif isequal(dfm,'MNC') |
elseif isequal(dfm,'MNC') |
| 421 |
iter = rdmnc_mod([dad,mnchandle],'T'); |
data = rdmnc_mod2([dad,mnchandle],[fln,filesuffix],'iter','T',itr); |
| 422 |
iter = iter.T; |
if ~isequal(itr,data.iter'), error('Missing iterations in data!'); end |
|
[dummy,indecies] = ismember(itr,iter); |
|
|
data = rdmnc_mod([dad,mnchandle],[fln,filesuffix],'T',indecies); |
|
|
iter = data.T; |
|
|
if ~isequal(itr,iter'), error('Missing iterations in data!'); end |
|
| 423 |
eval(['data = data.',fln,filesuffix,';']); |
eval(['data = data.',fln,filesuffix,';']); |
| 424 |
else |
else |
| 425 |
error(['Unrecognized data type: ',dfm]); |
error(['Unrecognized data type: ',dfm]); |