Home > atmlab > arts > qarts_abstable.m

qarts_abstable

PURPOSE ^

QARTS_ABSTABLE Help preparing qarts for calculation of an absorption table

SYNOPSIS ^

function Q = qarts_abstable( Q, varargin )

DESCRIPTION ^

 QARTS_ABSTABLE   Help preparing qarts for calculation of an absorption table

   Sets automatically some Q-fields (see below) needed for calculation of
   an absorption look-up table. The fields are set to match the selected
   pressure grid and atmospheric temperature and VMR fields. 

   The pressure grid is set to be identical to P_GRID, while temperature
   and VMR profiles are set to the mean of max and min values. 

   Default values for optional arguments should work for a single
   calculation. Temperature and "non-linear" species variations are then
   selected automatically to precisely cover the variation of specified
   atmospheric fields.

   The following fields must always be set:
      Q.ATMOSPHERE_DIM
      Q.P_GRID
      Q.ABS_NLS

 FORMAT   Q = qarts_abstable( Q [, nt, dt, dnls ] )
        
 OUT   Q      Q structure with some fields automatically set. These fields
              are:
                 ABSORPTION
                 ABS_P
                 ABS_T
                 ABS_T_PERT 
                 ABS_VMRS 
                 ABS_NLS_PERT
 IN    Q      Original qarts settings.
 OPT   nt     Number of temperature variations. Default is 1.
       dt     Maximum size of temperature variation. If set to be empty,
              an automatic selection is made. Default is 50. This value 
              has no impact if *dt* < 2.
       dnls   Relative disturbances for "non-linear" species.
              Default is [], that signifies no disturbances.
              Otherwise required to be a vector, the vector values are used 
              as variations. A value of 2 means here "twice the reference".

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

qarts_abstable.m

SOURCE CODE ^

0001 % QARTS_ABSTABLE   Help preparing qarts for calculation of an absorption table
0002 %
0003 %   Sets automatically some Q-fields (see below) needed for calculation of
0004 %   an absorption look-up table. The fields are set to match the selected
0005 %   pressure grid and atmospheric temperature and VMR fields.
0006 %
0007 %   The pressure grid is set to be identical to P_GRID, while temperature
0008 %   and VMR profiles are set to the mean of max and min values.
0009 %
0010 %   Default values for optional arguments should work for a single
0011 %   calculation. Temperature and "non-linear" species variations are then
0012 %   selected automatically to precisely cover the variation of specified
0013 %   atmospheric fields.
0014 %
0015 %   The following fields must always be set:
0016 %      Q.ATMOSPHERE_DIM
0017 %      Q.P_GRID
0018 %      Q.ABS_NLS
0019 %
0020 % FORMAT   Q = qarts_abstable( Q [, nt, dt, dnls ] )
0021 %
0022 % OUT   Q      Q structure with some fields automatically set. These fields
0023 %              are:
0024 %                 ABSORPTION
0025 %                 ABS_P
0026 %                 ABS_T
0027 %                 ABS_T_PERT
0028 %                 ABS_VMRS
0029 %                 ABS_NLS_PERT
0030 % IN    Q      Original qarts settings.
0031 % OPT   nt     Number of temperature variations. Default is 1.
0032 %       dt     Maximum size of temperature variation. If set to be empty,
0033 %              an automatic selection is made. Default is 50. This value
0034 %              has no impact if *dt* < 2.
0035 %       dnls   Relative disturbances for "non-linear" species.
0036 %              Default is [], that signifies no disturbances.
0037 %              Otherwise required to be a vector, the vector values are used
0038 %              as variations. A value of 2 means here "twice the reference".
0039 
0040 % 2007-08-22   Created by Patrick Eriksson.
0041 
0042 
0043 function Q = qarts_abstable( Q, varargin )
0044 %
0045 [nt,dt,dnls] = optargs( varargin, { 1, 50, [] } );
0046                                                                            %&%
0047 %= Check input                                                             %&%
0048 %                                                                          %&%
0049 rqre_nargin(1,nargin);                                                     %&%
0050 %                                                                          %&%
0051 rqre_datatype( Q, @isstruct );                                             %&%
0052 %                                                                          %&%
0053 if ~qarts_isset( Q.ATMOSPHERE_DIM )                                        %&%
0054   error( 'Q.ATMOSPHERE_DIM must be set' );                                 %&%
0055 end                                                                        %&%
0056 rqre_alltypes( Q.ATMOSPHERE_DIM, {@istensor0,@iswhole}, ...                %&%
0057                                            'Q.ATMOSPHERE_DIM' );           %&%
0058 if ~qarts_isset( Q.P_GRID )                                                %&%
0059   error( 'Q.P_GRID must be set' );                                         %&%
0060 end                                                                        %&%
0061 if ~qarts_isset( Q.ABS_NLS )                                               %&%
0062   error( 'Q.ABS_NLS must be set' );                                        %&%
0063 end                                                                        %&%
0064 rqre_alltypes( nt, {@istensor0,@iswhole} );                                %&%
0065 rqre_datatype( dt, {@istensor0} );                                         %&%
0066 rqre_datatype( dnls, {@isempty,@istensor1} );                              %&%
0067 
0068 
0069 %- Obtain atmospheric profiles
0070 %
0071 p_grid = qarts_get( Q.P_GRID );
0072 %
0073 if qarts_isset( Q.RAW_ATMOSPHERE )
0074   %
0075   [t_field,z_field,vmr_field] = arts_atmfields( Q ); 
0076 else
0077   t_field   = qarts_get( Q.T_FIELD );
0078   vmr_field = qarts_get( Q.VMR_FIELD );
0079   %
0080   np = length( p_grid );
0081   if np~=size(t_field,1)  |  np~=size(vmr_field,2)
0082     error( 'Either T_FIELD or VMR_FIELD does not match P_GRID' );
0083   end
0084 end
0085 
0086 
0087 
0088 %- Compact to 1D, and possibly determine dt and dnls automatically
0089 %
0090 if Q.ATMOSPHERE_DIM == 1
0091   %
0092   t = t_field;
0093   if isempty(dt)
0094     dt = 0;
0095   end
0096   %
0097   vmr = vmr_field;
0098   %
0099 else
0100   %
0101   t_max   = t_field;
0102   t_min   = t_field;
0103   vmr_max = vmr_field;
0104   vmr_min = vmr_field;
0105   %
0106   if Q.ATMOSPHERE_DIM == 3
0107     t_max   = max( t_max, [], 3 );
0108     t_min   = min( t_min, [], 3 );
0109     vmr_max = max( vmr_max, [], 4 );
0110     vmr_min = min( vmr_min, [], 4 );
0111   end
0112   if Q.ATMOSPHERE_DIM > 1
0113     t_max   = max( t_max, [], 2 );
0114     t_min   = min( t_min, [], 2 );
0115     vmr_max = max( vmr_max, [], 3 );
0116     vmr_min = min( vmr_min, [], 3 );
0117   end 
0118   %
0119   t   = ( t_max + t_min ) / 2;
0120   vmr = ( vmr_max + vmr_min ) / 2;
0121   %
0122   if isempty(dt)
0123     dt   = max([ max(t_max-t_min)/2 (nt-1)/2]);  % No idea to have steps < 1K
0124   end
0125 end
0126 
0127 
0128 
0129 %- Fill Q fields
0130 %
0131 Q.ABSORPTION = 'CalcTable';
0132 %
0133 Q.ABS_P      = p_grid;
0134 %
0135 Q.ABS_T      = t;
0136 %
0137 if dt == 0  |  nt < 2
0138   Q.ABS_T_PERT = [];
0139 else
0140   Q.ABS_T_PERT = linspace( -dt, dt, nt )';
0141 end  
0142 %
0143 Q.ABS_VMRS   = vmr;
0144 %
0145 if isempty( Q.ABS_NLS )  |  isempty( dnls )
0146   Q.ABS_NLS_PERT = [];
0147 else
0148   if length(dnls) < 2
0149     error( 'The argument *dnls* can not be a scalar.' );
0150   else
0151     Q.ABS_NLS_PERT = dnls;
0152   end
0153 end  
0154 
0155 
0156

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