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. |
105 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
106 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
107 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
108 |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
109 |
|
|
110 |
% 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 |
111 |
% called either 'cplFld.*' (MDS) or 'cpl_tave.*' (MNC). Variables within |
% called either 'cplFldtave.*' (MDS) or 'cpl_tave.*' (MNC). Variables within |
112 |
% the MDS files given in 'DiagGenParam', accessed directly with MNC. TX |
% the MDS files given in 'DiagGenParam', accessed directly with MNC. TX |
113 |
% and TY (stress on ocean) must be converted to lat-lon grid. |
% and TY (stress on ocean) must be converted to lat-lon grid. |
114 |
elseif ismember(fln,cplparameters) |
elseif ismember(fln,cplparameters) |
138 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
139 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
140 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
141 |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
142 |
|
|
143 |
% 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 |
144 |
% constant flux, this part quickly becomes out of date. |
% constant flux, this part quickly becomes out of date. |
153 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
154 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
155 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
156 |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
157 |
|
|
158 |
% Load generic fields where no modifications are needed. |
% Load generic fields where no modifications are needed. |
159 |
elseif ismember(fln,{'S','T','Temp','aim_RH','phiHyd','Conv'}) |
elseif ismember(fln,{'S','T','Temp','aim_RH','phiHyd','Conv'}) |
161 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
162 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
163 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
164 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
165 |
|
|
166 |
% Read vertical velocities, eta. Convert from [P] to [hPa] in atmosphere. |
% Read vertical velocities, eta. Convert from [P] to [hPa] in atmosphere. |
167 |
elseif ismember(fln,{'W','wVel','Eta','ETA'}) |
elseif ismember(fln,{'W','wVel','Eta','ETA'}) |
170 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
171 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
172 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
173 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
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','fizhi_U','fizhi_V'}) |
elseif ismember(fln,{'U','V','uVel','vVel','fizhi_U','fizhi_V'}) |
197 |
end |
end |
198 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
199 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
200 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
201 |
|
|
202 |
% Meridional overturning. |
% Meridional overturning. |
203 |
elseif ismember(fln,{'Bol','Psi','Res'}) |
elseif ismember(fln,{'Bol','Psi','Res'}) |
280 |
end |
end |
281 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
282 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,ddf,gdf,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,ddf,gdf,... |
283 |
avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
284 |
|
|
285 |
|
|
286 |
% Read in variabilities. Here we must make some simple calculations. For |
% Read in variabilities. Here we must make some simple calculations. For |
296 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
297 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
298 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
299 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
300 |
elseif isequal(fln,'Tstd') |
elseif isequal(fln,'Tstd') |
301 |
T = DiagLoad_Local('T' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
T = DiagLoad_Local('T' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
302 |
TT = DiagLoad_Local('TT',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
TT = DiagLoad_Local('TT',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
304 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
305 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
306 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
307 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
308 |
elseif isequal(fln,'KEpri') |
elseif isequal(fln,'KEpri') |
309 |
U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
310 |
V = DiagLoad_Local('vVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
V = DiagLoad_Local('vVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
311 |
UU = DiagLoad_Local('UU' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
UU = DiagLoad_Local('UU' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
312 |
VV = DiagLoad_Local('VV' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
VV = DiagLoad_Local('VV' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
313 |
if isequal(ddf,'MNC') |
if isequal(ddf,'MNC') |
314 |
U = .5*( U(2:end,:,:,:) + U(1:end-1,:,:,:) ); |
U = U(1:end-1,:,:,:); UU = UU(1:end-1,:,:,:); |
315 |
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,:,:) ); |
|
316 |
end |
end |
317 |
U = DiagAverage(U,fln,avg,months,ddf,Dim); |
U = DiagAverage(U ,fln,avg,months,ddf,Dim); |
318 |
V = DiagAverage(V,fln,avg,months,ddf,Dim); |
V = DiagAverage(V ,fln,avg,months,ddf,Dim); |
319 |
UU = DiagAverage(UU,fln,avg,months,ddf,Dim); |
UU = DiagAverage(UU,fln,avg,months,ddf,Dim); |
320 |
VV = DiagAverage(VV,fln,avg,months,ddf,Dim); |
VV = DiagAverage(VV,fln,avg,months,ddf,Dim); |
321 |
data = sqrt(abs((U.*U + V.*V) - (UU + VV))); |
data = sqrt(abs((U.*U + V.*V) - (UU + VV))); |
322 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
323 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
324 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
325 |
|
|
326 |
% 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. |
327 |
else |
else |
328 |
disp([' Unknown field, attempting to load.']); |
disp([' Unknown field, attempting to load.']); |
329 |
data = DiagLoad_Local(fln,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
data = DiagLoad_Local(fln,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
330 |
if DiagDebug, disp([' Debug -- ''data'' size after load: ',mat2str(size(data))]); end |
if DiagDebug, disp([' Debug -- ''data'' size after load: ',mat2str(size(data))]); end |
331 |
if ~isequal(Index,0) |
if isequal(Vector,1) | isequal(Vector,2) | isequal(Vector,3) |
332 |
|
if isequal(Vector,1) | isequal(Vector,3) |
333 |
|
if ~isequal(Index,0) |
334 |
|
if isequal(Dim,2), U = squeeze(data(:,:,Index,:)); |
335 |
|
elseif isequal(Dim,3), U = squeeze(data(:,:,:,Index,:)); end |
336 |
|
end |
337 |
|
if ~isequal(Mate,0) |
338 |
|
if isequal(Dim,2), V = squeeze(data(:,:,Mate,:)); |
339 |
|
elseif isequal(Dim,3), V = squeeze(data(:,:,:,Mate,:)); end |
340 |
|
end |
341 |
|
elseif isequal(Vector,2) |
342 |
|
if ~isequal(Index,0) |
343 |
|
if isequal(Dim,2), V = squeeze(data(:,:,Index,:)); |
344 |
|
elseif isequal(Dim,3), V = squeeze(data(:,:,:,Index,:)); end |
345 |
|
end |
346 |
|
if ~isequal(Mate,0) |
347 |
|
if isequal(Dim,2), U = squeeze(data(:,:,Mate,:)); |
348 |
|
elseif isequal(Dim,3), U = squeeze(data(:,:,:,Mate,:)); end |
349 |
|
end |
350 |
|
end |
351 |
|
U = DiagAverage(U,fln,avg,months,ddf,Dim); |
352 |
|
V = DiagAverage(V,fln,avg,months,ddf,Dim); |
353 |
|
[XC,XG,YC,YG,Ylat,ZC,ZG,RAC,drC,drF,HFacC,HFacW,HFacS,dxG,dyG,dxC,dyC] = ... |
354 |
|
DiagLoadGridData(LoadGridData,grd,gdf,flu,GridSuffix,ZcordFile); |
355 |
|
if isequal(Vector,1) | isequal(Vector,2) |
356 |
|
[U,V]=uvcube2latlon(XC,YC,U,V,XL,YL); |
357 |
|
end |
358 |
|
if isequal(Vector,1) |
359 |
|
data = U; |
360 |
|
elseif isequal(Vector,2) |
361 |
|
data = V; |
362 |
|
elseif isequal(Vector,3) |
363 |
|
if isequal(flu,'A'), delM = - 1000*drF ./ g; |
364 |
|
elseif isequal(flu,'O'), delM = drF; end |
365 |
|
[psiavg,mskG,ylat]=calc_PsiCube(delM,U.*HFacW,V.*HFacS,dxG,dyG); |
366 |
|
data = psiavg(2:end-1,:)'; |
367 |
|
if isequal(flu,'A'), data = data./1e6; end |
368 |
|
xax = ylat; yax = ZG; pltslc = 'lathgt'; |
369 |
|
end |
370 |
|
if DiagDebug, disp([' Debug -- ''data'' size after vector manipulation: ',mat2str(size(data))]); end |
371 |
|
else |
372 |
|
% Sequence here for Vector = 0 |
373 |
|
if ~isequal(Index,0) & isequal(size(Index),[1 1]) & isequal(sign(Index),1) |
374 |
if isequal(Dim,2), data = squeeze(data(:,:,Index,:)); |
if isequal(Dim,2), data = squeeze(data(:,:,Index,:)); |
375 |
elseif isequal(Dim,3), data = squeeze(data(:,:,:,Index,:)); end |
elseif isequal(Dim,3), data = squeeze(data(:,:,:,Index,:)); end |
376 |
|
elseif isequal(size(Index),[1 1]) & ~isequal(sign(Index),1) |
377 |
|
if isequal(Dim,2), data = sign(Index(1)).*squeeze(data(:,:,abs(Index(1)),:)); |
378 |
|
elseif isequal(Dim,3), data = sign(Index(1)).*squeeze(data(:,:,:,abs(Index(1)),:)); end |
379 |
|
elseif isequal(size(Index),[1 2]) |
380 |
|
if isequal(Dim,2), data = sign(Index(1)).*squeeze(data(:,:,abs(Index(1)),:)) + sign(Index(2)).*squeeze(data(:,:,abs(Index(2)),:)); |
381 |
|
elseif isequal(Dim,3), data = sign(Index(1)).*squeeze(data(:,:,:,abs(Index(1)),:)) + sign(Index(2)).*squeeze(data(:,:,:,abs(Index(2)),:)); end |
382 |
|
end |
383 |
|
if DiagDebug, disp([' Debug -- ''data'' size after indexing: ',mat2str(size(data))]); end |
384 |
|
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
385 |
|
% Actual Temperature -- When the FieldName says ActT we assume that |
386 |
|
% the field that is pointed to in Index is potential temperature |
387 |
|
if isequal(FieldName,'ActT') |
388 |
|
[XC,XG,YC,YG,Ylat,ZC,ZG,RAC,drC,drF,HFacC,HFacW,HFacS,dxG,dyG,dxC,dyC] = ... |
389 |
|
DiagLoadGridData(LoadGridData,grd,gdf,flu,GridSuffix,ZcordFile); |
390 |
|
pres = NaN.*zeros(size(data)); |
391 |
|
for iz=1:length(ZC), pres(:,:,iz)=ZC(iz); end |
392 |
|
temp=data.*(pres./presrefA).^(RdA/cpA); |
393 |
|
data=temp; |
394 |
|
end |
395 |
|
|
396 |
|
if DiagDebug, disp([' Debug -- ''data'' size after average: ',mat2str(size(data))]); end |
397 |
end |
end |
398 |
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 |
|
399 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
400 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
401 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
402 |
if DiagDebug, disp([' Debug -- ''data'' size after slice: ',mat2str(size(data))]); end |
if DiagDebug, disp([' Debug -- ''data'' size after slice: ',mat2str(size(data))]); end |
403 |
if DiagDebug, disp([' Debug -- ''xax'' size: ',mat2str(size(xax))]); end |
if DiagDebug, disp([' Debug -- ''xax'' size: ',mat2str(size(xax))]); end |
404 |
if DiagDebug, disp([' Debug -- ''yax'' size: ',mat2str(size(yax))]); end |
if DiagDebug, disp([' Debug -- ''yax'' size: ',mat2str(size(yax))]); end |
405 |
if DiagDebug, disp([' Debug -- ''pltslc'': ',pltslc]); end |
if DiagDebug, disp([' Debug -- ''pltslc'': ',pltslc]); end |
406 |
|
end |
407 |
end |
end |
408 |
|
|
|
|
|
409 |
%-------------------------------------------------------------------------% |
%-------------------------------------------------------------------------% |
410 |
% Local functions % |
% Local functions % |
411 |
%-------------------------------------------------------------------------% |
%-------------------------------------------------------------------------% |
413 |
% Thus is merely a local function that calls the load data functions |
% Thus is merely a local function that calls the load data functions |
414 |
% according to the DataFormat for the data specified by dfm. |
% according to the DataFormat for the data specified by dfm. |
415 |
function data = DiagLoad_Local(fln,dat,dad,grd,itr,dfm,filesuffix,mnchandle) |
function data = DiagLoad_Local(fln,dat,dad,grd,itr,dfm,filesuffix,mnchandle) |
|
|
|
416 |
if isequal(dfm,'MDS') |
if isequal(dfm,'MDS') |
417 |
data = rdmds([dad,'/',fln,filesuffix],itr); |
data = rdmds([dad,'/',fln,filesuffix],itr); |
418 |
elseif isequal(dfm,'MNC') |
elseif isequal(dfm,'MNC') |
419 |
iter = rdmnc_mod([dad,mnchandle],'T'); |
data = rdmnc_mod2([dad,mnchandle],[fln,filesuffix],'iter','T',itr); |
420 |
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 |
|
421 |
eval(['data = data.',fln,filesuffix,';']); |
eval(['data = data.',fln,filesuffix,';']); |
422 |
else |
else |
423 |
error(['Unrecognized data type: ',dfm]); |
error(['Unrecognized data type: ',dfm]); |