Back to home page

MITgcm

 
 

    


Warning, /utils/matlab/Graphix/GraphixPlot.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 ifig = GraphixPlot(plotparam,plotparamvalue,pagename,page,data,...
4cf7d6e47a Dani*0002                             xax,yax,XG,YG,time,pltslc,outputdir,...
                0003                             LoadGridData,SavePlots,GraphixDebug);
5bbd0d07c9 Dani*0004 
                0005 % Function: GraphixPlot
                0006 % Author:   Daniel Enderton
                0007 %
                0008 % Input Fields:
                0009 %
                0010 %   Field        Type        (Brief) Description
                0011 %   -----------------------------------------------------------------------
                0012 %   ifig         integer     Figure counter
                0013 %   field        cell array  Experiment and plot configuration information
                0014 %   data         cell array  Plotting data
                0015 %   datatime     array       Iterations ('Int') or months ('Tav') of data
                0016 %   outputdir    string      Output directory name
                0017 %   LoadGridData 0/1         Optionally load grid data
                0018 %   SavePlots    0/1         Optionally save plot to .eps file
                0019 %
                0020 % Descripton:
                0021 %   This is the plotting function for the diagnostics package.  This
                0022 %   function should allow you to plot all sorts of things, and is
                0023 %   reasonably versitile.  Unfortunately, this also means that things get
                0024 %   quite comlicated.  The code is broken up into little scripts to make it
                0025 %   more managable, though unfortunately this makes it rather difficult to
                0026 %   track variables and make changes throughout the function.
                0027 
                0028 % Load diagnostics parameters:  Plot, general, and field information.
                0029 GraphixGenParam;
                0030 GraphixPlotDefaults;
                0031 GraphixFieldParamA;
                0032 GraphixFieldParamO;
                0033 GraphixFieldParamC;
                0034 GraphixFieldParamI;
                0035 diagrunparam  = ReadVariables('GraphixRunDefaults.m');
                0036 nrow = length(page);
                0037 
                0038 % Initiate figure, with number 'ifig', set oreiention.
4cf7d6e47a Dani*0039 figure; clf; set(gca,'fontsize',fs_tick);
5bbd0d07c9 Dani*0040 
                0041 % Loop over subplots and make plots.
                0042 for inrow = 1:nrow
                0043     
                0044     ntrl = length(page{inrow}); if ntrl ~= 1, ntrl = ntrl - 1; end
                0045     if ntrl == 1, cmp = 'Sep'; else, cmp = page{inrow}{end}; end
                0046     if ntrl == 1, ncol = 1; elseif isequal(cmp,'Sbs'), ncol = ntrl; else ncol = 1; end
                0047     
                0048     for incol = 1:ncol
                0049         
                0050         if ~isequal(data{inrow}{incol},'Empty')
                0051         
                0052             % Set panel settings to default values, override first with
                0053             % page overrides and finally with panel overrides.
                0054             GraphixPlotDefaults;
                0055             for iarg = 1:length(plotparam)
                0056                 incoming = plotparamvalue{iarg};
                0057                 eval([plotparam{iarg},'=incoming;']);
                0058             end
                0059                         ExpInfo = page{inrow}{incol};
                0060             for iarg = 15:2:length(ExpInfo)
                0061                 incoming = ExpInfo{iarg+1};
                0062                 eval([ExpInfo{iarg},'=incoming;']);
                0063             end
                0064             
                0065             eval(['orient ',Orientation,';']);
                0066             
                0067             % Very crude test to see if cube sphere, must be fixed!
                0068             test = size(data{inrow}{incol});
                0069             if test(1)./test(2) == 6, isCS = 1; else, isCS = 0; end
                0070             fln = page{inrow}{incol}{ifln};
                0071             try fln = PlotFld; catch, end
                0072             pst = page{inrow}{incol}{ipst};
                0073             flu = page{inrow}{incol}{iflu};
                0074             
                0075             disp(['  Row: ',num2str(inrow),'/',num2str(nrow),...
                0076                   '; Col: ',num2str(incol),'/',num2str(ncol),...
                0077                   '; Cmp: ',cmp]);
                0078                   
                0079             % Load contour intervals, units (loaded in
                0080             % 'GraphixFieldParam[A,O,I,C]').
                0081             if ~isequal(cmp,'Dif')
                0082                 try, contint; catch
4cf7d6e47a Dani*0083                     try, eval(['contint = ',fln,'contour',flu,';']);
5bbd0d07c9 Dani*0084                     catch
                0085                         disp(['***Warning***  No contour information for ',fln]);
                0086                         disp(['               Using 10 generic contour levels.']);
                0087                         contint = 10;
                0088                     end
                0089                 end
                0090             else, try, contint; catch, contint = 10; end, end
                0091             try, units; catch
4cf7d6e47a Dani*0092                 try, eval(['units = ',fln,'units',flu,';']);
5bbd0d07c9 Dani*0093                 catch,
                0094                         disp(['***Warning***  No unit information found for ',fln]);
                0095                     disp(['               Using question mark.']);
                0096                     units = '?';
                0097                 end
                0098             end
4cf7d6e47a Dani*0099                 
                0100             dx = (1-dxl-dxr-(ncol-1)*dxm)/ncol;
                0101             dy = (1-dyb-dyt-(nrow-1)*dym)/nrow;
5bbd0d07c9 Dani*0102             xi = dxl + (incol-1)*(dx+dxm);
                0103             yi = 1-dyt-inrow*dy-(inrow-1)*dym;
                0104             
                0105             isp = (inrow-1)*ncol+incol;
                0106             if GraphixDebug, disp(['  GraphixDebug:  Subplot:  ',mat2str([nrow,ncol,isp])]); end
                0107             if GraphixDebug, disp(['  GraphixDebug:  SP Range: ',mat2str([xi,yi,dx,dy])]); end
                0108             subplot(nrow,ncol,isp); hold on;
4cf7d6e47a Dani*0109             set(gca,'position',[xi,yi,dx,dy],'fontsize',fs_axis,...
                0110                 'TickDir',TickDir);
5bbd0d07c9 Dani*0111             
                0112             if Coast
                0113                 fac = pi./180;
                0114                 xax{inrow}{incol} = xax{inrow}{incol}.*fac;
                0115                 yax{inrow}{incol} = yax{inrow}{incol}.*fac;
                0116             else, fac = 1; end
                0117             
4cf7d6e47a Dani*0118             if isempty(clabelv)
                0119                 clabelv = contint;
                0120             end
                0121             
5bbd0d07c9 Dani*0122             % (Re)set axes and color axis -- Accounts for things like a possible
                0123             % colorbar, or trimming the axis in certain ways.
                0124             % Apply desired colorbar, contour label, tick labels, box, grid, and
                0125             % other such odds and ends.
                0126             GraphixPlotMakePlot;
                0127             GraphixPlotResetAxes;
                0128             GraphixPlotMisc;
                0129             GraphixPlotTitles;
4cf7d6e47a Dani*0130             
                0131             clear contint units crange clabelv
5bbd0d07c9 Dani*0132         end
                0133     end
                0134 end
                0135 
                0136 
                0137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                0138 %                   Save plot, update figure counter                      %
                0139 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                0140 
                0141 % Save plot as desired.
                0142 if SavePlots
                0143     if isequal(outputdir,'')
                0144         outputfile = [pagename,'.eps'];
                0145     else
                0146         outputfile = [outputdir,'/',pagename,'.eps'];
                0147     end
                0148     print('-depsc2',outputfile);
                0149 end