1 |
function [data,xax,yax,time,pltslc] = ... |
2 |
DiagLoad(fln,trl,dat,dad,grd,itr,tst,flu,ddf,gdf,avg,slc,pst,... |
3 |
LoadGridData,DiagDebug,GridSuffix,ZcordFile,Index,Dim,Vector,Mate,... |
4 |
Grads,Year0Iter,SecPerYear,Months,FieldName); |
5 |
|
6 |
|
7 |
% Load parameters. |
8 |
DiagGenParam; |
9 |
DiagFieldParamA; |
10 |
DiagFieldParamO; |
11 |
DiagFieldParamI; |
12 |
DiagFieldParamC; |
13 |
|
14 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
15 |
% Prepare for the various data types, set time % |
16 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
17 |
|
18 |
% Currently the function can handle time averages (dat=='Tav'), which must |
19 |
% be monthly mean, and instantaneous data (dat=='Ins'). There is also an |
20 |
% option for generic data (dat=='Non') which, if the field name is exactly |
21 |
% specified, is able to load any type file. |
22 |
if isequal(dat,'Tav') |
23 |
filesuffix = 'tave'; |
24 |
if isequal(flu,'C'), mnchandle = 'cpl_tave.*'; |
25 |
else , mnchandle = 'tave.*' ; end |
26 |
elseif isequal(dat,'Ins') |
27 |
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'}) |
34 |
filesuffix = ''; mnchandle = ''; |
35 |
else |
36 |
error(['DataType not recognized: ',datatype]); |
37 |
end |
38 |
|
39 |
% Time stuff (itr = 0 is start of new 360 day year). |
40 |
if isempty(Months) |
41 |
months = (itr-Year0Iter)./(30.*24.*3600./tst); |
42 |
else |
43 |
months = Months; |
44 |
end |
45 |
time = months/12; |
46 |
|
47 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
48 |
% Read in data % |
49 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
50 |
|
51 |
% Open grads files |
52 |
if ~isequal(Grads,0) |
53 |
if DiagDebug, disp([' Debug -- Loading GRADS field.']); end |
54 |
[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 |
57 |
data = DiagAverage(data,fln,avg,months,ddf,dim); |
58 |
if DiagDebug, disp([' Debug -- ''data'' size after averaging: ',mat2str(size(data))]); end |
59 |
% if isequal(slc,'Sur') |
60 |
% data = data'; |
61 |
% pltslc='lonlat'; |
62 |
% else |
63 |
% error('Loading grads data only set to handle surface plots!'); |
64 |
% end |
65 |
[data,xax,yax,pltslc] = ... |
66 |
DiagSliceGradsData(fln,flu,slc,data,xax,yax,zax); |
67 |
|
68 |
% Load monitor data. |
69 |
elseif isequal(dat(1:2),'Mn') |
70 |
[data,time] = ... |
71 |
DiagLoadMonitor(fln,mnchandle,dad,itr,tst,SecPerYear,DiagDebug); |
72 |
xax = time; yax = NaN; pltslc = 'timfld'; |
73 |
|
74 |
% Load AIM physics data. The data is all stuffed into one file called |
75 |
% 'aimPhy' which currently only comes in MDS format. When loading a field, |
76 |
% call the variable name that is used in the actual MITgcm code. These |
77 |
% variables are given in 'DiagGenParam'. Here, we check that to see if the |
78 |
% parameter is an AIM parameter, then load the 'aimPhy' file and extract |
79 |
% the data with the proper index as specified in 'DiagGenParam'. For total |
80 |
% precipitation ('TotP') and evaporation minus precipitation ('EmP') some |
81 |
% simple calculations of the AIM fields are performed and the U and V |
82 |
% stresses (on atmosphere) must converted to a lat-lon grid. |
83 |
elseif ismember(fln,aimparameters) |
84 |
if isequal(ddf,'MNC') |
85 |
error('Aim physics reader not set to handle ''MNC'' data format.') |
86 |
end |
87 |
data = DiagLoad_Local('aimPhy',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
88 |
if isequal(fln,'TotP') |
89 |
data = data(:,:,PRECNV,:) ... |
90 |
+ data(:,:,PRECLS,:); |
91 |
elseif isequal(fln,'EmP') |
92 |
data = data(:,:,EVAP ,:) ... |
93 |
- data(:,:,PRECNV,:) ... |
94 |
- data(:,:,PRECLS,:); |
95 |
elseif ismember(fln,{'USTR','VSTR'}) |
96 |
[XC,XG,YC,YG,Ylat,ZC,ZG,RAC,drC,drF,HFacC,HFacW,HFacS,dxG,dyG,dxC,dyC] = ... |
97 |
DiagLoadGridData(LoadGridData,grd,gdf,flu,GridSuffix,ZcordFile); |
98 |
eval(['USTRdata = data(:,:,',num2str(USTR),',:);']); |
99 |
eval(['VSTRdata = data(:,:,',num2str(VSTR),',:);']); |
100 |
[USTRdata,VSTRdata]=uvcube2latlon(XC,YC,USTRdata,VSTRdata,XL,YL); |
101 |
if isequal(fln,'USTR'), data = USTRdata; |
102 |
elseif isequal(fln,'VSTR'), data = VSTRdata; end |
103 |
else |
104 |
eval(['data = data(:,:,',fln,',:);']); |
105 |
end |
106 |
data = squeeze(data(:,:,1,:)); |
107 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
108 |
[data,xax,yax,pltslc] = ... |
109 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
110 |
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 |
113 |
% called either 'cplFldtave.*' (MDS) or 'cpl_tave.*' (MNC). Variables within |
114 |
% the MDS files given in 'DiagGenParam', accessed directly with MNC. TX |
115 |
% and TY (stress on ocean) must be converted to lat-lon grid. |
116 |
elseif ismember(fln,cplparameters) |
117 |
if ismember(fln,{'TX','TY'}) |
118 |
[XC,XG,YC,YG,Ylat,ZC,ZG,RAC,drC,drF,HFacC,HFacW,HFacS,dxG,dyG,dxC,dyC] = ... |
119 |
DiagLoadGridData(LoadGridData,grd,gdf,flu,GridSuffix,ZcordFile); |
120 |
if isequal(ddf,'MNC') |
121 |
TXdata = DiagLoad_Local('TX',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
122 |
TYdata = DiagLoad_Local('TY',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
123 |
elseif isequal(ddf,'MDS') |
124 |
data = DiagLoad_Local('cplFld',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
125 |
eval(['TXdata = squeeze(data(:,:,',num2str(TX),',:));']); |
126 |
eval(['TYdata = squeeze(data(:,:,',num2str(TY),',:));']); |
127 |
end |
128 |
[TXdata,TYdata]=uvcube2latlon(XC,YC,TXdata,TYdata,XL,YL); |
129 |
if isequal(fln,'TX'), data = TXdata; |
130 |
elseif isequal(fln,'TY'), data = TYdata; end |
131 |
else |
132 |
if isequal(ddf,'MNC') |
133 |
data = DiagLoad_Local(fln,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
134 |
elseif isequal(ddf,'MDS') |
135 |
data = DiagLoad_Local('cplFld',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
136 |
eval(['data = squeeze(data(:,:,',fln,',:));']); |
137 |
end |
138 |
if isequal(fln,'SLP'), data = data ./ 100; end |
139 |
end |
140 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
141 |
[data,xax,yax,pltslc] = ... |
142 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
143 |
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 |
146 |
% constant flux, this part quickly becomes out of date. |
147 |
elseif ismember(fln,iceparameters) |
148 |
if isequal(dat,'Ins') |
149 |
data = DiagLoad_Local([fln,'-T'],dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
150 |
else |
151 |
data = DiagLoad_Local('thSIce_',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
152 |
eval(['data = data(:,:,',fln,',:);']); |
153 |
data = squeeze(data(:,:,1,:)); |
154 |
end |
155 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
156 |
[data,xax,yax,pltslc] = ... |
157 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
158 |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
159 |
|
160 |
% Load generic fields where no modifications are needed. |
161 |
elseif ismember(fln,{'S','T','Temp','aim_RH','phiHyd','Conv'}) |
162 |
data = DiagLoad_Local(fln,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
163 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
164 |
[data,xax,yax,pltslc] = ... |
165 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
166 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
167 |
|
168 |
% Read vertical velocities, eta. Convert from [P] to [hPa] in atmosphere. |
169 |
elseif ismember(fln,{'W','wVel','Eta','ETA'}) |
170 |
data = DiagLoad_Local(fln,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
171 |
if isequal(flu,'A'), data = data./100; end |
172 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
173 |
[data,xax,yax,pltslc] = ... |
174 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
175 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
176 |
|
177 |
% Load horizontal velocities, convert to lat-lon grid. |
178 |
elseif ismember(fln,{'U','V','uVel','vVel','fizhi_U','fizhi_V'}) |
179 |
if isequal(dat,'Tav') |
180 |
U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
181 |
V = DiagLoad_Local('vVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
182 |
else isequal(dat,'Ins') |
183 |
U = DiagLoad_Local([fln(1:end-1),'U'],dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
184 |
V = DiagLoad_Local([fln(1:end-1),'V'],dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
185 |
end |
186 |
if isequal(ddf,'MNC') |
187 |
U = U(1:end-1,:,:,:); |
188 |
V = V(:,1:end-1,:,:); |
189 |
end |
190 |
U = DiagAverage(U,fln,avg,months,ddf,Dim); |
191 |
V = DiagAverage(V,fln,avg,months,ddf,Dim); |
192 |
[XC,XG,YC,YG,Ylat,ZC,ZG,RAC,drC,drF,HFacC,HFacW,HFacS,dxG,dyG,dxC,dyC] = ... |
193 |
DiagLoadGridData(LoadGridData,grd,gdf,flu,GridSuffix,ZcordFile); |
194 |
[U,V]=uvcube2latlon(XC,YC,U,V,XL,YL); |
195 |
if ismember(fln,{'U','uVel','fizhi_U'}) |
196 |
data = U; |
197 |
elseif ismember(fln,{'V','vVel','fizhi_V'}) |
198 |
data = V; |
199 |
end |
200 |
[data,xax,yax,pltslc] = ... |
201 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
202 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
203 |
|
204 |
% Meridional overturning. |
205 |
elseif ismember(fln,{'Bol','Psi','Res'}) |
206 |
[XC,XG,YC,YG,Ylat,ZC,ZG,RAC,drC,drF,HFacC,HFacW,HFacS,dxG,dyG,dxC,dyC] = ... |
207 |
DiagLoadGridData(LoadGridData,grd,gdf,flu,GridSuffix,ZcordFile); |
208 |
if isequal(flu,'A'), delM = - 1000*drF ./ g; |
209 |
elseif isequal(flu,'O'), delM = drF; end |
210 |
if ismember(fln,{'Bol','Res'}) |
211 |
kwx = DiagLoad_Local('GM_Kwx-T',dat,dad,grd,itr,'MDS','',mnchandle); |
212 |
kwy = DiagLoad_Local('GM_Kwy-T',dat,dad,grd,itr,'MDS','',mnchandle); |
213 |
kwx = DiagAverage(kwx,fln,avg,months,ddf,Dim); |
214 |
kwy = DiagAverage(kwy,fln,avg,months,ddf,Dim); |
215 |
[ub,vb]=calc_Bolus_CS(RAC,dxC,dyC,dxG,dyG,drC ,kwx,kwy,HFacW,HFacS); |
216 |
[psibol,mskG,ylat]=calc_PsiCube(delM,ub.*HFacW,vb.*HFacS,dxG,dyG); |
217 |
end |
218 |
if ismember(fln,{'Psi','Res'}) |
219 |
if isequal(dat,'Tav') |
220 |
U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
221 |
V = DiagLoad_Local('vVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
222 |
else isequal(dat,'Ins') |
223 |
U = DiagLoad_Local('U',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
224 |
V = DiagLoad_Local('V',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
225 |
end |
226 |
if isequal(ddf,'MNC') |
227 |
U = U(1:end-1,:,:,:); |
228 |
V = V(:,1:end-1,:,:); |
229 |
end |
230 |
U = DiagAverage(U,fln,avg,months,ddf,Dim); |
231 |
V = DiagAverage(V,fln,avg,months,ddf,Dim); |
232 |
[psiavg,mskG,ylat]=calc_PsiCube(delM,U.*HFacW,V.*HFacS,dxG,dyG); |
233 |
end |
234 |
if isequal(fln,'Psi') |
235 |
data = psiavg(2:end-1,:)'; |
236 |
elseif isequal(fln,'Bol') |
237 |
data = psibol(2:end-1,:)'; |
238 |
elseif isequal(fln,'Res') |
239 |
data = psibol(2:end-1,:)' + psiavg(2:end-1,:)'; |
240 |
end |
241 |
if isequal(flu,'A'), data = data./1e6; end |
242 |
xax = ylat; yax = ZG; pltslc = 'lathgt'; |
243 |
eval(['fixedrange = ',fln,'range',flu,';']); |
244 |
datarange = [min(data(:)),max(data(:))]; |
245 |
if datarange(1) < fixedrange(1) | ... |
246 |
datarange(2) > fixedrange(2) |
247 |
disp(['***Warning*** Value out of range for ',fln]); |
248 |
disp([' Calculated range: ',mat2str(datarange)]); |
249 |
disp([' Given range: ',mat2str(fixedrange)]); |
250 |
end |
251 |
|
252 |
|
253 |
% Actual temperature and moist potential temperature. Actual temperature |
254 |
% is calculated as T=Theta*(p/po)^(R/cp). Moist potential temperature is |
255 |
% calculated as Theta_e=Theta*e^(L*q*/cp*T) where q*=(R/Rv)*(es/p) and |
256 |
% es=Ae^(beta*T). |
257 |
elseif ismember(fln,{'ActT','ThetaEc'}) |
258 |
if isequal('flu','O'), |
259 |
error('Calculation may only be done for atmosphere!'); |
260 |
end |
261 |
[XC,XG,YC,YG,Ylat,ZC,ZG,RAC,drC,drF,... |
262 |
HFacC,HFacW,HFacS,dxG,dyG,dxC,dyC] = ... |
263 |
DiagLoadGridData(LoadGridData,grd,gdf,flu,GridSuffix,ZcordFile); |
264 |
if isequal(ddf,'MDS') |
265 |
theta = DiagLoad_Local('T',dat,dad,grd,itr,ddf,... |
266 |
filesuffix,mnchandle); |
267 |
elseif isequal(ddf,'MNC') |
268 |
theta = DiagLoad_Local('Temp',dat,dad,grd,itr,... |
269 |
ddf,filesuffix,mnchandle); |
270 |
end |
271 |
theta = DiagAverage(theta,fln,avg,months,ddf,Dim); |
272 |
if ismember(fln,{'ActT','ThetaEc'}) |
273 |
pres = NaN.*zeros(size(theta)); |
274 |
for iz=1:length(ZC), pres(:,:,iz)=ZC(iz); end |
275 |
temp=theta.*(pres./presrefA).^(RdA/cpA); |
276 |
if isequal(fln,'ActT'), data=temp; end |
277 |
end |
278 |
if isequal(fln,'ThetaEc') |
279 |
es=A_CC.*exp(Beta_CC.*(temp-K2C)); |
280 |
qstar=(RdA/RvA).*(es./pres); |
281 |
data=theta.*exp(LHvapA.*qstar./cpA./temp); |
282 |
end |
283 |
[data,xax,yax,pltslc] = ... |
284 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,ddf,gdf,... |
285 |
avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
286 |
|
287 |
|
288 |
% Read in variabilities. Here we must make some simple calculations. For |
289 |
% all the variablilty fields there is are (field)^2 fields from which we |
290 |
% can calculate the desired variabilities: sqrt(field*field-(field)^2). |
291 |
% Note that 'ETAstd' is scaled from [P] to [hPa]. For 'KEpri', we should |
292 |
% use the values on either side of a grid, since it will be plotted from |
293 |
% the grid center, but here we just use from one edge out of convenience. |
294 |
elseif isequal(fln,'ETAstd') |
295 |
ETA = DiagLoad_Local('ETA' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle)./100 ; |
296 |
ETA2 = DiagLoad_Local('Eta2',dat,dad,grd,itr,ddf,filesuffix,mnchandle)./10000; |
297 |
data = sqrt(abs(ETA.*ETA-ETA2)); |
298 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
299 |
[data,xax,yax,pltslc] = ... |
300 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
301 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
302 |
elseif isequal(fln,'Tstd') |
303 |
T = DiagLoad_Local('T' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
304 |
TT = DiagLoad_Local('TT',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
305 |
data = sqrt(abs(T.*T-TT)); |
306 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
307 |
[data,xax,yax,pltslc] = ... |
308 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
309 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
310 |
elseif isequal(fln,'KEpri') |
311 |
U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
312 |
V = DiagLoad_Local('vVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
313 |
UU = DiagLoad_Local('UU' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
314 |
VV = DiagLoad_Local('VV' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
315 |
if isequal(ddf,'MNC') |
316 |
U = U(1:end-1,:,:,:); UU = UU(1:end-1,:,:,:); |
317 |
V = V(:,1:end-1,:,:); VV = VV(:,1:end-1,:,:); |
318 |
end |
319 |
U = DiagAverage(U ,fln,avg,months,ddf,Dim); |
320 |
V = DiagAverage(V ,fln,avg,months,ddf,Dim); |
321 |
UU = DiagAverage(UU,fln,avg,months,ddf,Dim); |
322 |
VV = DiagAverage(VV,fln,avg,months,ddf,Dim); |
323 |
data = sqrt(abs((U.*U + V.*V) - (UU + VV))); |
324 |
[data,xax,yax,pltslc] = ... |
325 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
326 |
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. |
329 |
else |
330 |
disp([' Unknown field, attempting to load.']); |
331 |
data = DiagLoad_Local(fln,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
332 |
if DiagDebug, disp([' Debug -- ''data'' size after load: ',mat2str(size(data))]); end |
333 |
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,:)); |
377 |
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 |
400 |
if ~isequal(Vector,3) |
401 |
[data,xax,yax,pltslc] = ... |
402 |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
403 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); |
404 |
if DiagDebug, disp([' Debug -- ''data'' size after slice: ',mat2str(size(data))]); end |
405 |
if DiagDebug, disp([' Debug -- ''xax'' size: ',mat2str(size(xax))]); end |
406 |
if DiagDebug, disp([' Debug -- ''yax'' size: ',mat2str(size(yax))]); end |
407 |
if DiagDebug, disp([' Debug -- ''pltslc'': ',pltslc]); end |
408 |
end |
409 |
end |
410 |
|
411 |
%-------------------------------------------------------------------------% |
412 |
% Local functions % |
413 |
%-------------------------------------------------------------------------% |
414 |
|
415 |
% Thus is merely a local function that calls the load data functions |
416 |
% according to the DataFormat for the data specified by dfm. |
417 |
function data = DiagLoad_Local(fln,dat,dad,grd,itr,dfm,filesuffix,mnchandle) |
418 |
if isequal(dfm,'MDS') |
419 |
data = rdmds([dad,'/',fln,filesuffix],itr); |
420 |
elseif isequal(dfm,'MNC') |
421 |
data = rdmnc_mod2([dad,mnchandle],[fln,filesuffix],'iter','T',itr); |
422 |
if ~isequal(itr,data.iter'), error('Missing iterations in data!'); end |
423 |
eval(['data = data.',fln,filesuffix,';']); |
424 |
else |
425 |
error(['Unrecognized data type: ',dfm]); |
426 |
end |