Home > atmlab > arts > scenegen > asg_regrid.m

asg_regrid

PURPOSE ^

ASG_REGRID Re-gridding of ASG data.

SYNOPSIS ^

function G = asg_regrid( G, Q )

DESCRIPTION ^

 ASG_REGRID   Re-gridding of ASG data.

    The data are re-gridded to match Q.P_GRID, Q.LAT_GRID and Q.LON_GRID. 
    These grids must be set before calling this function (that is, scalar
    input is not allowed as for *asg_atmgrids*).

    Interpolation in pressure is performed after conversion to pressure
    decades. Nothing is done if the DATA field is empty. 

 FORMAT   G = asg_regrid( G, Q )
        
 OUT   G   Re-gridded ASG data.
 IN    
       G   gformat data data.
       Q   Qarts setting structure.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

asg_regrid.m

SOURCE CODE ^

0001 % ASG_REGRID   Re-gridding of ASG data.
0002 %
0003 %    The data are re-gridded to match Q.P_GRID, Q.LAT_GRID and Q.LON_GRID.
0004 %    These grids must be set before calling this function (that is, scalar
0005 %    input is not allowed as for *asg_atmgrids*).
0006 %
0007 %    Interpolation in pressure is performed after conversion to pressure
0008 %    decades. Nothing is done if the DATA field is empty.
0009 %
0010 % FORMAT   G = asg_regrid( G, Q )
0011 %
0012 % OUT   G   Re-gridded ASG data.
0013 % IN
0014 %       G   gformat data data.
0015 %       Q   Qarts setting structure.
0016 
0017 % 2007-10-08   Created by Patrick Eriksson
0018 
0019 
0020 function G = asg_regrid( G, Q )
0021 
0022 
0023 %- Basic checks
0024 %
0025 % D and G are partially checked inside gf functions.
0026 % Full check of D, G and Q is only made in *asg_chdim* for efficiency reasons.
0027 
0028 
0029 %- Create array with new grids.
0030 %
0031 grids = [ {vec2col(Q.P_GRID)} {vec2col(Q.LAT_GRID)} {vec2col(Q.LON_GRID)} ];
0032 
0033 
0034 %- Switch to pressure decades
0035 %
0036 grids{1} = gridconvert( grids{1}, false, @log10, true );
0037 
0038  for ig = 1 : length(G)
0039 
0040   %- Do nothing if DATA or DIMS field is empty.
0041   
0042   if ~isempty( G(ig).DATA )  &  ~isempty( G(ig).DIM ) 
0043   
0044     dim = G(ig).DIM;
0045     %change G.GRID1 to pressure decade
0046     if strcmp(lower(G(ig).GRID1_NAME),'pressure')
0047        grid1=gridconvert( vec2col(G(ig).GRID1), false, @log10, true );
0048        G(ig).GRID1=grid1;
0049     
0050     
0051      if dim==3
0052        G(ig).GRID1=vec2col(G(ig).GRID1);
0053        G(ig).GRID2=vec2col(G(ig).GRID2);
0054        G(ig).GRID3=vec2col(G(ig).GRID3);
0055        G(ig)= gf_regrid(G(ig), grids );
0056        
0057      elseif dim==2
0058        G(ig).GRID1=vec2col(G(ig).GRID1);
0059        G(ig).GRID2=vec2col(G(ig).GRID2);
0060        G(ig)= gf_regrid(G(ig), [{grids{1}} {grids{2}}] );
0061      
0062      else
0063        G(ig).GRID1=vec2col(G(ig).GRID1);
0064        G(ig)= gf_regrid(G(ig), [{grids{1}}] );
0065 
0066      end
0067       %switch back from pressure decades
0068        grid1=gridconvert( vec2col(G(ig).GRID1), true, @pow10);
0069        G(ig).GRID1=grid1;
0070      
0071     end
0072     %try
0073     %  G(ig) = gf_regrid( G(ig), { grids });
0074     %catch
0075     %  fprintf( '%s\n\n', lasterr );
0076     %  error( sprintf('Message above applies to G(%d).',ig) );
0077     %end
0078     
0079   end
0080   
0081 end
0082 
0083   
0084 %- Back to Pa
0085 %
0086 %G        = gf_grid_convert( D, G, 1, 1, @pow10 );
0087

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