ReFRACtor
configuration_fixture.cc
Go to the documentation of this file.
2 #include <fenv.h>
3 
4 using namespace FullPhysics;
5 using namespace blitz;
6 
7 std::map<std::string, boost::shared_ptr<LuaState> > ConfigurationFixture::config;
8 ConfigurationFixture::ConfigurationFixture(const std::string& Config_file)
9 {
10  if(!config[Config_file]) {
11  // Disable floating point exeptions while loading
12  // Lua configuration due to the way Lua parses certain
13  // things.
14 
15  // Mac doesn't have this function, even though it is a C99
16  // function. We check for this during configuration.
17 #ifdef HAVE_FEENABLEEXCEPT
18  fedisableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
19 #endif
20  config[Config_file] = LuaState::load_file(test_data_dir() + "/lua/" + Config_file);
21 #ifdef HAVE_FEENABLEEXCEPT
22  feclearexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
23  feenableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
24 #endif
25  }
26 
27  lua_config = config[Config_file]->globals()["config"];
28 
29  config_absorber = lua_config["absorber"].value_ptr<Absorber>();
30  // Allow this to fail, we don't have aerosols if we happen to have a
31  // Rayleigh only atmosphere
32  try {
33  config_aerosol = lua_config["aerosol"].value_ptr<Aerosol>();
34  } catch(const std::exception& e) {
35  ;
36  }
37  config_atmosphere = lua_config["atmosphere"].value_ptr<RtAtmosphere>();
38  config_state_vector = lua_config["state_vector"].value_ptr<StateVector>();
39  if (!lua_config["pinp"].is_nil()) // Not all configs use this
40  config_pressure_level_input =
41  lua_config["pinp"].value_ptr<PressureLevelInput>();
42  config_pressure = lua_config["pressure"].value_ptr<Pressure>();
43  config_register_output =
44  lua_config["register_output"].
45  value<std::vector<boost::shared_ptr<RegisterOutputBase> > >();
46  config_instrument = lua_config["instrument"].value_ptr<Instrument>();
47  config_spectral_window = lua_config["spec_win"].value_ptr<SpectralWindow>();
48  config_initial_guess =
49  lua_config["initial_guess"].value_ptr<InitialGuess>();
50  config_solver = lua_config["conn_solver"].value_ptr<ConnorSolver>();
51  // Allow this to fail, we don't have ground if we happen to be looking
52  // up.
53  try {
54  config_ground = lua_config["ground"].value_ptr<Ground>();
55  } catch(const std::exception& e) {
56  ;
57  }
58  config_temperature = lua_config["temperature"].value_ptr<Temperature>();
59  config_spectrum_sampling =
60  lua_config["spec_samp"].value_ptr<SpectrumSampling>();
61  config_error_analysis =
62  lua_config["error_analysis"].value_ptr<ErrorAnalysis>();
63  config_level_1b = lua_config["l1b"].value_ptr<Level1bSampleCoefficient>();
64  config_rt = lua_config["rt"].value_ptr<RadiativeTransfer>();
65  config_forward_model = lua_config["forward_model"].value_ptr<ForwardModel>();
66  config_observation = lua_config["observation"].value_ptr<Observation>();
67  sv_initial.reference(config_initial_guess->initial_guess());
68  config_state_vector->update_state(sv_initial);
69 
70  epsilon.resize(config_state_vector->observer_claimed_size());
71  epsilon = 1e-6; // Default
72  epsilon(Range(0, 19)) = 1e-7; // CO2 VMR
73  epsilon(21) = 1e-3; // Surface Pressure
74  epsilon(22) = 1e-4; // Temperature
75 
76  epsilon(Range(23, 34)) = 1e-8; // Aerosol
77 
78  // For debugging epsilon values
79  if (false) {
80  for (int i=0 ; i < config_state_vector->observer_claimed_size(); i++) {
81  std::cerr << i << ": " << config_state_vector->state_vector_name()(i) << " val = " << config_state_vector->state()(i) << ", epsilon = " << epsilon(i) << std::endl;
82  }
83  }
84 
85 }
86 
88  : ConfigurationFixture(Config_file)
89 {
90  // Shrink array from base constructor less elements but first many should be the same
91  epsilon.resizeAndPreserve(110);
92 }
93 
There are a number of tests that need to use a standard set of objects, similar to what we generate w...
This class is responsible for setting up the atmosphere and ground information needed to run the Radi...
Definition: rt_atmosphere.h:51
This is used to wrap the nominal Level 1B file reader.
ConfigurationCoxmunkFixture(const std::string &Config_file="config_coxmunk.lua")
blitz::Array< double, 1 > epsilon
This is an epsilon that can be used to generate finite difference Jacobians for unit tests...
This class maintains the ground portion of the state.
Definition: ground.h:22
Apply value function to a blitz array.
This class maintains the aerosol portion of the state.
Definition: aerosol.h:24
This runs a Radiative Transfer code to determine the reflectance for a given set of wavelengths...
This applies a instrument model to radiances.
Definition: instrument.h:17
The forward model represents the encapsulation of modeling spectra from an atmospheric state then app...
Definition: forward_model.h:14
This determines the sampling of the spectrum that should be used for each of the spectrum indexes...
This class represents a the spectral window.
This handles informing a set of interested objects when the state vector has updated.
Definition: state_vector.h:16
This class maintains the pressure portion of the state.
Definition: pressure.h:32
ConfigurationFixture(const std::string &Config_file="config.lua")
virtual void state_vector_name(const StateVector &Sv, blitz::Array< std::string, 1 > &Sv_name) const
Update any portion of the list of the state vector names that apply to this object.
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
This calculates a variety of values to help with the error analysis of a Level 2 Full Physics Run...
This gets the initial guess and the apriori state vector values.
Definition: initial_guess.h:12
This class maintains the absorber portion of the state.
Definition: absorber.h:27
This class maintains the temperature portion of the state.
Definition: temperature.h:22
static boost::shared_ptr< LuaState > load_file(const std::string &Fname)
Create a new LuaState, and then open the given file.
Definition: lua_state.cc:39

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:08