105                Index&                mc_iteration_count,
   110                const Index&          f_index,
   113                const Index&          stokes_dim,
   114                const Index&          atmosphere_dim,
   115                const Agenda&         ppath_step_agenda,
   116                const Numeric&        ppath_lraytrace,
   117                const Agenda&         iy_space_agenda,
   118                const Agenda&         surface_rtprop_agenda,
   119                const Agenda&         propmat_clearsky_agenda, 
   124                const Vector&         refellipsoid, 
   128                const Index&          cloudbox_on,
   132                const Index&          atmfields_checked,
   133                const Index&          atmgeom_checked,
   134                const Index&          cloudbox_checked,
   135                const Index&          mc_seed,
   138                const Index&          max_time,
   139                const Index&          max_iter,
   140                const Index&          min_iter,
   146   if( atmfields_checked != 1 )
   147     throw runtime_error( 
"The atmospheric fields must be flagged to have "   148                          "passed a consistency check (atmfields_checked=1)." );
   149   if( atmgeom_checked != 1 )
   150     throw runtime_error( 
"The atmospheric geometry must be flagged to have "   151                          "passed a consistency check (atmgeom_checked=1)." );
   152   if( cloudbox_checked != 1 )
   153     throw runtime_error( 
"The cloudbox must be flagged to have "   154                          "passed a consistency check (cloudbox_checked=1)." );
   156     throw runtime_error( 
"The cloudbox  must be activated (cloudbox_on=1)." );
   159     throw runtime_error( 
"*mc_min_iter* must be >= 100." );
   161   if( max_time < 0  &&  max_iter < 0  &&  std_err < 0 )
   162     throw runtime_error( 
"At least one of std_err, max_time, and max_iter "   163                          "must be positive." );
   166     throw runtime_error( 
"The option of f_index < 0 is not handled by this "   168   if( f_index >= f_grid.
nelem() )
   169     throw runtime_error( 
"*f_index* is outside the range of *f_grid*." );
   171   if( atmosphere_dim != 3 )
   172     throw runtime_error( 
"Only 3D atmospheres are handled. " );
   174   if( sensor_pos.
ncols() != 3 )
   177       os << 
"Expected number of columns in sensor_pos: 3.\n";
   178       os << 
"Found: " << sensor_pos.
ncols();
   179       throw runtime_error(os.str());
   182   if (! (sensor_los.
ncols() == 2))
   185       os << 
"Expected number of columns in sensor_los: 2.\n";
   186       os << 
"Found: " << sensor_los.
ncols();
   187       throw runtime_error(os.str());
   192   time_t start_time=time(NULL);
   198     { 
findZ11max(Z11maxvector,scat_data_array_mono); }
   199   rng.
seed(mc_seed, verbosity);
   200   Numeric g,temperature,albedo,g_los_csc_theta;
   201   Matrix  A(stokes_dim,stokes_dim), Q(stokes_dim,stokes_dim);
   202   Matrix  evol_op(stokes_dim,stokes_dim), ext_mat_mono(stokes_dim,stokes_dim);
   203   Matrix  q(stokes_dim,stokes_dim), newQ(stokes_dim,stokes_dim);
   204   Matrix  Z(stokes_dim,stokes_dim);
   207   Vector vector1(stokes_dim), abs_vec_mono(stokes_dim), I_i(stokes_dim);
   208   Vector Isum(stokes_dim), Isquaredsum(stokes_dim);
   209   Index termination_flag = 0;
   210   const Numeric f_mono = f_grid[f_index];
   217   mc_iteration_count = 0;
   218   mc_error.
resize(stokes_dim);
   223   Matrix  local_iy(1,stokes_dim), local_surface_emission(1,stokes_dim);
   230   Isum=0.0;Isquaredsum=0.0;
   232   bool    convert_to_rjbt = 
false;
   233   if ( y_unit == 
"RJBT" )
   237       convert_to_rjbt = 
true;
   239   else if ( y_unit == 
"1" )
   240     { std_err_i = std_err; }
   244       os << 
"Invalid value for *y_unit*:" << y_unit <<
".\n"    245          << 
"This method allows only the options \"RJBT\" and \"1\".";
   246       throw runtime_error( os.str() );
   252   bool keepgoing, oksampling; 
   258       mc_iteration_count += 1;
   266       local_rte_pos=sensor_pos(0,
joker);
   272                               ext_mat_mono, rng, local_rte_pos, local_rte_los, 
   273                               pnd_vec, g,ppath_step, termination_flag, 
   274                               inside_cloud, ppath_step_agenda, ppath_lraytrace,
   275                               propmat_clearsky_agenda, stokes_dim, f_mono, 
   276                               p_grid, lat_grid, lon_grid, z_field, refellipsoid,
   277                               z_surface, t_field, vmr_field, 
   278                               cloudbox_limits, pnd_field, scat_data_array_mono, 
   282           mc_points(ppath_step.gp_p[np-1].idx,ppath_step.gp_lat[np-1].idx,
   283                                               ppath_step.gp_lon[np-1].idx) += 1;
   297               mc_iteration_count -= 1;
   298               out0 << 
"WARNING: A rejected path sampling (g=0)!\n(if this"   299                    << 
"happens repeatedly, try to decrease *ppath_lmax*)";
   301           else if( termination_flag == 1 )
   304                                       local_rte_pos, local_rte_los, 
   306               mult( vector1, evol_op, local_iy(0,
joker) );
   307               mult( I_i, Q, vector1 );
   311           else if( termination_flag == 2 )
   316                                             local_surface_rmatrix, 
   318                                             local_rte_pos, local_rte_los, 
   319                                             surface_rtprop_agenda );
   321               if( local_surface_los.
nrows() > 1 )
   323                               "The method handles only specular reflections." );
   326               if( local_surface_los.
nrows() == 0 )
   328                   mult( vector1, evol_op, local_surface_emission(0,
joker) );
   329                   mult( I_i, Q, vector1);
   336                   Numeric R11 = local_surface_rmatrix(0,0,0,0);
   337                   if( rng.
draw() > R11 )
   340                       mult( vector1, evol_op, local_surface_emission(0,
joker) );
   341                       mult( I_i, Q, vector1 );
   348                       local_rte_los = local_surface_los( 0, 
joker );
   357           else if (inside_cloud)
   361               albedo = 1 - abs_vec_mono[0]/ext_mat_mono(0,0);
   364               if( rng.
draw() > albedo )
   368                   Vector emission = abs_vec_mono;
   369                   emission *= planck_value;
   370                   Vector emissioncontri(stokes_dim);
   371                   mult( emissioncontri, evol_op, emission );
   372                   emissioncontri /= (g*(1-albedo)); 
   373                   mult( I_i, Q, emissioncontri );
   379                   Sample_los( new_rte_los, g_los_csc_theta, Z, rng, 
   380                               local_rte_los, scat_data_array_mono, stokes_dim,
   381                               pnd_vec, anyptype30, Z11maxvector, 
   382                               ext_mat_mono(0,0)-abs_vec_mono[0], temperature,
   385                   Z /= g * g_los_csc_theta * albedo;
   387                   mult( 
q, evol_op, Z );
   391                   local_rte_los = new_rte_los;
   399               Vector emission = abs_vec_mono;
   400               emission *= planck_value;
   401               Vector emissioncontri(stokes_dim);
   402               mult( emissioncontri, evol_op, emission );
   404               mult( I_i, Q, emissioncontri );
   413           for( 
Index j=0; j<stokes_dim; j++ )
   415               assert( !isnan(I_i[j]) );
   416               Isquaredsum[j] += I_i[j]*I_i[j];
   419           y /= (
Numeric)mc_iteration_count;
   420           for(
Index j=0; j<stokes_dim; j++) 
   422               mc_error[j] = sqrt( ( Isquaredsum[j] / 
   423                                     (
Numeric)mc_iteration_count - y[j]*y[j] ) / 
   426           if( std_err > 0  &&  mc_iteration_count >= min_iter && 
   427               mc_error[0] < std_err_i )
   429           if( max_time > 0  &&  (
Index)(time(NULL)-start_time) >= max_time )
   431           if( max_iter > 0  &&  mc_iteration_count >= max_iter )
   436   if( convert_to_rjbt )
   438       for(
Index j=0; j<stokes_dim; j++) 
   441           mc_error[j] = 
invrayjean( mc_error[j], f_mono );
   451   mc_seed=(
Index)time(NULL);
 INDEX Index
The type to use for all integer numbers and indices. 
 
void set_pencil_beam(void)
makes the antenna pattern a pencil beam 
 
void MCGeneral(Workspace &ws, Vector &y, Index &mc_iteration_count, Vector &mc_error, Tensor3 &mc_points, const MCAntenna &mc_antenna, const Vector &f_grid, const Index &f_index, const Matrix &sensor_pos, const Matrix &sensor_los, const Index &stokes_dim, const Index &atmosphere_dim, const Agenda &ppath_step_agenda, const Numeric &ppath_lraytrace, const Agenda &iy_space_agenda, const Agenda &surface_rtprop_agenda, const Agenda &propmat_clearsky_agenda, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Tensor3 &z_field, const Vector &refellipsoid, const Matrix &z_surface, const Tensor3 &t_field, const Tensor4 &vmr_field, const Index &cloudbox_on, const ArrayOfIndex &cloudbox_limits, const Tensor4 &pnd_field, const ArrayOfSingleScatteringData &scat_data_array_mono, const Index &atmfields_checked, const Index &atmgeom_checked, const Index &cloudbox_checked, const Index &mc_seed, const String &y_unit, const Numeric &std_err, const Index &max_time, const Index &max_iter, const Index &min_iter, const Verbosity &verbosity)
WORKSPACE METHOD: MCGeneral. 
 
Interpolation classes and functions created for use within Monte Carlo scattering simulations...
 
Declarations having to do with the four output streams. 
 
void set_gaussian(const Numeric &za_sigma, const Numeric &aa_sigma)
makes the antenna pattern a 2D gaussian specified by za and aa standard deviations ...
 
Numeric invrayjean(const Numeric &i, const Numeric &f)
invrayjean 
 
void findZ11max(Vector &Z11maxvector, const ArrayOfSingleScatteringData &scat_data_array_mono)
findZ11max 
 
void draw_los(VectorView &sampled_rte_los, Rng &rng, ConstVectorView bore_sight_los) const
draws a line of sight by sampling the antenna response function 
 
Linear algebra functions. 
 
This file contains basic functions to handle XML data files. 
 
void mc_antennaSetPencilBeam(MCAntenna &mc_antenna, const Verbosity &)
WORKSPACE METHOD: mc_antennaSetPencilBeam. 
 
Index nelem() const
Returns the number of elements. 
 
void mult(VectorView y, const ConstMatrixView &M, const ConstVectorView &x)
Matrix Vector multiplication. 
 
void mc_antennaSetGaussianByFWHM(MCAntenna &mc_antenna, const Numeric &za_fwhm, const Numeric &aa_fwhm, const Verbosity &)
WORKSPACE METHOD: mc_antennaSetGaussianByFWHM. 
 
const Numeric SPEED_OF_LIGHT
 
The implementation for String, the ARTS string class. 
 
Index ncols() const
Returns the number of columns. 
 
The global header file for ARTS. 
 
void Sample_los(VectorView new_rte_los, Numeric &g_los_csc_theta, MatrixView Z, Rng &rng, ConstVectorView rte_los, const ArrayOfSingleScatteringData &scat_data_array_mono, const Index stokes_dim, ConstVectorView pnd_vec, const bool anyptype30, ConstVectorView Z11maxvector, const Numeric Csca, const Numeric rtp_temperature, const Verbosity &verbosity)
Sample_los. 
 
void iy_space_agendaExecute(Workspace &ws, Matrix &iy, const Vector &f_grid, const Vector &rtp_pos, const Vector &rtp_los, const Agenda &input_agenda)
 
Defines the Rng random number generator class. 
 
NUMERIC Numeric
The type to use for all floating point numbers. 
 
const Numeric BOLTZMAN_CONST
 
An Antenna object used by MCGeneral. 
 
Header file for special_interp.cc. 
 
Propagation path structure and functions. 
 
void resize(Index p, Index r, Index c)
Resize function. 
 
Header file for logic.cc. 
 
This can be used to make arrays out of anything. 
 
void mcPathTraceGeneral(Workspace &ws, MatrixView evol_op, Vector &abs_vec_mono, Numeric &temperature, MatrixView ext_mat_mono, Rng &rng, Vector &rte_pos, Vector &rte_los, Vector &pnd_vec, Numeric &g, Ppath &ppath_step, Index &termination_flag, bool &inside_cloud, const Agenda &ppath_step_agenda, const Agenda &propmat_clearsky_agenda, const Index stokes_dim, const Numeric &f_mono, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Tensor3 &z_field, const Vector &refellipsoid, const Matrix &z_surface, const Tensor3 &t_field, const Tensor4 &vmr_field, const Tensor3 &edensity_field, const ArrayOfIndex &cloudbox_limits, const Tensor4 &pnd_field, const ArrayOfSingleScatteringData &scat_data_array_mono, const Verbosity &verbosity)
mcPathTraceGeneral 
 
void MCSetSeedFromTime(Index &mc_seed, const Verbosity &)
WORKSPACE METHOD: MCSetSeedFromTime. 
 
void resize(Index n)
Assignment operator from VectorView. 
 
void mc_antennaSetGaussian(MCAntenna &mc_antenna, const Numeric &za_sigma, const Numeric &aa_sigma, const Verbosity &)
WORKSPACE METHOD: mc_antennaSetGaussian. 
 
Numeric planck(const Numeric &f, const Numeric &t)
planck 
 
Index nbooks() const
Returns the number of books. 
 
bool is_anyptype30(const ArrayOfSingleScatteringData &scat_data_array_mono)
is_anyptype30 
 
void id_mat(MatrixView I)
Identity Matrix. 
 
void seed(unsigned long int n, const Verbosity &verbosity)
 
The structure to describe a propagation path and releated quantities. 
 
void set_gaussian_fwhm(const Numeric &za_fwhm, const Numeric &aa_fwhm)
makes the antenna pattern a 2D gaussian specified by za and aa FWHM 
 
void surface_rtprop_agendaExecute(Workspace &ws, Matrix &surface_emission, Matrix &surface_los, Tensor4 &surface_rmatrix, const Vector &f_grid, const Vector &rtp_pos, const Vector &rtp_los, const Agenda &input_agenda)
 
Index nrows() const
Returns the number of rows. 
 
Declaration of functions in rte.cc.