Home > atmlab > arts > arts_regrid.m

arts_regrid

PURPOSE ^

ARTS_REGRID Regridding of atmospheric fields

SYNOPSIS ^

function F = arts_regrid( dim, Q1, F0, Q2 )

DESCRIPTION ^

 ARTS_REGRID   Regridding of atmospheric fields

   Mimics the interpolation done in ARTS. For example, log(p) is used as
   vertical coordinate. 

   There are two options to specify grids, valid for both Q1 and Q2.
   The first option is that Q is a structure, including the fields 
   P_GRID, LAT_GRID and LON_GRID. 
   The second option is that Q is an ArrayOfGrids, where the first
   grid is taken as p_grid etc.

   Grids for dimensions not used can be left out.

   This function operates just with the internal grids (P_GRID, LAT_GRID and
   LON_GRID), and can not be used to for interpolation considering LAT_TRUE
   and LON_TRUE.

   The actual interpolation is made by gridinterp, with *extrap* set to
   true. That is, "extrapolation" following arts retrieval grids is applied
   throughout.

 FORMAT   F = arts_regrid( dim, Q1, F0, Q2 )
        
 OUT   F     Interpolated field.
 IN    dim   Atmospheric dimensionality.
       Q1    Original grids. See further above.
       F0    Field to interpolate.
       Q2    New grids. See further above.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

DOWNLOAD ^

arts_regrid.m

SOURCE CODE ^

0001 % ARTS_REGRID   Regridding of atmospheric fields
0002 %
0003 %   Mimics the interpolation done in ARTS. For example, log(p) is used as
0004 %   vertical coordinate.
0005 %
0006 %   There are two options to specify grids, valid for both Q1 and Q2.
0007 %   The first option is that Q is a structure, including the fields
0008 %   P_GRID, LAT_GRID and LON_GRID.
0009 %   The second option is that Q is an ArrayOfGrids, where the first
0010 %   grid is taken as p_grid etc.
0011 %
0012 %   Grids for dimensions not used can be left out.
0013 %
0014 %   This function operates just with the internal grids (P_GRID, LAT_GRID and
0015 %   LON_GRID), and can not be used to for interpolation considering LAT_TRUE
0016 %   and LON_TRUE.
0017 %
0018 %   The actual interpolation is made by gridinterp, with *extrap* set to
0019 %   true. That is, "extrapolation" following arts retrieval grids is applied
0020 %   throughout.
0021 %
0022 % FORMAT   F = arts_regrid( dim, Q1, F0, Q2 )
0023 %
0024 % OUT   F     Interpolated field.
0025 % IN    dim   Atmospheric dimensionality.
0026 %       Q1    Original grids. See further above.
0027 %       F0    Field to interpolate.
0028 %       Q2    New grids. See further above.
0029 
0030 % 2006-08-18   Created by Patrick Eriksson
0031 
0032 
0033 function F = arts_regrid( dim, Q1, F0, Q2 )
0034 
0035 %= Check input                                                   %&%
0036 %                                                                %&%
0037 rqre_nargin(4,nargin);                                           %&%
0038 %                                                                %&%
0039 rqre_alltypes( dim, {@istensor0,@iswhole} );                     %&%
0040 rqre_in_range( dim, 1, 3 );                                      %&%
0041 
0042 
0043 grids1 = extract_grids( dim, Q1, 'Q1' );
0044 grids2 = extract_grids( dim, Q2, 'Q2' );
0045 
0046 
0047 F = gridinterp( grids1, qarts_get(F0), grids2, 'linear', true );
0048 
0049 return
0050 
0051 function grids = extract_grids( dim, Q, qname )
0052 
0053 if iscell(Q)
0054   %
0055   grids = Q;
0056   grids{1} = -log( grids{1} );
0057   
0058 elseif isstruct(Q)
0059   %                                                             %&%
0060   rqre_field( Q, {'P_GRID'}, qname );                           %&%
0061   %
0062   grids{1} = -log( qarts_get( Q.P_GRID ) );
0063 
0064   if dim == 2
0065     %                                                           %&%
0066     rqre_field( Q, {'LAT_GRID'}, qname );                       %&%
0067     %
0068     grids{2} = qarts_get( Q.LAT_GRID );
0069 
0070   elseif dim == 3
0071     %                                                           %&%
0072     rqre_field( Q, {'LAT_GRID'}, qname );                       %&%
0073     rqre_field( Q, {'LON_GRID'}, qname );                       %&%
0074     %
0075     grids{2} = qarts_get( Q.LAT_GRID );
0076     grids{3} = qarts_get( Q.LON_GRID );
0077   end
0078 else                                                            %&%
0079   error( 'Unknown choice for Q.' );                             %&%
0080 end

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