Home > atmlab > demos > qarts_demo2.m

qarts_demo2

PURPOSE ^

QARTS_DEMO2 A demonstration of Qarts

SYNOPSIS ^

function [Q,f,y] = qarts_demo2( varargin )

DESCRIPTION ^

 QARTS_DEMO2   A demonstration of Qarts

    As *qarts_demo*, but with more advanced calculation options.
    Pre-calculation of absorption and sensor characteristics is 
    exemplified. VMR_FIELD is set through ABS_SPECIES.ATMDATA.
    Further, pre-defined agendas are used.

    Input temperature data are 2D, and it can not be expected that 
    1D results shall be identical to 2D and 3D.

 FORMAT   [Q,f,y] = qarts_demo2( [ ztan, atmdim ] )
        
 OUT   Q          Qarts setting structure.
       f          Frequency grid
       y          Calculated spectrum
 OPT   ztan       Tangent altitude. Default is 30 km.
       atmdim     Atmospheric dimensionality. Default is 1.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

qarts_demo2.m

SOURCE CODE ^

0001 % QARTS_DEMO2   A demonstration of Qarts
0002 %
0003 %    As *qarts_demo*, but with more advanced calculation options.
0004 %    Pre-calculation of absorption and sensor characteristics is
0005 %    exemplified. VMR_FIELD is set through ABS_SPECIES.ATMDATA.
0006 %    Further, pre-defined agendas are used.
0007 %
0008 %    Input temperature data are 2D, and it can not be expected that
0009 %    1D results shall be identical to 2D and 3D.
0010 %
0011 % FORMAT   [Q,f,y] = qarts_demo2( [ ztan, atmdim ] )
0012 %
0013 % OUT   Q          Qarts setting structure.
0014 %       f          Frequency grid
0015 %       y          Calculated spectrum
0016 % OPT   ztan       Tangent altitude. Default is 30 km.
0017 %       atmdim     Atmospheric dimensionality. Default is 1.
0018 
0019 % 2008-05-27   Updated to ARTS2 by Patrick Eriksson.
0020 % 2007-08-23   Created by Patrick Eriksson (based qarts_demo).
0021 
0022 
0023 function [Q,f,y] = qarts_demo2( varargin )
0024 %
0025 [ztan,atmdim] = optargs( varargin, { 30e3, 1 } );
0026 
0027 
0028 %= Atmlab settings
0029 %
0030 arts_xmldata_path = atmlab( 'ARTS_XMLDATA_PATH' );
0031 %
0032 if isnan( arts_xmldata_path )
0033   error('You need to ARTS_XMLDATA_PATH to run this example.');
0034 end
0035 %
0036 fascod = fullfile( arts_xmldata_path, 'planets', 'Earth', 'Fascod' );
0037 
0038   
0039 %= Init Q structures
0040 %
0041 Q  = qarts;
0042 %
0043 Q.INCLUDES              = { fullfile( 'ARTS_INCLUDES', 'general.arts' ), ...
0044                             fullfile( 'ARTS_INCLUDES', 'agendas.arts' ), ...
0045                             fullfile( 'ARTS_INCLUDES', 'continua.arts' ), ...
0046                             fullfile( 'ARTS_INCLUDES', 'planet_earth.arts' ) };
0047 
0048 
0049 %= De-activate parts not used
0050 %
0051 Q.CLOUDBOX_DO           = false;
0052 Q.J_DO                  = false;
0053 
0054 
0055 %= Define agendas
0056 %
0057 % Here we do it by using the predefined agenda templates.
0058 % This works only if the pre-defined agenda is names following the pattern:
0059 %    name_of_agenda__(Something)
0060 %
0061 Q.PPATH_AGENDA               = { 'ppath_agenda__FollowSensorLosPath'   };
0062 Q.PPATH_STEP_AGENDA          = { 'ppath_step_agenda__GeometricPath'    };
0063 Q.BLACKBODY_RADIATION_AGENDA = { 'blackbody_radiation_agenda__Planck'  };
0064 Q.IY_SPACE_AGENDA            = { 'iy_space_agenda__CosmicBackground'   };
0065 Q.IY_SURFACE_AGENDA          = { 'iy_surface_agenda__UseSurfaceRtprop' };
0066 Q.IY_MAIN_AGENDA             = { 'iy_main_agenda__Emission'            };
0067 
0068 
0069 %= Atmospheric species
0070 %
0071 % Note that ATMDATA for nitrogen is set to a scalar
0072 %
0073 Q.ABS_SPECIES(1).TAG{1}  = 'ClO';
0074 Q.ABS_SPECIES(1).ATMDATA = gf_artsxml( fullfile( fascod, 'tropical', ...
0075                             'tropical.ClO.xml' ), 'ClO', 'vmr_field' ); 
0076 %
0077 Q.ABS_SPECIES(2).TAG{1}  = 'O3';
0078 Q.ABS_SPECIES(2).ATMDATA = gf_artsxml( fullfile( fascod, 'subarctic-summer',...
0079                               'subarctic-summer.O3.xml' ), 'O3', 'vmr_field' ); 
0080 %
0081 Q.ABS_SPECIES(3).TAG{1}  = 'N2O';
0082 Q.ABS_SPECIES(3).ATMDATA = gf_artsxml( fullfile( fascod, 'tropical', ...
0083                             'tropical.N2O.xml' ), 'N2O', 'vmr_field' ); 
0084 %
0085 Q.ABS_SPECIES(4).TAG{1}  = 'H2O-*-490e9-510e9'; % Some local lines not in PWR98
0086 Q.ABS_SPECIES(4).TAG{2}  = 'H2O-PWR98';
0087 Q.ABS_SPECIES(4).ATMDATA = gf_artsxml( fullfile( fascod, 'tropical', ...
0088                             'tropical.H2O.xml' ), 'H2O', 'vmr_field' ); 
0089 %
0090 Q.ABS_SPECIES(5).TAG{1}  = 'N2-SelfContStandardType';
0091 Q.ABS_SPECIES(5).ATMDATA = gf_set( atmdata_empty(0), 0.781, [] );
0092 
0093 
0094 %= Temperature and geoemtrical altitudes are taken from CIRA86
0095 %
0096 Q.T.ATMDATA              = gf_artsxml( fullfile( arts_xmldata_path, ...
0097          'climatology', 'cira86', 'cira86.t.xml' ), 'Temperature', 't_field' );
0098 Q.Z.ATMDATA              = gf_artsxml( fullfile( arts_xmldata_path, ...
0099            'climatology', 'cira86', 'cira86.z.xml' ), 'Altitudes', 'z_field' );
0100 
0101 
0102 %= Set-up atmosphere and surface
0103 %
0104 Q.ATMOSPHERE_DIM         = atmdim;
0105 %
0106 Q.P_GRID                 = z2p_simple( [0:500:45e3 46e3:1e3:100e3]' );
0107 %
0108 if atmdim == 1
0109   Q.LAT_TRUE             = 0;    
0110   Q.LON_TRUE             = 80;    
0111 elseif atmdim == 2
0112   Q.LAT_GRID             = [-10:10]'; 
0113   Q.LAT_TRUE             = Q.LAT_GRID; 
0114   Q.LON_TRUE             = repmat( 0, size( Q.LAT_GRID ) );
0115 else
0116   Q.LAT_GRID             = [-10:10]'; 
0117   Q.LON_GRID             = [-10:10]'; 
0118 end
0119 %
0120 Q.REFELLIPSOID           = ellipsoidmodels( 'SphericalEarth' );
0121 if atmdim < 3
0122   Q.Z_SURFACE            = repmat( 500, length(Q.LAT_TRUE), length(Q.LON_TRUE));
0123 else
0124   Q.Z_SURFACE            = repmat( 500, length(Q.LAT_GRID), length(Q.LON_GRID));
0125 end
0126 
0127 %= Set-up VMR_FIELD, T_FIELD and Z_FIELD
0128 % A dummy date
0129 mjd = date2mjd( 2008, 2, 15 );
0130 %
0131 Q.VMR_FIELD              = qarts_vmr_field( Q );
0132 Q.T_FIELD                = qarts_atm_field( Q, 't', mjd );
0133 Q.Z_FIELD                = qarts_atm_field( Q, 'z', mjd );
0134 
0135 
0136 %= Absorption
0137 %
0138 Q.F_GRID                 = linspace( 501.18e9, 501.58e9, 201 )';
0139 Q.STOKES_DIM             = 1;
0140 %
0141 % Absorption is here precalculated. The look-up table is here loaded (into
0142 % Q.ABS_LOOKUP), which will be followed by a saving of data. This
0143 % unnecessary loading/saving can be avoided by giving *arts_abstable* a
0144 % folder where the look-up can be saved: Q.ABS_LOOKUP = arts_abstable(Q,folder);
0145 %
0146 Q.ABS_LINES_FORMAT       = 'Arts';
0147 Q.ABS_LINES              = fullfile( atmlab_example_data , 'lines501.4' );
0148 Q.ABS_NLS                = [];
0149 %
0150 Q                        = qarts_abstable( Q, 8, 15 );
0151 Q.ABS_LOOKUP             = arts_abstable( Q );        
0152 %
0153 Q.ABSORPTION             = 'LoadTable';
0154 
0155 
0156 %= Sensor
0157 %
0158 % Simple example, only including a narrow antenna pattern.
0159 %
0160 % Sensor reponse is here pre-calculated. Considerations around
0161 % loading/saving are identical to absorption, commented above.
0162 %
0163 if 1                  % Commit only with 1 here, to make *make_check* to work
0164   Q.SENSOR_DO = false;
0165 else
0166   H                      = qartsSensor;
0167   %
0168   H.SENSOR_NORM          = true;
0169   %
0170   Q.ANTENNA_DIM          = 1;
0171   Q.MBLOCK_ZA_GRID       = [-0.04:0.02:0.04]';
0172   H.ANTENNA_DO           = true;
0173   H.ANTENNA_LOS          = 0;
0174   H.ANTENNA_RESPONSE     = fullfile( atmlab_example_data, 'antenna.xml' );
0175   %
0176   Q.SENSOR_DO            = true;
0177   Q.SENSOR_RESPONSE      = H;
0178   %
0179   % Calculate:
0180   Q = arts_sensor( Q );
0181 end
0182 
0183 
0184 %= Set RTE variables (refraction is here neglected)
0185 %
0186 Q.YCALC_WSMS             = { 'yCalc' };
0187 %
0188 Q.PPATH_LMAX             = 20e3;
0189 Q.IY_UNIT                = 'RJBT';
0190 %
0191 zplat                    = 600e3;
0192 Q.SENSOR_POS             = [ zplat, -23, 0 ];
0193 Q.SENSOR_POS             = Q.SENSOR_POS(1:atmdim);
0194 %
0195 Q.SENSOR_LOS             = geomztan2za( Q.REFELLIPSOID(1), zplat, ztan );
0196 if atmdim == 3
0197   Q.SENSOR_LOS           = [ Q.SENSOR_LOS, 5 ];
0198 end
0199 
0200 
0201 
0202 if nargout == 1
0203   return
0204 end
0205 
0206 
0207 
0208 %= Calculate spectrum/spectra
0209 %
0210 y = arts_y( Q );
0211 %
0212 f = Q.F_GRID;
0213 
0214 
0215 
0216 %= Plot
0217 %
0218 if ~nargout
0219   plot( Q.F_GRID/1e9, y, 'LineWidth', 2 );
0220   xlabel( 'Frequency [GHz]' )
0221   ylabel( 'Brightness temperature [K]' )
0222   title( sprintf( 'Odin-SMR ClO band (tangent altitude = %.1f km)', ztan/1e3));
0223 end
0224

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