19 int n_user_streams = 1;
23 int nstreams_brdf = 50;
30 nbeams, n_user_streams, nstreams_brdf) );
32 brdf_params.reference( twostream_brdf_->brdf_parameters() );
33 brdf_factors.reference( twostream_brdf_->brdf_factors() );
40 Array<double, 1> beam_szas( twostream_brdf_->beam_szas() );
44 Array<double, 1> user_angles( twostream_brdf_->user_angles() );
50 twostream_brdf_->run();
55 return twostream_brdf_->n_brdf_kernels();
60 twostream_brdf_->n_brdf_kernels(n_kernels);
65 return twostream_brdf_->n_kernel_factor_wfs();
78 return twostream_brdf_->n_kernel_params_wfs();
91 return twostream_brdf_->n_surface_wfs();
104 return twostream_brdf_->do_kparams_derivs()(kernel_index);
118 return twostream_brdf_->do_shadow_effect();
122 twostream_brdf_->do_shadow_effect(do_shadow);
126 const int which_brdf,
127 const bool lambertian_flag,
128 const int n_brdf_parameters,
129 const bool do_factor_wfs,
130 const blitz::Array<bool, 1>& do_params_wfs)
132 Array<int, 1> ts_which_brdf( twostream_brdf_->which_brdf() );
133 ts_which_brdf(kernel_index) = which_brdf;
135 Array<bool, 1> ts_lambertian_flag = twostream_brdf_->lambertian_kernel_flag();
136 ts_lambertian_flag(kernel_index) = lambertian_flag;
137 twostream_brdf_->lambertian_kernel_flag(ts_lambertian_flag);
139 Array<int, 1> ts_n_brdf_parameters( twostream_brdf_->n_brdf_parameters() );
140 ts_n_brdf_parameters(kernel_index) = n_brdf_parameters;
142 Array<bool, 1> ts_do_factor_wfs( twostream_brdf_->do_kernel_factor_wfs() );
143 ts_do_factor_wfs(kernel_index) = do_factor_wfs;
144 twostream_brdf_->do_kernel_factor_wfs(ts_do_factor_wfs);
146 Array<bool, 2> ts_do_params_wfs( twostream_brdf_->do_kernel_params_wfs() );
147 ts_do_params_wfs(kernel_index, Range(0, do_params_wfs.rows()-1)) = do_params_wfs;
148 twostream_brdf_->do_kernel_params_wfs(ts_do_params_wfs);
159 bool do_solar,
bool do_thermal)
160 : surface_type_(surface_type), do_fullquadrature_(do_fullquadrature),
SpurrRtDriver(do_solar, do_thermal)
165 int n_user_streams = 1;
166 int n_user_relazms = 1;
168 int n_geometries = nbeams * n_user_streams * n_user_relazms;
169 int ntotal = 2 * nlayers;
180 nlayers, ntotal, n_user_streams, n_user_relazms, nbeams, earth_radius, n_geometries) );
237 layer_jac_flag =
true;
257 int nlayers = in_height_grid.rows() - 1;
261 throw Exception(
"TwostreamDriver does not support the number of layers changing during the retrieval.");
265 ts_height_grid(Range(0, nlayers)) = in_height_grid;
290 Range rlev(0, atmosphere_bb.extent(firstDim) - 1);
292 thermal_bb_input(rlev) = atmosphere_bb;
299 const blitz::Array<double, 1>& ssa,
300 const blitz::Array<double, 2>& pf)
const 303 Range rlay(0, od.extent(firstDim) - 1);
311 omega(rlay) = where(ssa > 0.999, 0.999999, ssa);
316 asymm_input(rlay) = pf(1, rlay) / 3.0;
322 d2s_scaling(rlay) = pf(2, rlay) / 5.0;
336 bool do_surface_linearization)
const 341 layer_jac_number = natm_jac;
344 Range rlay(0, od.
rows() - 1);
345 Range rjac(0, natm_jac - 1);
346 Range all(Range::all());
362 e <<
"The number of layers you are using exceeds the maximum allowed by\n" 363 <<
"the current build of Lidort. The number requested is " 364 << od.
rows() <<
"\nand the maximum allowed is " 367 <<
"You might try rebuilding with a larger value given to the configure\n" 368 <<
"option --with-lidort-maxlayer=value set to a larger value.\n";
373 e <<
"The number of jacobians you are using exceeds the maximum allowed by\n" 374 <<
"the current build of Lidort. The number requested is " 375 << natm_jac <<
"\nand the maximum allowed is " 378 <<
"This number of jacobians is a function of the number of aerosols\n" 379 <<
"in your state vector, so you can reduce the number of aerosols\n" 381 <<
"You might also try rebuilding with a larger value given to the configure\n" 382 <<
"option --with-lidort-maxatmoswfs=value set to a larger value.\n";
395 l_asymm_input = pf.
jacobian()(1, all, all) / 3.0;
396 l_d2s_scaling = pf.
jacobian()(2, all, all) / 5.0;
405 stringstream err_msg;
406 err_msg <<
"TwostreamInterace input check failed:" << std::endl;
414 stringstream err_msg;
415 err_msg <<
"TwostreamInterace execution failed:" << std::endl
432 Range ra(Range::all());
434 jac_atm.transposeSelf(secondDim, firstDim);
boost::shared_ptr< Twostream_Ls_Brdf_Supplement > brdf_interface() const
const int max_brdf_parameters
void initialize_rt()
Initializes radiative transfer data structures.
virtual int n_kernel_factor_wfs() const
static Lidort_Pars & instance()
virtual void setup_geometry(double sza, double azm, double zen) const
void setup_linear_inputs(const ArrayAd< double, 1 > &od, const ArrayAd< double, 1 > &ssa, const ArrayAd< double, 2 > &pf, bool do_surface_linearization) const
Set up linearization, weighting functions.
const int max_user_streams
boost::shared_ptr< Twostream_Lps_Master > twostream_interface_
TwostreamBrdfDriver(int surface_type)
Initialize Twostream BRDF interface.
const DoubleWithUnit wgs84_a(6378137.0000, units::m)
Equatorial radius.
virtual int n_brdf_kernels() const
void setup_thermal_inputs(double surface_bb, const blitz::Array< double, 1 > atmosphere_bb) const
Set up thermal emission inputs.
TwoStream specific BRDF driver implementation.
This is the base of the exception hierarchy for Full Physics code.
TwostreamRtDriver(int nlayers, int surface_type, bool do_fullquadrature=true, bool do_solar=true, bool do_thermal=false)
TwostreamRtDriver Sizes of layers, and number of jacobians must be set up in construtor as seen in si...
virtual bool do_kparams_derivs(const int kernel_index) const
void clear_linear_inputs() const
Mark that we are not retrieving weighting functions.
const blitz::Array< T, D+1 > jacobian() const
Apply value function to a blitz array.
virtual void initialize_kernel_parameters(const int kernel_index, const int which_brdf, const bool lambertian_flag, const int n_brdf_parameters, const bool do_factor_wfs, const blitz::Array< bool, 1 > &do_params_wfs)
void setup_optical_inputs(const blitz::Array< double, 1 > &od, const blitz::Array< double, 1 > &ssa, const blitz::Array< double, 2 > &pf) const
Set up optical depth, single scattering albedo and phase function Should be called per spectral point...
void copy_jacobians(blitz::Array< double, 2 > &jac_atm, blitz::Array< double, 1 > &jac_surf) const
Copy jacobians out of internal xdata structures.
const int max_user_relazms
int number_variable() const
DoubleWithUnit convert(const Unit &R) const
Convert to the given units.
double get_intensity() const
Retrieve the intensity value calculated.
Abstracts away set up of Radiative Transfer software from Rob Spurr into a simpler common inteface us...
void setup_height_grid(const blitz::Array< double, 1 > &height_grid) const
Setup height grid, should only be called once per instance or if the height grid changes.
Contains classes to abstract away details in various Spurr Radiative Transfer software.
void setup_geometry(double sza, double azm, double zen) const
Setup viewing geometry, should only be called once per instance or if the viewing geometry changes...
const int max_brdf_kernels
virtual int n_kernel_params_wfs() const
virtual void calculate_brdf() const
const Unit km("km", 1e3 *m)
virtual int n_surface_wfs() const
virtual bool do_shadow_effect() const
boost::shared_ptr< SpurrBrdfDriver > brdf_driver_
Spurr BRDF class interface class to use.
void calculate_rt() const
Perform radiative transfer calculation with the values setup by setup_optical_inputs and setup_linear...
const int max_user_obsgeoms
const int maxstreams_brdf