Back to home page

MITgcm

 
 

    


Warning, /utils/matlab/Graphix/GraphixSlice.m is written in an unsupported language. File is not indexed.

view on githubraw file Latest commit 4cf7d6e4 on 2006-06-29 18:52:07 UTC
5bbd0d07c9 Dani*0001 function [data,xax,yax,pltslc] = ...
e5f86a2f55 Dani*0002     GraphixSlice(data,fln,trl,dat,dad,grd,itr,tst,flu,ddf,gdf,avg,slc,...
                0003                  pst,Dim,LoadGridData,GridSuffix,ZcordFile,Vector,...
                0004                  FieldName,XL,YL);
5bbd0d07c9 Dani*0005 
                0006 % Function: GraphixSlice
                0007 % Author:   Daniel Enderton
                0008 %
                0009 % Input Fields:
                0010 %
                0011 %   Field        Type        (Brief) Description
                0012 %   -----------------------------------------------------------------------
                0013 %   data         array       Field name
                0014 %   fln          string      Field name
                0015 %   dad          string      Data directory.
                0016 %   grd          string      Grid data directory.
                0017 %   avg          string      Averaging scheme ('Ann','DJF', 'JJA',...)
                0018 %   slc          string      Slice type ('Zon','k=#',...)
                0019 %   pst          string      Plot style ('Con','Sur',...)
                0020 %   flu          string      Fluid ('A','O')
                0021 %   dfm          string      Data format ('MDS' or 'MNC')
                0022 %   LoadGridData 0/1         Optionally load grid data
                0023 %
                0024 % Output Fields:
                0025 %
                0026 %   Field       Type        (Brief) Description
                0027 %   -----------------------------------------------------------------------
                0028 %   data        array       Sliced data.
                0029 %
                0030 % Descripton:
                0031 %   This function slices the data according to SliceType 'slc'.  Depending
                0032 %   on the SliceType and PlotStyle, the data may be converted to a lat-lon
                0033 %   grid.  At the end there is also a range check.  If the value is out of
                0034 %   the user specified range given in 'DaigFieldParamA'.
                0035 
                0036 % Load diagnostics parameters, grid data, mark data size
                0037 GraphixGenParam;
                0038 GraphixFieldParamA;
                0039 GraphixFieldParamO;
                0040 GraphixFieldParamC;
                0041 GraphixFieldParamI;
e5f86a2f55 Dani*0042 [nc,dim,XC,XG,YC,YG,ZC,ZF,RAC,drC,drF,HFacC,...
5bbd0d07c9 Dani*0043  HFacW,HFacS,dxG,dyG,dxC,dyC,AngleCS,AngleSN] = ...
                0044     GraphixLoadGridData(LoadGridData,grd,gdf,flu,GridSuffix,ZcordFile);
                0045 datasize = size(data);
                0046 
                0047 
                0048 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                0049 %                               Surface plot                              %
                0050 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                0051 
                0052 % All surface plots are direct cube sphere outputs, and therefore must have
                0053 % the dimensions of the cube grid data.  If the 'pst' is 'Grd' or 'Int',
                0054 % everything is already all set since those handle the cubed sphere data.
                0055 % If the 'pst' is 'Con' or 'Cnf', convert data to a lat-lon grid so that it
                0056 % can easily be contoured.
                0057 if isequal(slc,'Sur')
                0058     if ismember(fln,{'TX','TY','USTR','VSTR'}) | ~isequal(Vector,0)
                0059         data = data'; xax = XL; yax = YL;
                0060     elseif ~isequal(datasize,size(XC)) 
                0061         error('Incorrect dimensions for slc:  ',slc);
                0062     else
                0063         if ismember(pst,{'Grd','Int'})
                0064             if     isequal(pst,'Grd'),
                0065                 xax = XG;
                0066                 yax = YG;
                0067             elseif isequal(pst,'Int'),
                0068                 xax = XC;
                0069                 yax = YC;
                0070             end
                0071         elseif ismember(pst,{'Con','Cnf'})
                0072             data = cube2latlon(XC,YC,data,XL,YL)';
                0073             xax = XL; yax = YL;
                0074         else
                0075             error(['slc = ''Sur'' can not use pst:  ',pst]);
                0076         end
                0077     end
                0078     pltslc='lonlat';
                0079     
                0080     
                0081 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                0082 %                            Zonal average plot                           %
                0083 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                0084 
                0085 % When computing a zonal average, there are many different options for the
                0086 % initial data.  If the data is cube-sphere, it could be the shape of XC,
                0087 % possibly also with a vertical axis.  In either case, 'calc_ZonAv_CS' (a
                0088 % nifty zonally averaging script from JMC) is called to compute the zonal
                0089 % average for raw cube sphere data.  For horizontal velocities, the data
                0090 % could be of the size [length(XL),length(YL),z-axis length], in which case
                0091 % you just need to take the mean over the longitude axis (always 1).
                0092 elseif isequal(slc,'Zon')
                0093     if isequal(datasize(1:2),size(XC))
                0094         if isequal(flu,'O'),                nBas = 0; end
                0095         if ismember(flu,{'A','I','C','L'}), nBas = 0; end
4cf7d6e47a Dani*0096         if Dim == 2 & length(size(data)) == 3
                0097             data = reshape(data,[size(data,1),size(data,2),1,size(data,3)]);
                0098         end
e5f86a2f55 Dani*0099         [data,maskzon,Ylat,areazon] = ...
                0100             calcZonalAvgCube(data,ny,YC,RAC,HFacC);
5bbd0d07c9 Dani*0101         if isequal(avg,'Tse')
4cf7d6e47a Dani*0102             data=data(:,:,1); xax=itr.*tst./31104000;
                0103             yax=Ylat;         pltslc='timlat';
5bbd0d07c9 Dani*0104         elseif isequal(avg,'Tyr')
4cf7d6e47a Dani*0105             data=data(:,:,1);  xax=[0:12];   yax=Ylat; pltslc='timlat';
5bbd0d07c9 Dani*0106         elseif isequal(pst,'Lin')
4cf7d6e47a Dani*0107             data=data(:,:,1)'; xax=Ylat;     yax=NaN;  pltslc='latfld';
5bbd0d07c9 Dani*0108         else
4cf7d6e47a Dani*0109             data=data(:,:,1)'; xax=Ylat;     yax=ZC;   pltslc='lathgt';
5bbd0d07c9 Dani*0110         end
                0111     elseif isequal(datasize(1:2),[length(XL),length(YL)])
                0112         if ~isequal(pst,'Lin')
                0113             data = squeeze(mean(data,1))'; xax=YL; yax=ZC;  pltslc='lathgt';
                0114         else
                0115             data = squeeze(mean(data,1))'; xax=YL; yax=NaN; pltslc='latfld';
                0116         end
                0117     else
                0118         error('Incorrect dimensions for slc = ''Zon''');
                0119     end
4cf7d6e47a Dani*0120     
5bbd0d07c9 Dani*0121     
                0122 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                0123 %                                   i,j,k=#                               %
                0124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                0125 
                0126 % These slicing settings just take a slice on one of the axes.  If the
                0127 % slice option is 'i=' or 'j=' and the data is cube-sphere, it is converted
                0128 % to lat-lon first and indexed then (thus the index number should be based
                0129 % off of the XL and YL interpolated grids defined in 'GraphixGenParam'.  It
                0130 % would be nice to add functions that can slice by longitude, latitude, and
                0131 % height values directly.  Note that there is transposing of all the data
                0132 % to prepare it for contour plots (harmless is line plots).
                0133 elseif isequal(slc(1:2),'i=')
                0134     ii = str2num(slc(3:end));
                0135     data = cube2latlon(XC,YC,data,XL,YL);
                0136     if ismember(fln,fields2D)
                0137         data=squeeze(data(ii,:));
                0138         xax=YL; yax=NaN; pltslc='latfld';
                0139     elseif ismember(fln,fields3D)
                0140         data=squeeze(data(ii,:,:))';
                0141         xax=YL; yax=ZC;  pltslc='lathgt';
                0142     end
                0143     
                0144 elseif isequal(slc(1:2),'j=')
                0145     jj = str2num(slc(3:end));
                0146     data = cube2latlon(XC,YC,data,XL,YL);
                0147     if ismember(fln,fields2D)
                0148         data = squeeze(data(:,jj));
                0149         xax=XL; yax=NaN; pltslc='lonfld';
                0150     elseif ismember(fln,fields3D)
                0151         data = squeeze(data(:,jj,:))';
                0152         xax=XL; yax=ZC;  pltslc='lonhgt';
                0153     end
                0154     
                0155 elseif isequal(slc(1:2),'k=')
                0156     kk = str2num(slc(3:end));
                0157     data = squeeze(data(:,:,kk));
                0158     if isequal(pst,'Grd'),
                0159         xax = XG;
                0160         yax = YG;
                0161     elseif isequal(pst,'Int'),
                0162         xax = XC;
                0163         yax = YC;
                0164     elseif ismember(pst,{'Con','Cnf'})
                0165         data = cube2latlon(XC,YC,data,XL,YL)';
                0166         xax = XL; yax = YL;
                0167     end
                0168     pltslc='lonlat';
                0169     
                0170 else
                0171     error(['Unrecognized SliceType:  ',slc]);
                0172 end