| 1 |
function [data,xax,yax,time,pltslc] = ... |
function [data,xax,yax,time,pltslc] = ... |
| 2 |
DiagLoad(fln,exp,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,... |
| 4 |
Grads,Year0Iter,Months); |
Grads,Year0Iter,Months); |
| 5 |
|
|
| 16 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 17 |
|
|
| 18 |
% Currently the function can handle time averages (dat=='Tav'), which must |
% Currently the function can handle time averages (dat=='Tav'), which must |
| 19 |
% be monthly mean, and instantaneous data (dat=='Int'). There is also an |
% 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 |
% option for generic data (dat=='Non') which, if the field name is exactly |
| 21 |
% specified, is able to load any type file. |
% specified, is able to load any type file. |
| 22 |
if isequal(dat,'Tav') |
if isequal(dat,'Tav') |
| 93 |
data = squeeze(data(:,:,1,:)); |
data = squeeze(data(:,:,1,:)); |
| 94 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 95 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 96 |
DiagSlice(data,fln,exp,dat,dad,grd,itr,tst,flu,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
| 97 |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
| 98 |
|
|
| 99 |
% 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 |
| 126 |
end |
end |
| 127 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 128 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 129 |
DiagSlice(data,fln,exp,dat,dad,grd,itr,tst,flu,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
| 130 |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
| 131 |
|
|
| 132 |
% 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 |
| 141 |
end |
end |
| 142 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 143 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 144 |
DiagSlice(data,fln,exp,dat,dad,grd,itr,tst,flu,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... |
| 145 |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
| 146 |
|
|
| 147 |
% Load generic fields where no modifications are needed. |
% Load generic fields where no modifications are needed. |
| 149 |
data = DiagLoad_Local(fln,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
data = DiagLoad_Local(fln,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 150 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 151 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 152 |
DiagSlice(data,fln,exp,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
| 153 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
| 154 |
|
|
| 155 |
% Read vertical velocities, eta. Convert from [P] to [hPa] in atmosphere. |
% Read vertical velocities, eta. Convert from [P] to [hPa] in atmosphere. |
| 158 |
if isequal(flu,'A'), data = data./100; end |
if isequal(flu,'A'), data = data./100; end |
| 159 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 160 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 161 |
DiagSlice(data,fln,exp,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
| 162 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
| 163 |
|
|
| 164 |
% Load horizontal velocities, convert to lat-lon grid. |
% Load horizontal velocities, convert to lat-lon grid. |
| 166 |
if isequal(dat,'Tav') |
if isequal(dat,'Tav') |
| 167 |
U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 168 |
V = DiagLoad_Local('vVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
V = DiagLoad_Local('vVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 169 |
else isequal(dat,'Int') |
else isequal(dat,'Ins') |
| 170 |
U = DiagLoad_Local('U',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
U = DiagLoad_Local('U',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 171 |
V = DiagLoad_Local('V',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
V = DiagLoad_Local('V',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 172 |
end |
end |
| 185 |
data = V; |
data = V; |
| 186 |
end |
end |
| 187 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 188 |
DiagSlice(data,fln,exp,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
| 189 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
| 190 |
|
|
| 191 |
% Meridional overturning. |
% Meridional overturning. |
| 206 |
if isequal(dat,'Tav') |
if isequal(dat,'Tav') |
| 207 |
U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 208 |
V = DiagLoad_Local('vVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
V = DiagLoad_Local('vVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 209 |
else isequal(dat,'Int') |
else isequal(dat,'Ins') |
| 210 |
U = DiagLoad_Local('U',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
U = DiagLoad_Local('U',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 211 |
V = DiagLoad_Local('V',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
V = DiagLoad_Local('V',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 212 |
end |
end |
| 235 |
disp([' Calculated range: ',mat2str(datarange)]); |
disp([' Calculated range: ',mat2str(datarange)]); |
| 236 |
disp([' Given range: ',mat2str(fixedrange)]); |
disp([' Given range: ',mat2str(fixedrange)]); |
| 237 |
end |
end |
| 238 |
|
|
| 239 |
|
|
| 240 |
|
% Actual temperature and moist potential temperature. Actual temperature |
| 241 |
|
% is calculated as T=Theta*(p/po)^(R/cp). Moist potential temperature is |
| 242 |
|
% calculated as Theta_e=Theta*e^(L*q*/cp*T) where q*=(R/Rv)*(es/p) and |
| 243 |
|
% es=Ae^(beta*T). |
| 244 |
|
elseif ismember(fln,{'ActT','ThetaEc'}) |
| 245 |
|
if isequal('flu','O'), |
| 246 |
|
error('Calculation may only be done for atmosphere!'); |
| 247 |
|
end |
| 248 |
|
[XC,XG,YC,YG,Ylat,ZC,ZG,RAC,drC,drF,... |
| 249 |
|
HFacC,HFacW,HFacS,dxG,dyG,dxC,dyC] = ... |
| 250 |
|
DiagLoadGridData(LoadGridData,grd,gdf,flu,GridSuffix,ZcordFile); |
| 251 |
|
if isequal(ddf,'MDS') |
| 252 |
|
theta = DiagLoad_Local('T',dat,dad,grd,itr,ddf,... |
| 253 |
|
filesuffix,mnchandle); |
| 254 |
|
elseif isequal(ddf,'MNC') |
| 255 |
|
theta = DiagLoad_Local('Temp',dat,dad,grd,itr,... |
| 256 |
|
ddf,filesuffix,mnchandle); |
| 257 |
|
end |
| 258 |
|
theta = DiagAverage(theta,fln,avg,months,ddf,Dim); |
| 259 |
|
if ismember(fln,{'ActT','ThetaEc'}) |
| 260 |
|
pres = NaN.*zeros(size(theta)); |
| 261 |
|
for iz=1:length(ZC), pres(:,:,iz)=ZC(iz); end |
| 262 |
|
temp=theta.*(pres./presrefA).^(RdA/cpA); |
| 263 |
|
if isequal(fln,'ActT'), data=temp; end |
| 264 |
|
end |
| 265 |
|
if isequal(fln,'ThetaEc') |
| 266 |
|
es=A_CC.*exp(Beta_CC.*(temp-K2C)); |
| 267 |
|
qstar=(RdA/RvA).*(es./pres); |
| 268 |
|
data=theta.*exp(LHvapA.*qstar./cpA./temp); |
| 269 |
|
end |
| 270 |
|
[data,xax,yax,pltslc] = ... |
| 271 |
|
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,ddf,gdf,... |
| 272 |
|
avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
| 273 |
|
|
| 274 |
|
|
| 275 |
% Read in variabilities. Here we must make some simple calculations. For |
% Read in variabilities. Here we must make some simple calculations. For |
| 276 |
% all the variablilty fields there is are (field)^2 fields from which we |
% all the variablilty fields there is are (field)^2 fields from which we |
| 277 |
% can calculate the desired variabilities: sqrt(field*field-(field)^2). |
% can calculate the desired variabilities: sqrt(field*field-(field)^2). |
| 284 |
data = sqrt(abs(ETA.*ETA-ETA2)); |
data = sqrt(abs(ETA.*ETA-ETA2)); |
| 285 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 286 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 287 |
DiagSlice(data,fln,exp,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
| 288 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
| 289 |
elseif isequal(fln,'Tstd') |
elseif isequal(fln,'Tstd') |
| 290 |
T = DiagLoad_Local('T' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
T = DiagLoad_Local('T' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 292 |
data = sqrt(abs(T.*T-TT)); |
data = sqrt(abs(T.*T-TT)); |
| 293 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 294 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 295 |
DiagSlice(data,fln,exp,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
| 296 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
| 297 |
elseif isequal(fln,'KEpri') |
elseif isequal(fln,'KEpri') |
| 298 |
U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 311 |
VV = DiagAverage(VV,fln,avg,months,ddf,Dim); |
VV = DiagAverage(VV,fln,avg,months,ddf,Dim); |
| 312 |
data = sqrt(abs((U.*U + V.*V) - (UU + VV))); |
data = sqrt(abs((U.*U + V.*V) - (UU + VV))); |
| 313 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 314 |
DiagSlice(data,fln,exp,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
| 315 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
| 316 |
|
|
| 317 |
% 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. |
| 318 |
else |
else |
| 319 |
if DiagDebug, disp([' Debug -- Unknown field, attempting to load.']); end |
disp([' Unknown field, attempting to load.']); |
| 320 |
data = DiagLoad_Local(fln,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
data = DiagLoad_Local(fln,dat,dad,grd,itr,ddf,filesuffix,mnchandle); |
| 321 |
if DiagDebug, disp([' Debug -- ''data'' size after load: ',mat2str(size(data))]); end |
if DiagDebug, disp([' Debug -- ''data'' size after load: ',mat2str(size(data))]); end |
| 322 |
if ~isequal(Index,0) |
if ~isequal(Index,0) |
| 327 |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
data = DiagAverage(data,fln,avg,months,ddf,Dim); |
| 328 |
if DiagDebug, disp([' Debug -- ''data'' size after average: ',mat2str(size(data))]); end |
if DiagDebug, disp([' Debug -- ''data'' size after average: ',mat2str(size(data))]); end |
| 329 |
[data,xax,yax,pltslc] = ... |
[data,xax,yax,pltslc] = ... |
| 330 |
DiagSlice(data,fln,exp,dat,dad,grd,itr,tst,... |
DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... |
| 331 |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); |
| 332 |
if DiagDebug, disp([' Debug -- ''data'' size after slice: ',mat2str(size(data))]); end |
if DiagDebug, disp([' Debug -- ''data'' size after slice: ',mat2str(size(data))]); end |
| 333 |
if DiagDebug, disp([' Debug -- ''xax'' size: ',mat2str(size(xax))]); end |
if DiagDebug, disp([' Debug -- ''xax'' size: ',mat2str(size(xax))]); end |
| 347 |
if isequal(dfm,'MDS') |
if isequal(dfm,'MDS') |
| 348 |
data = rdmds([dad,'/',fln,filesuffix],itr); |
data = rdmds([dad,'/',fln,filesuffix],itr); |
| 349 |
elseif isequal(dfm,'MNC') |
elseif isequal(dfm,'MNC') |
|
%[dad,mnchandle] |
|
| 350 |
iter = rdmnc_mod([dad,mnchandle],'T'); |
iter = rdmnc_mod([dad,mnchandle],'T'); |
| 351 |
iter = iter.T; |
iter = iter.T; |
| 352 |
[dummy,indecies] = ismember(itr,iter); |
[dummy,indecies] = ismember(itr,iter); |