13 using namespace blitz;
75 bool do_debug_restoration =
false;
115 return brdf_interface_->brdf_linsup_in().bs_do_kparams_derivs()(kernel_index);
135 const int which_brdf,
136 const bool lambertian_flag,
137 const int n_brdf_parameters,
138 const bool do_factor_wfs,
139 const blitz::Array<bool, 1>& do_params_wfs)
145 bs_which_brdf(kernel_index) = which_brdf;
148 bs_lambertian_flag(kernel_index) = lambertian_flag;
152 bs_n_brdf_parameters(kernel_index) = n_brdf_parameters;
155 bs_do_factor_wfs(kernel_index) = do_factor_wfs;
159 bs_do_params_wfs(kernel_index, Range(0, do_params_wfs.rows()-1)) = do_params_wfs;
168 int surface_type,
const blitz::Array<double, 1>& zen,
bool pure_nadir,
169 bool do_solar,
bool do_thermal)
170 : nstream_(nstream),
nmoment_(nmoment), do_multi_scatt_only_(do_multi_scatt_only), surface_type_(surface_type), pure_nadir_(pure_nadir),
193 throw Exception(
"Lidort Interface not initialized");
201 throw Exception(
"Lidort Interface not initialized");
302 layer_jac_flag =
true;
419 Array<double, 1> lidort_height_grid( fchapman_inputs.
ts_height_grid() );
420 int nlayer = in_height_grid.extent(firstDim) - 1;
421 Range lay_range = Range(0,nlayer);
422 lidort_height_grid(lay_range) = in_height_grid;
459 Range rlev(0, atmosphere_bb.extent(firstDim) - 1);
461 thermal_bb_input(rlev) = atmosphere_bb;
465 const blitz::Array<double, 1>& ssa,
466 const blitz::Array<double, 2>& pf)
const 470 Range rlay(0, od.extent(firstDim) - 1);
471 Range rmom(0, pf.extent(firstDim) - 1);
478 Array<double, 1> deltau( foptical_inputs.ts_deltau_vert_input() );
483 omega(rlay) = where(ssa > 0.999, 0.999999, ssa);
490 Array<double, 2> phasmoms( foptical_inputs.ts_phasmoms_total_input() );
491 phasmoms(rmom, rlay) = where(abs(pf) > 1e-11, pf, 1e-11);
508 bool do_surface_linearization)
const 514 <<
" atmosphere derivatives to be calculated. We are trying to calculate " 525 layer_jac_number = natm_jac;
528 Range ra(Range::all());
529 Range rlay(0, od.
rows() - 1);
530 Range rjac(0, natm_jac - 1);
532 Range rmom(0, pf.
rows() - 1);
533 Range all(Range::all());
546 e <<
"The number of layers you are using exceeds the maximum allowed by\n" 547 <<
"the current build of Lidort. The number requested is " 548 << od.
rows() <<
"\nand the maximum allowed is " 551 <<
"You might try rebuilding with a larger value given to the configure\n" 552 <<
"option --with-lidort-maxlayer=value set to a larger value.\n";
557 e <<
"The number of jacobians you are using exceeds the maximum allowed by\n" 558 <<
"the current build of Lidort. The number requested is " 559 << natm_jac <<
"\nand the maximum allowed is " 562 <<
"This number of jacobians is a function of the number of aerosols\n" 563 <<
"in your state vector, so you can reduce the number of aerosols\n" 565 <<
"You might also try rebuilding with a larger value given to the configure\n" 566 <<
"option --with-lidort-maxatmoswfs=value set to a larger value.\n";
588 l_deltau.transposeSelf(secondDim, firstDim);
589 l_omega.transposeSelf(secondDim, firstDim);
603 firstIndex i1; secondIndex i2;
606 Array<double, 1> ssa_limit(ssa.
rows());
607 ssa_limit = where(ssa.
value() > 0.999, 0.999999, ssa.
value());
608 l_omega = where(ssa_limit(i1) != 0, ssa.
jacobian() / ssa_limit(i1), 0.0);
611 l_phasmoms(rjac, rmom, rlay) = 0.0;
613 blitz::Array<double, 2> pf_in( where(abs(pf.
value()) > 1e-11, pf.
value(), 1e-11) );
617 l_phasmoms(jidx, rmom, rlay) = pf.
jacobian()(rmom, rlay, jidx) / pf_in(rmom, rlay)(i1,i2);
661 Range ra(Range::all());
665 jac_surf.reference( lsoutputs.
ts_surfacewf()(ra, 0, 0, lid_pars.
upidx-1).copy() );
670 jac_atm.reference( lpoutputs.
ts_profilewf()(ra, ra, 0, 0, lid_pars.
upidx-1).copy() );
const boost::shared_ptr< Brdf_Linsup_Masters > brdf_interface() const
void setup_thermal_inputs(double surface_bb, const blitz::Array< double, 1 > atmosphere_bb) const
Set up thermal emission inputs.
const blitz::Array< double, 1 > & ts_height_grid() const
#define range_check(V, Min, Max)
Range check.
const blitz::Array< int, 1 > & ts_layer_vary_number() const
const bool ts_do_brdf_surface() const
const bool ts_do_upwelling() const
static Lidort_Pars & instance()
const blitz::Array< bool, 1 > ts_layer_vary_flag() const
const bool ts_do_double_convtest() const
void set_line_of_sight() const
Set line of sight mode.
virtual int n_kernel_params_wfs() const
const blitz::Array< double, 1 > & ts_beam_szas() const
const blitz::Array< double, 2 > & ts_l_deltau_vert_input() const
const int & ts_n_thermal_coeffs() const
LidortBrdfDriver(int nstream, int nmoment)
Initialize Lidort BRDF interface.
const bool ts_do_sscorr_nadir() const
int number_moment() const
const int & ts_n_user_streams() const
const bool ts_do_deltam_scaling() const
const DoubleWithUnit wgs84_a(6378137.0000, units::m)
Equatorial radius.
int number_stream() const
const boost::shared_ptr< SpurrBrdfDriver > brdf_driver() const
Access to BRDF driver.
const double & ts_lidort_accuracy() const
const blitz::Array< double, 4 > & ts_surfacewf() const
const blitz::Array< double, 5 > & ts_profilewf() const
void clear_linear_inputs() const
Mark that we are not retrieving weighting functions.
const blitz::Array< double, 1 > & ts_user_angles_input() const
void copy_brdf_sup_outputs() const
Copy outputs from BRDF supplement into LIDORT Sup inputs types.
void copy_jacobians(blitz::Array< double, 2 > &jac_atm, blitz::Array< double, 1 > &jac_surf) const
Copy jacobians out of internal xdata structures.
const double & ts_flux_factor() const
boost::shared_ptr< Brdf_Linsup_Masters > brdf_interface_
const bool ts_do_no_azimuth() const
boost::shared_ptr< Lidort_Lps_Masters > lidort_interface_
This is the base of the exception hierarchy for Full Physics code.
const blitz::Array< double, 1 > & bs_beam_szas() const
const bool ts_do_sscorr_outgoing() const
To detect things like divide by zero, we may turn on floating point exceptions.
const int & ts_n_user_relazms() const
const bool ts_do_chapman_function() const
const bool ts_do_fullrad_mode() const
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...
const bool ts_do_profile_linearization() const
const blitz::Array< T, D+1 > jacobian() const
const int & ts_nfinelayers() const
bool do_multi_scatt_only_
const double & ts_surface_bb_input() const
const bool ts_do_surface_linearization() const
const blitz::Array< int, 1 > & bs_n_brdf_parameters() const
LidortRtDriver(int nstream, int nmoment, bool do_multi_scatt_only, int surface_type, const blitz::Array< double, 1 > &zen, bool pure_nadir, bool do_solar=true, bool do_thermal=false)
const blitz::Array< double, 2 > & ts_l_omega_total_input() const
const bool ts_do_solar_sources() const
virtual int n_kernel_factor_wfs() const
virtual int n_brdf_kernels() const
const int & ts_n_surface_wfs() const
const blitz::Array< double, 2 > & bs_brdf_parameters() const
Apply value function to a blitz array.
virtual bool do_kparams_derivs(const int kernel_index) const
const bool ts_do_plane_parallel() const
const blitz::Array< bool, 1 > bs_do_kparams_derivs() const
const bool ts_do_thermal_emission() const
const blitz::Array< T, D > & value() const
const blitz::Array< double, 1 > & bs_brdf_factors() const
const bool ts_do_surface_emission() const
const blitz::Array< double, 3 > & ts_l_phasmoms_total_input() const
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)
const blitz::Array< bool, 1 > bs_lambertian_kernel_flag() const
const int & ts_nbeams() const
const blitz::Array< bool, 1 > bs_do_kernel_factor_wfs() const
const bool ts_do_user_streams() const
void set_plane_parallel() const
Set plane parallel sphericity.
const int & bs_nstreams_brdf() const
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.
double get_intensity() const
Retrieve the intensity value calculated.
const blitz::Array< double, 1 > & bs_user_relazms() const
const int & bs_n_user_relazms() const
void set_plane_parallel_plus_ss_correction() const
Set plane parallel plus single scattering correction.
const bool ts_do_ssfull() const
const int & ts_nmoments_input() const
const double & ts_geometry_specheight() const
const int & bs_nbeams() const
const int maxmoments_input
int number_variable() const
blitz::Array< double, 1 > brdf_factors
void calculate_rt() const
Perform radiative transfer calculation with the values setup by setup_optical_inputs and setup_linear...
const blitz::Array< double, 1 > & bs_user_angles_input() const
const int & ts_n_user_levels() const
void copy_from_sup(Brdf_Sup_Outputs &supp_obj)
void set_pseudo_spherical() const
Set pseudo spherical sphericity.
const blitz::Array< double, 1 > & ts_omega_total_input() const
Abstracts away set up of Radiative Transfer software from Rob Spurr into a simpler common inteface us...
const blitz::Array< int, 1 > & bs_which_brdf() const
virtual void setup_geometry(double sza, double azm, double zen) const
Contains classes to abstract away details in various Spurr Radiative Transfer software.
LIDORT specific BRDF driver implementation.
const int & bs_n_user_streams() const
virtual void calculate_brdf() const
virtual int n_surface_wfs() const
const blitz::Array< bool, 2 > bs_do_kernel_params_wfs() const
const double & ts_earth_radius() const
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 Unit km("km", 1e3 *m)
const int & bs_nstreams() const
double value(const FullPhysics::AutoDerivative< double > &Ad)
virtual bool do_shadow_effect() const
const int & ts_nstreams() const
void copy_from_sup(Brdf_Linsup_Outputs &supp_obj)
const bool ts_do_dnwelling() 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.
boost::shared_ptr< SpurrBrdfDriver > brdf_driver_
Spurr BRDF class interface class to use.
const blitz::Array< double, 1 > & ts_user_relazms() const
blitz::Array< double, 2 > brdf_params
void setup_sphericity(double zen) const
Set up/reset sphericity mode which may be affected by the current zenith viewing angle.
const blitz::Array< double, 1 > & ts_thermal_bb_input() const
void initialize_rt()
Initializes radiative transfer data structures.