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