Home > atmlab > geoplots > atmplot_xdata.m

atmplot_xdata

PURPOSE ^

ATMPLOT_XDATA A general function to plot retrieval data

SYNOPSIS ^

function ha = atmplot_xdata(x,xname,g,gnames,varargin)

DESCRIPTION ^

 ATMPLOT_XDATA   A general function to plot retrieval data

    The function aims at provide simple plotting of 1D or 2D data coming
    naturally as a vector, as when doing retrievals. 2D data are then
    assumed to be stored as [p1;p2;p3 ..] where p1 is the "profile" for
    position 1 along second dimension. For atmospheric profiles dimension
    1 is typically pressure or altitutde, and dimension 2 e.g. latitude.

    Default is to plot dimension 1 in the x-direction. This can be changed
    by the optional argument *rot*. A "rotation" is also performed if
    gnames{1} starts as 'Pressure' or 'Altitude'. For 'Pressure' the y-axis
    is made logarithmic and direction reversed.

    2D data are plotted with *rectgridplot*.

 FORMAT   ha = atmplot_xdata(x,xname,g,gnames[,fname,shadtype,rot])
        
 OUT   ha
 IN    x          Data vector to be plotted.
       xname      Data description. To be used for xlabel or ylabel. Not 
                  used for 2D.
       g          Data grid(s) as a cell array of vectors. For 1D a plain 
                  vector is also accaepted.
       gnames     Decscription of grids, as a cell array of strings. For 1D
                  a plain string is alos accepted.
 OPT   fname      Figure name. That is, title text. Default is [].
       shadtype   Type of shading for 2D figures. See *rectgridplot* for
                  options. Default is 'interp'.
       rot        See above.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

atmplot_xdata.m

SOURCE CODE ^

0001 % ATMPLOT_XDATA   A general function to plot retrieval data
0002 %
0003 %    The function aims at provide simple plotting of 1D or 2D data coming
0004 %    naturally as a vector, as when doing retrievals. 2D data are then
0005 %    assumed to be stored as [p1;p2;p3 ..] where p1 is the "profile" for
0006 %    position 1 along second dimension. For atmospheric profiles dimension
0007 %    1 is typically pressure or altitutde, and dimension 2 e.g. latitude.
0008 %
0009 %    Default is to plot dimension 1 in the x-direction. This can be changed
0010 %    by the optional argument *rot*. A "rotation" is also performed if
0011 %    gnames{1} starts as 'Pressure' or 'Altitude'. For 'Pressure' the y-axis
0012 %    is made logarithmic and direction reversed.
0013 %
0014 %    2D data are plotted with *rectgridplot*.
0015 %
0016 % FORMAT   ha = atmplot_xdata(x,xname,g,gnames[,fname,shadtype,rot])
0017 %
0018 % OUT   ha
0019 % IN    x          Data vector to be plotted.
0020 %       xname      Data description. To be used for xlabel or ylabel. Not
0021 %                  used for 2D.
0022 %       g          Data grid(s) as a cell array of vectors. For 1D a plain
0023 %                  vector is also accaepted.
0024 %       gnames     Decscription of grids, as a cell array of strings. For 1D
0025 %                  a plain string is alos accepted.
0026 % OPT   fname      Figure name. That is, title text. Default is [].
0027 %       shadtype   Type of shading for 2D figures. See *rectgridplot* for
0028 %                  options. Default is 'interp'.
0029 %       rot        See above.
0030 
0031 % 2007-03-07   Created by Patrick Eriksson.
0032 
0033 
0034 function ha = atmplot_xdata(x,xname,g,gnames,varargin)
0035 %
0036 [fname,shadtype,rot] = optargs( varargin, { [], 'interp', 0 } );
0037   
0038   
0039 %--- Check input
0040 %
0041 rqre_datatype( x, {@isvector,@ismatrix} );
0042 %
0043 if ischar(xname)
0044   %
0045 elseif iscellstr(xname)  & length(xname)==1
0046   xname = xname{1};
0047 else
0048   error( ['Input variable *xname* must be a string or a cell array ', ...
0049           'of strings with length 1.'] )
0050 end
0051 %
0052 if isnumeric(g)  &  isvector(g)
0053   tmp = g;
0054   g   = [];
0055   g{1} = tmp;
0056   clear tmp
0057 elseif iscell(g)  &  isvector(g{1})
0058   %
0059 else
0060   error( ['Input variable *g* must be a vector or a cell array ', ...
0061           'of vectors.'] )
0062 end
0063 %
0064 if ischar(gnames)
0065   tmp       = gnames;
0066   gnames    = [];
0067   gnames{1} = tmp;
0068   clear tmp
0069 elseif iscellstr(gnames)
0070   %
0071 else
0072   error( ['Input variable *gnames* must be a string or a cell array ', ...
0073           'of strings'] )
0074 end
0075 %
0076 if length(g) ~= length(gnames)
0077   error( 'Different number of implied data dimensions in *g* and *gnames*.' );
0078 end
0079 
0080 
0081 
0082 dim = length(g);
0083 
0084 
0085 %--- 1D
0086 %
0087 if dim == 1
0088   
0089   if size(x,1) ~= length(g{1})
0090     error( 'Size of *x* and grid length do not match.' )
0091   end
0092   
0093   %- Pressure
0094   if strncmp( gnames{1}, 'Pressure', 8 )
0095     semilogy( x, g{1} );
0096     set( gca, 'Ydir', 'rev' );
0097     xlabel( xname )
0098     ylabel( gnames{1} );
0099 
0100   %- Selected rotation or altitude
0101   elseif rot  |  strncmp( gnames{1}, 'Altitude', 8 )
0102     plot( x, g{1} );
0103     xlabel( xname )
0104     ylabel( gnames{1} );
0105     
0106   else
0107     plot( g{1}, x );
0108     xlabel( gnames{1} );
0109     ylabel( xname )
0110   end
0111  
0112 
0113 %--- 2D
0114 %
0115 elseif dim == 2
0116   if size(x,1) ~= length(g{1})*length(g{2})
0117     error( 'Size of *x* and product of grid lengths do not match.' )
0118   end
0119 
0120   F = reshape( x, length(g{1}), length(g{2}) );
0121   x = grid2edges( g{1} );
0122   y = grid2edges( g{2} );
0123   
0124   %- Pressure
0125   if strncmp( gnames{1}, 'Pressure', 8 )
0126     rectgridplot( y, x, F', shadtype );
0127     set( gca, 'Yscale', 'log' );
0128     set( gca, 'Ydir', 'rev' );
0129     xlabel( gnames{2} )
0130     ylabel( gnames{1} );
0131 
0132   %- Selected rotation or altitude
0133   elseif rot  |  strncmp( gnames{1}, 'Altitude', 8 )
0134     rectgridplot( y, x, F', shadtype );
0135     xlabel( gnames{2} )
0136     ylabel( gnames{1} );
0137     
0138   else
0139     rectgridplot( x, y, F, shadtype );
0140     xlabel( gnames{1} )
0141     ylabel( gnames{2} );
0142   end
0143   
0144 else
0145   error( 'Only 1D and 2D are handled' );
0146 end
0147 
0148 
0149 if ~isempty( fname )
0150   title( fname )
0151 end
0152 
0153 
0154 ha = gca;

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005