Home > atmlab > arts > scenegen > asg_atmgrids.m

asg_atmgrids

PURPOSE ^

ASG_ATMGRIDS Automatic selection of the atmospheric grids

SYNOPSIS ^

function Q = asg_atmgrids( D, G, Q );

DESCRIPTION ^

 ASG_ATMGRIDS   Automatic selection of the atmospheric grids

    The following Q fields are considered:
       ATMOSPHERE_DIM
       P_GRID
       LAT_GRID
       LON_GRID

    If any of the grids are set to a scalar, a grid is created by taking the
    union of all corresponding grids in G (by *gf_grid_union*). The given
    scalar value is used as minimum distance between grid points (see input
    argument *mindx* in *gridthinning*). No thinning is performed if grid
    set to be empty or 0.

    The unit for scalar P_GRID is pressure decades. Normal values should
    accordingly be in the order of 0.01 (roughly equal to 200/16e3).

 FORMAT   Q = asg_atmgrids( D, G, Q )
        
 OUT   Q   Modified qarts setting structure.
 IN    D   Gformat definition structure.
       G   AGS data.
       Q   Qarts setting structure.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

asg_atmgrids.m

SOURCE CODE ^

0001 % ASG_ATMGRIDS   Automatic selection of the atmospheric grids
0002 %
0003 %    The following Q fields are considered:
0004 %       ATMOSPHERE_DIM
0005 %       P_GRID
0006 %       LAT_GRID
0007 %       LON_GRID
0008 %
0009 %    If any of the grids are set to a scalar, a grid is created by taking the
0010 %    union of all corresponding grids in G (by *gf_grid_union*). The given
0011 %    scalar value is used as minimum distance between grid points (see input
0012 %    argument *mindx* in *gridthinning*). No thinning is performed if grid
0013 %    set to be empty or 0.
0014 %
0015 %    The unit for scalar P_GRID is pressure decades. Normal values should
0016 %    accordingly be in the order of 0.01 (roughly equal to 200/16e3).
0017 %
0018 % FORMAT   Q = asg_atmgrids( D, G, Q )
0019 %
0020 % OUT   Q   Modified qarts setting structure.
0021 % IN    D   Gformat definition structure.
0022 %       G   AGS data.
0023 %       Q   Qarts setting structure.
0024 
0025 
0026 % 2007-10-19   Created by Patrick Eriksson
0027 
0028 
0029 function Q = asg_atmgrids( D, G, Q );
0030 
0031   
0032 %- Basic checks
0033 %
0034 % D and G are partially checked inside gf functions.
0035 % Full check of D, G and Q is only made in *asg_chdim* for efficiency reasons.
0036 
0037 
0038 dims = [];
0039 
0040 
0041 %- Check for what dimensions grid union is reuqired, and some checks
0042 %
0043 if isnan( Q.P_GRID )
0044   error( 'NaN found for Q.P_GRID' );
0045 elseif isempty( Q.P_GRID )  |  isscalar( Q.P_GRID )
0046   dims = 1;
0047 elseif isnumeric( Q.P_GRID )  &  isvector( Q.P_GRID )
0048   %
0049 else
0050   error( 'Q.P_GRID must be empty, a scalar or a vector.' );  
0051 end
0052 %
0053 if Q.ATMOSPHERE_DIM >= 2
0054   if isnan( Q.LAT_GRID )
0055     error( 'NaN found for Q.LAT_GRID' );
0056   elseif isempty( Q.LAT_GRID )  |  isscalar( Q.LAT_GRID )
0057     dims = [ dims 2 ];
0058   elseif isnumeric( Q.LAT_GRID )  &  isvector( Q.LAT_GRID )
0059     %
0060   else
0061     error( 'Q.LAT_GRID must be empty, a scalar or a vector.' );  
0062   end
0063 end
0064 %
0065 if Q.ATMOSPHERE_DIM == 3
0066   if isnan( Q.LON_GRID )
0067     error( 'NaN found for Q.LON_GRID' );
0068   elseif isempty( Q.LON_GRID )  |  isscalar( Q.LON_GRID )
0069     dims = [ dims 3 ];
0070   elseif isnumeric( Q.LON_GRID )  &  isvector( Q.LON_GRID )
0071     %
0072   else
0073     error( 'Q.LON_GRID must be empty, a scalar or a vector.' );  
0074   end
0075 end
0076 
0077 
0078 %- Something to do?
0079 %
0080 if isempty( dims )
0081   return;           % --->
0082 end
0083 
0084 grids = gf_grid_union(D,G,dims);
0085 
0086 %- Set P_GRID
0087 %
0088 if any( dims == 1 )
0089   %
0090   % Consider that grids{1} is sorted in ascending order, and is in Pa while
0091   % grid thinning is made in pressure decades.
0092   %
0093   grids{1} = flipud( vec2col( grids{1} ) );
0094   if isempty( Q.P_GRID )  |  Q.P_GRID == 0 
0095     Q.P_GRID = grids{1};
0096   else
0097     grids{1} = gridconvert( grids{1}, 0, @log10, 1 );
0098     grids{1} = gridthinning( grids{1}, Q.P_GRID );
0099     Q.P_GRID = gridconvert( grids{1}, 1, @pow10 );
0100   end
0101   %
0102 end
0103 
0104 
0105 %- Set LAT_GRID
0106 %
0107 if any( dims == 2 )
0108   %
0109   id = find( dims == 2 );
0110   %
0111   if isempty( grids{id} )
0112     error( 'Automatic setting of Q.LAT_GRID not possible (no input data).' );
0113   end
0114   %
0115   if isempty( Q.LAT_GRID )  |  Q.LAT_GRID == 0 
0116     Q.LAT_GRID = grids{id};
0117   else 
0118     Q.LAT_GRID = gridthinning( grids{id}, Q.LAT_GRID );
0119   end
0120   %
0121 end
0122 
0123 
0124 %- Set LON_GRID
0125 %
0126 if any( dims == 3 )
0127   %
0128   id = find( dims == 3 );
0129   %
0130   if isempty( grids{id} )
0131     error( 'Automatic setting of Q.LON_GRID not possible (no input data).' );
0132   end
0133   %
0134   if isempty( Q.LON_GRID )  |  Q.LON_GRID == 0 
0135     Q.LON_GRID = grids{id};
0136   else 
0137     Q.LON_GRID = gridthinning( grids{id}, Q.LON_GRID );
0138   end
0139   %
0140 end
0141 
0142 
0143 
0144 
0145 
0146 
0147

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