Home > atmlab > gridcreation > gridconvert.m

gridconvert

PURPOSE ^

GRIDCONVERT Conversion of grid unit

SYNOPSIS ^

function g = gridconvert( g, varargin )

DESCRIPTION ^

 GRIDCONVERT   Conversion of grid unit

    This function allows a change of grid unit. The conversion of a grid g
    can be expressed as:

       g = -(postcs==1) * mapfun( -(precs==1)*g )

    To convert a pressure grid to increasing "pressure decades":
       g = gridconvert( g, 0, @log10, 1 );
    The reversed conversion is:
       g = gridconvert( g, 1, @pow10 );

 FORMAT   g = gridconvert( g, precs, mapfun, postcs )
        
 OUT   g        Transformed grid.
 IN    g        Original grid.
 OPT   precs    Change sign before applying *mapfun*. Defult is false.
       mapfun   Mapping function. No mapping if empty, which is default.
       postcs   Change sign after applying *mapfun*. Defult is false.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

gridconvert.m

SOURCE CODE ^

0001 % GRIDCONVERT   Conversion of grid unit
0002 %
0003 %    This function allows a change of grid unit. The conversion of a grid g
0004 %    can be expressed as:
0005 %
0006 %       g = -(postcs==1) * mapfun( -(precs==1)*g )
0007 %
0008 %    To convert a pressure grid to increasing "pressure decades":
0009 %       g = gridconvert( g, 0, @log10, 1 );
0010 %    The reversed conversion is:
0011 %       g = gridconvert( g, 1, @pow10 );
0012 %
0013 % FORMAT   g = gridconvert( g, precs, mapfun, postcs )
0014 %
0015 % OUT   g        Transformed grid.
0016 % IN    g        Original grid.
0017 % OPT   precs    Change sign before applying *mapfun*. Defult is false.
0018 %       mapfun   Mapping function. No mapping if empty, which is default.
0019 %       postcs   Change sign after applying *mapfun*. Defult is false.
0020 
0021 % 2007-10-17   Created by Patrick Eriksson.
0022 
0023 
0024 function g = gridconvert( g, varargin )
0025 %
0026 [precs,mapfun,postcs] = optargs( varargin, { false, [], false } );
0027 %                                                                          %&%
0028 rqre_datatype( g, @istensor1 );                                            %&%
0029 rqre_datatype( precs, @isboolean );                                        %&%
0030 rqre_datatype( mapfun, {@isempty,@isfunction_handle} );                    %&%
0031 rqre_datatype( postcs, @isboolean );                                       %&%
0032 
0033 
0034 if precs
0035   g = -g;
0036 end
0037 
0038 if ~isempty( mapfun )
0039   g = feval( mapfun, g );
0040 end
0041 
0042 if postcs
0043   g = -g;
0044 end
0045     
0046 
0047

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