--- MITgcm_contrib/enderton/Diagnostics/DiagLoad.m 2005/06/28 21:33:51 1.8 +++ MITgcm_contrib/enderton/Diagnostics/DiagLoad.m 2005/09/05 18:48:27 1.13 @@ -53,15 +53,15 @@ if DiagDebug, disp([' Debug -- Loading GRADS field.']); end [data,xax,yax,zax,months,time,dim] = ... DiagLoadGradsData(Grads,dad,fln,DiagDebug); - if DiagDebug, disp([' Debug -- ''data'' size after load: ',mat2str(size(data))]); end + if DiagDebug, disp([' Debug -- ''data'' size after load: ',... + mat2str(size(data))]); end data = DiagAverage(data,fln,avg,months,ddf,dim); - if DiagDebug, disp([' Debug -- ''data'' size after averaging: ',mat2str(size(data))]); end - if isequal(slc,'Sur') - data = data'; - pltslc='lonlat'; - else - error('Loading grads data only set to handle surface plots!'); - end + if DiagDebug, disp([' Debug -- ''data'' size after averaging: ',... + mat2str(size(data))]); end + [data,xax,yax,pltslc] = ... + DiagSliceGradsData(fln,flu,slc,data,xax,yax,zax); + if DiagDebug, disp([' Debug -- ''data'' size after slicing: ',... + mat2str(size(data))]); end % Load monitor data. elseif isequal(dat(1:2),'Mn') @@ -105,10 +105,10 @@ data = DiagAverage(data,fln,avg,months,ddf,Dim); [data,xax,yax,pltslc] = ... DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... - ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); + ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); % Load coupled fields. Like AIM, the data is all stuffed into one file -% called either 'cplFld.*' (MDS) or 'cpl_tave.*' (MNC). Variables within +% called either 'cplFldtave.*' (MDS) or 'cpl_tave.*' (MNC). Variables within % the MDS files given in 'DiagGenParam', accessed directly with MNC. TX % and TY (stress on ocean) must be converted to lat-lon grid. elseif ismember(fln,cplparameters) @@ -138,7 +138,7 @@ data = DiagAverage(data,fln,avg,months,ddf,Dim); [data,xax,yax,pltslc] = ... DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... - ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); + ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); % Load ice parameters. Note that as the ice variable names appear to be in % constant flux, this part quickly becomes out of date. @@ -153,7 +153,7 @@ data = DiagAverage(data,fln,avg,months,ddf,Dim); [data,xax,yax,pltslc] = ... DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,... - ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); + ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); % Load generic fields where no modifications are needed. elseif ismember(fln,{'S','T','Temp','aim_RH','phiHyd','Conv'}) @@ -161,7 +161,7 @@ data = DiagAverage(data,fln,avg,months,ddf,Dim); [data,xax,yax,pltslc] = ... DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... - flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); + flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); % Read vertical velocities, eta. Convert from [P] to [hPa] in atmosphere. elseif ismember(fln,{'W','wVel','Eta','ETA'}) @@ -170,7 +170,7 @@ data = DiagAverage(data,fln,avg,months,ddf,Dim); [data,xax,yax,pltslc] = ... DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... - flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); + flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); % Load horizontal velocities, convert to lat-lon grid. elseif ismember(fln,{'U','V','uVel','vVel','fizhi_U','fizhi_V'}) @@ -197,7 +197,7 @@ end [data,xax,yax,pltslc] = ... DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... - flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); + flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); % Meridional overturning. elseif ismember(fln,{'Bol','Psi','Res'}) @@ -280,7 +280,7 @@ end [data,xax,yax,pltslc] = ... DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,ddf,gdf,... - avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); + avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); % Read in variabilities. Here we must make some simple calculations. For @@ -296,7 +296,7 @@ data = DiagAverage(data,fln,avg,months,ddf,Dim); [data,xax,yax,pltslc] = ... DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... - flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); + flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); elseif isequal(fln,'Tstd') T = DiagLoad_Local('T' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); TT = DiagLoad_Local('TT',dat,dad,grd,itr,ddf,filesuffix,mnchandle); @@ -304,26 +304,24 @@ data = DiagAverage(data,fln,avg,months,ddf,Dim); [data,xax,yax,pltslc] = ... DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... - flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); + flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); elseif isequal(fln,'KEpri') U = DiagLoad_Local('uVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); V = DiagLoad_Local('vVel',dat,dad,grd,itr,ddf,filesuffix,mnchandle); UU = DiagLoad_Local('UU' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); VV = DiagLoad_Local('VV' ,dat,dad,grd,itr,ddf,filesuffix,mnchandle); if isequal(ddf,'MNC') - U = .5*( U(2:end,:,:,:) + U(1:end-1,:,:,:) ); - V = .5*( V(:,2:end,:,:) + V(:,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,:,:) ); + U = U(1:end-1,:,:,:); UU = UU(1:end-1,:,:,:); + V = V(:,1:end-1,:,:); VV = VV(:,1:end-1,:,:); end - U = DiagAverage(U,fln,avg,months,ddf,Dim); - V = DiagAverage(V,fln,avg,months,ddf,Dim); + U = DiagAverage(U ,fln,avg,months,ddf,Dim); + V = DiagAverage(V ,fln,avg,months,ddf,Dim); UU = DiagAverage(UU,fln,avg,months,ddf,Dim); VV = DiagAverage(VV,fln,avg,months,ddf,Dim); data = sqrt(abs((U.*U + V.*V) - (UU + VV))); [data,xax,yax,pltslc] = ... DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... - flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); + flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); % If the field is not recognized, try best to try and open it. else @@ -372,9 +370,15 @@ if DiagDebug, disp([' Debug -- ''data'' size after vector manipulation: ',mat2str(size(data))]); end else % Sequence here for Vector = 0 - if ~isequal(Index,0) + if ~isequal(Index,0) & isequal(size(Index),[1 1]) & isequal(sign(Index),1) if isequal(Dim,2), data = squeeze(data(:,:,Index,:)); elseif isequal(Dim,3), data = squeeze(data(:,:,:,Index,:)); end + elseif isequal(size(Index),[1 1]) & ~isequal(sign(Index),1) + if isequal(Dim,2), data = sign(Index(1)).*squeeze(data(:,:,abs(Index(1)),:)); + elseif isequal(Dim,3), data = sign(Index(1)).*squeeze(data(:,:,:,abs(Index(1)),:)); end + elseif isequal(size(Index),[1 2]) + if isequal(Dim,2), data = sign(Index(1)).*squeeze(data(:,:,abs(Index(1)),:)) + sign(Index(2)).*squeeze(data(:,:,abs(Index(2)),:)); + elseif isequal(Dim,3), data = sign(Index(1)).*squeeze(data(:,:,:,abs(Index(1)),:)) + sign(Index(2)).*squeeze(data(:,:,:,abs(Index(2)),:)); end end if DiagDebug, disp([' Debug -- ''data'' size after indexing: ',mat2str(size(data))]); end data = DiagAverage(data,fln,avg,months,ddf,Dim); @@ -394,7 +398,7 @@ if ~isequal(Vector,3) [data,xax,yax,pltslc] = ... DiagSlice(data,fln,trl,dat,dad,grd,itr,tst,... - flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile); + flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile,Vector,FieldName); if DiagDebug, disp([' Debug -- ''data'' size after slice: ',mat2str(size(data))]); end if DiagDebug, disp([' Debug -- ''xax'' size: ',mat2str(size(xax))]); end if DiagDebug, disp([' Debug -- ''yax'' size: ',mat2str(size(yax))]); end @@ -409,16 +413,11 @@ % Thus is merely a local function that calls the load data functions % according to the DataFormat for the data specified by dfm. function data = DiagLoad_Local(fln,dat,dad,grd,itr,dfm,filesuffix,mnchandle) - if isequal(dfm,'MDS') data = rdmds([dad,'/',fln,filesuffix],itr); elseif isequal(dfm,'MNC') - iter = rdmnc_mod([dad,mnchandle],'T'); - iter = iter.T; - [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 + data = rdmnc_mod2([dad,mnchandle],[fln,filesuffix],'iter','T',itr); + %if ~isequal(itr,data.iter'), error('Missing iterations in data!'); end eval(['data = data.',fln,filesuffix,';']); else error(['Unrecognized data type: ',dfm]);