ReFRACtor
register_lua.cc
Go to the documentation of this file.
1 #include "register_lua.h"
2 #include <iostream>
3 #include <sstream>
4 #include "unit.h"
5 
6 using namespace FullPhysics;
7 
8 //-----------------------------------------------------------------------
10 //-----------------------------------------------------------------------
11 
12 std::string string_vector_tostring(const std::vector<std::string>& Vec)
13 {
14  std::ostringstream os;
15  os << "std::vector<std::string>:" << std::endl;
16  for(int i = 0; i < (int) Vec.size(); i++)
17  os << "["<<i<<"] = " << Vec[i] << std::endl;
18  return os.str();
19 }
20 
21 std::string double_vector_tostring(const std::vector<double>& Vec)
22 {
23  std::ostringstream os;
24  os << "std::vector<std::double>:" << std::endl;
25  for(int i = 0; i < (int) Vec.size(); i++)
26  os << "["<<i<<"] = " << Vec[i] << std::endl;
27  return os.str();
28 }
29 
30 std::string int_vector_tostring(const std::vector<int>& Vec)
31 {
32  std::ostringstream os;
33  os << "std::vector<std::int>:" << std::endl;
34  for(int i = 0; i < (int) Vec.size(); i++)
35  os << "["<<i<<"] = " << Vec[i] << std::endl;
36  return os.str();
37 }
38 
39 std::string string_value(const std::vector<std::string>& Vec, int index) {
40  return Vec.at(index);
41 }
42 
43 double double_value(const std::vector<double>& Vec, int index) {
44  return Vec.at(index);
45 }
46 
47 int int_value(const std::vector<int>& Vec, int index) {
48  return Vec.at(index);
49 }
50 
51 // typedef to distinguish between copying value or moving value (C++11) push_back prototoypes
52 typedef void(std::vector<std::string>::*pbt1)(const std::vector<std::string>::value_type&);
53 typedef void(std::vector<double>::*pbt2)(const std::vector<double>::value_type&);
54 typedef void(std::vector<int>::*pbt3)(const std::vector<int>::value_type&);
55 
56 REGISTER_LUA_CLASS_NAME(std::vector<std::string>, VectorString)
57 .def(luabind::constructor<>())
58 .def("size", &std::vector<std::string>::size)
59 .def("push_back", ((pbt1) &std::vector<std::string>::push_back))
60 .def("value", &string_value)
61 .def("__tostring", &string_vector_tostring)
63 
64 REGISTER_LUA_CLASS_NAME(std::vector<double>, VectorDouble)
65 .def(luabind::constructor<>())
66 .def("size", &std::vector<double>::size)
67 .def("push_back", ((pbt2) &std::vector<double>::push_back))
69 .def("__tostring", &double_vector_tostring)
71 
72 REGISTER_LUA_CLASS_NAME(std::vector<int>, VectorInt)
73 .def(luabind::constructor<>())
74 .def("size", &std::vector<int>::size)
75 .def("push_back", ((pbt3) &std::vector<int>::push_back))
76 .def("value", &int_value)
77 .def("__tostring", &int_vector_tostring)
79 
80 //-----------------------------------------------------------------------
83 //-----------------------------------------------------------------------
84 
86 .def(luabind::constructor<const std::string&>())
87 .property("name",
88  (const std::string&(Unit::*)() const) &Unit::name,
89  (void(Unit::*)(const std::string&)) &Unit::name)
90 .def("conversion_to_si", &Unit::conversion_to_si)
91 .def("is_commensurate", &Unit::is_commensurate)
93 
94 //-----------------------------------------------------------------------
97 //-----------------------------------------------------------------------
98 
99 int RegisterLua::add_file_and_line(lua_State* L)
100 {
101  lua_Debug d;
102  lua_getstack(L, 1, &d);
103  lua_getinfo(L, "Sln", &d);
104  std::string err = lua_tostring(L, -1);
105  lua_pop(L, 1);
106  std::stringstream msg;
107  msg << d.short_src << ":" << d.currentline;
108 
109  if (d.name != 0)
110  {
111  msg << "(" << d.namewhat << " " << d.name << ")";
112  }
113  msg << " " << err;
114  lua_pushstring(L, msg.str().c_str());
115  return 1;
116 }
117 
118 namespace FullPhysics {
119 void RegisterLua::register_lua(lua_State* ls)
120 {
121  // There order is not important here, *except* that you need to make
122  // sure that if the Lua interface for class B refers to class A
123  // (e.g., is derived from it, has a function listed for Lua that
124  // uses A), then B appears after A in the list.
126  REGISTER_LUA_LIST(Range);
127  REGISTER_LUA_LIST(Blitz_double_array_1d);
128  REGISTER_LUA_LIST(Blitz_double_array_2d);
129  REGISTER_LUA_LIST(Blitz_double_array_3d);
130  REGISTER_LUA_LIST(Blitz_double_array_4d);
131  REGISTER_LUA_LIST(Blitz_double_array_5d);
132  REGISTER_LUA_LIST(Blitz_int_array_1d);
133  REGISTER_LUA_LIST(Blitz_int_array_2d);
134  REGISTER_LUA_LIST(Blitz_int_array_3d);
135  REGISTER_LUA_LIST(Blitz_bool_array_1d);
136  REGISTER_LUA_LIST(Blitz_bool_array_2d);
137  REGISTER_LUA_LIST(Blitz_bool_array_3d);
138  REGISTER_LUA_LIST(VectorString);
139  REGISTER_LUA_LIST(VectorDouble);
140  REGISTER_LUA_LIST(VectorInt);
145  REGISTER_LUA_LIST(OldConstant);
148  REGISTER_LUA_LIST(ArrayWithUnit_1d);
149  REGISTER_LUA_LIST(ArrayWithUnit_2d);
150  REGISTER_LUA_LIST(ArrayWithUnit_3d);
158  REGISTER_LUA_LIST(VectorAerosolProperty);
160  REGISTER_LUA_LIST(VectorAerosolExtinction);
165  REGISTER_LUA_LIST(VectorAltitude);
167  REGISTER_LUA_LIST(VectorAbsorberVmr);
169  REGISTER_LUA_LIST(VectorGasAbsorption);
177  REGISTER_LUA_LIST(VectorLevel1b);
178  REGISTER_LUA_LIST(VectorLevel1bSampleCoefficient);
180  REGISTER_LUA_LIST(VectorIls);
184  REGISTER_LUA_LIST(VectorInstrumentCorrection);
185  REGISTER_LUA_LIST(VectorVectorInstrumentCorrection);
187  REGISTER_LUA_LIST(VectorSpectrumEffect);
188  REGISTER_LUA_LIST(VectorVectorSpectrumEffect);
192  REGISTER_LUA_LIST(VectorDispersion);
212  REGISTER_LUA_LIST(VectorRegisterOutput);
320  //Disabled due to conflict with newer GSL versions
321  //REGISTER_LUA_LIST(NLLSSolverGSL);
322  //REGISTER_LUA_LIST(NLLSSolverGSLLMDER);
323  //REGISTER_LUA_LIST(NLLSSolverGSLLMSDER);
337 }
338 }
339 
340 extern "C" {
341  int luaopen_librefractor(lua_State* ls)
342  {
343  luabind::open(ls);
345  luabind::set_pcall_callback(RegisterLua::add_file_and_line);
346  return 1;
347  }
348 }
This class is used to read the absco tables.
Definition: absco.h:56
This class handles the solar Doppler stretch to calculate the shift of the solar lines with respect t...
The base class for all iterative optimizers that use first order derivatives.
This gives the Aerosol properties for an Aerosol.
This registers the portions of the GroundCoxmunkPlusLambertian class that should be written as output...
This class implements a Coxmunk plus Lambertian ground type.
This class maintains the absorber portion of the state.
This generates a spectrum sampling that covers all the high resolution points needed to create the sp...
std::string string_value(const std::vector< std::string > &Vec, int index)
Definition: register_lua.cc:39
This does a Low Stream Interpolator correction to another RadiativeTransfer object.
Definition: lsi_rt.h:20
This class calculates the solar continuum spectrum.
Defines the interface for supplying meteorological data.
Definition: meteorology.h:14
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.
The class handles the calculation of the altitude and gravity constants.
Definition: altitude.h:19
This class will recieve observer notifications from any class that pushes out NamedSpectrum and write...
This is a ILS where we use a Dispersion object to determine the wavenumbers of each pixel...
This is an observer of the ConnorSolver that writes out the state vector values in a nicely formated ...
This class maps the state vector to the aerosol extinction on each level.
This class maintains the temperature portion of the state.
As a design principle, we have each base class with the absolutely minimum interface needed for use f...
This class implements a Lambertian albedo as a ground type.
The base class for the solvers of the Nonlinear-Least-Squares Problem.
Definition: nlls_solver.h:24
This class maps the state vector to the absorber VMR on each level.
This class maintains the stokes coefficient portion of the state.
Implements a fitted radiance scaling correction.
This class is used to create the Aerosol from a Merra climatology file.
Definition: merra_aerosol.h:15
This class is an implementation of Constant that uses hard coded values suitable for Earth...
This applies a solar model to reflectance to model the incoming solar irradiance. ...
Definition: solar_model.h:15
The base class for all problem classes that implement a cost function.
Definition: cost_func.h:20
This registers the portions of the RadianceScaling class that should be written as output...
This registers the portions of the AbsorberVmrLevelScaled class that should be written as output...
For different instruments, it is more natural to either work with wavenumbers (e.g., GOSAT) or wavelength (e.g., OCO).
int luaopen_librefractor(lua_State *ls)
Corrects Spectrum spectral domain to account for the doppler shift due to the relative velocity betwe...
Given a single frame of data, estimate the spectral shift in band 1P.
This class handles the calculation of the altitude an gravity constants, automatically updating with ...
static void register_lua(lua_State *ls)
This class maintains the stokes coefficient portion of the state.
This is a instrument that uses a Ils object for each spectrometer to model the instrument.
This is the Forward Model spectral grid.
This gives the Aerosol properties for an Aerosol.
This registers the portions of the ConnorSolver class that should be written as output.
The base class for all iterative cost minimizers that do not require derivatives of any order...
STL namespace.
This registers the coefficients used for classes that inherits from AerosolExtinctionBaseImp.
This registers the portions of the AbsorberVmrFixedLevel class that should be written as output...
This class drives the LRAD code, which gives a polarization correction to scalar intensity and jacobi...
Definition: l_rad_rt.h:19
Implements adding the effect of fluorescence to A-Band spectrum by using a retrievable across the ban...
This class calculates the solar absorption spectrum.
This class maintains the pressure portion of the state.
This class applies a empirical orthogonal function (EOF) correction to instrument data...
This class models an Instrument Line Shape (ILS) function.
Definition: ils_function.h:17
This class handles the registration of luabind class wrappers with Lua.
Definition: register_lua.h:105
This class calculates the solar absorption spectrum.
The base class for maximum likelihood estimation.
A common way to create an initial guess is to have other classes responsible for portions of the stat...
This registers the portions of the FluorescenceEffect class that should be written as output...
This class maintains the ground portion of the state.
Definition: ground.h:22
Writes source filenames into the output file.
This registers the portions of the Absorber class that should be written as output.
This is used to read a Level 1B file.
Definition: level_1b.h:15
This registers the portions of the TemperatureLevelOffset class that should be written as output...
int int_value(const std::vector< int > &Vec, int index)
Definition: register_lua.cc:47
std::string string_vector_tostring(const std::vector< std::string > &Vec)
Here are some registrations that do not really belong anywhere else.
Definition: register_lua.cc:12
This registers the portions of the DispersionPolynomial class that should be written as output...
This registers the portions of the GroundLambertian class that should be written as output...
The actual implementation of the Logger.
Definition: logger.h:11
This class reads and writes a HDF5 file.
Definition: hdf_file.h:39
#define REGISTER_LUA_CLASS(X)
Definition: register_lua.h:116
This class maintains the temperature portion of the state.
void(std::vector< double >::* pbt2)(const std::vector< double >::value_type &)
Definition: register_lua.cc:53
Adapts the ReferenceVmrApriori class into a form that is easier to work with in the context of how th...
This class maps the state vector to the aerosol extinction on each level.
This class models models any effects that need to be applied to high resolution spectra after the rad...
This class maps the state vector to the absorber VMR on each level.
This class maintains the aerosol portion of the state.
Definition: aerosol.h:24
#define REGISTER_LUA_CLASS_NAME(X, Y)
Definition: register_lua.h:129
This is the forward model used form GOSAT/OCO.
Implements a fitted radiance scaling correction where the correction is determined by a linear fit of...
This is a simple object to call a callback that can be used in Lua.
Definition: lua_callback.h:11
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
This class contains various constants.
Definition: constant.h:11
Writes source filenames into the output file.
This class handles the solar Doppler stretch to calculate the shift of the solar lines with respect t...
This registers the portions of the Aerosol class that should be written as output.
This class tests for convergence of a Levenberg-Marquardt solver.
This is a full spectrum, which contains a SpectralRange and SpectralDomain.
Definition: spectrum.h:18
This is an implementation of a SpectralWindow that covers a fixed window.
Uses the Spurr interfaces to construct a radiative transfer class connecting L2 FP and LIDORT 3...
Definition: lidort_rt.h:13
This registers the portions of the Pressure class that should be written as output.
This registers the portions of the AbsorberVmrLevel class that should be written as output...
The base class for maximum a posteriori estimation.
Class that builds a portion of the state vector.
This gives the upper and lower bounds of the SpectralWindow.
This registers the portions of the MaxAPosteriori class that should be written as output...
std::string int_vector_tostring(const std::vector< int > &Vec)
Definition: register_lua.cc:30
This class implements and example Meteorological reader that reads data from an HDF file with dataset...
This is a simple implementation of InitialGuessBuilder that just has variables used to give the aprio...
This class maps the state vector to aerosol extinction defined by a Gaussian parameterization.
This calculates the relative humidity.
The forward model represents the encapsulation of modeling spectra from an atmospheric state then app...
Definition: forward_model.h:14
Implementation of Aerosol.
void(std::vector< int >::* pbt3)(const std::vector< int >::value_type &)
Definition: register_lua.cc:54
This class maintains the temperature portion of the state.
This registers the portions of the StateVector class that should be written as output.
This determines the sampling of the spectrum that should be used for each of the spectrum indexes...
This registers the portions of the ConnorConvergence class that should be written as output...
Interface for calculating noise/uncertainty values from radiance data given some internal representat...
Definition: noise_model.h:13
This class tests for convergence of a Levenberg-Marquardt solver.
This class calculates a cost function, along with a jacobian.
Definition: cost_function.h:10
This class maps the state vector to the absorber VMR on each level.
This class maintains the stokes coefficient portion of the state.
We frequently have a double with units associated with it.
This registers the portions of the ForwardModel class that should be written as output.
This class represents a the spectral window.
This registers the portions of the Aerosol class that should be written as output.
The base class for the Non-Linear Least Squares problem.
Definition: nlls_problem.h:54
The base class for all problem classes that implement a cost function and its gradient.
This handles informing a set of interested objects when the state vector has updated.
Definition: state_vector.h:16
As described in the Output class, we have a decentralized model of producing output for L2 Full Physi...
This registers the portions of the AbsorberVmrMet class that should be written as output...
void(std::vector< std::string >::* pbt1)(const std::vector< std::string >::value_type &)
Definition: register_lua.cc:52
We have a number of different spectrums that appear in different parts of the code.
This class maps the state vector to the absorber VMR on each level.
When we have bad samples, we usually pass this to the spectral window to prevent the sample from even...
This gives the Gas Absorber Volumn mixing ratio for a single gas.
Definition: absorber_vmr.h:17
This class maps the state vector to the absorber VMR on each level.
This applies a solar model to radiances to model the incoming solar irradiance.
This class maintains the pressure portion of the state.
Definition: pressure.h:32
This is an implementation of Dispersion that uses a polynomial expression to calculate the wavenumber...
This class models an Instrument Line Shape (ILS).
Definition: ils.h:13
Uses the Spurr interfaces to construct a radiative transfer class connecting L2 FP and TwoStream...
Definition: twostream_rt.h:13
This is an example L1B reader that reads a HDF formatted file that corresponds one-to-one with the ex...
This registers the portions of the ErrorAnalysis class that should be written as output.
This class in a IlsFunction where we get the ILS response by using a table of measured values...
Definition: ils_table.h:34
This solves a nonlinear least squares problem using Levenberg-Marquardt.
This class determine the gaseous absorption coefficient for a given wave number, temperature and pres...
This gives the Aerosol properties for an Aerosol.
Libraries such as boost::units allow unit handling where we know the units at compile time...
Definition: unit.h:25
This is a simple logger.
Definition: logger.h:69
This registers the portions of the StokesCoefficientFraction class that should be written as output...
This registers the portions of the DispersionFit class that should be written as output.
This class calculates the wavenumber for each pixel in a single band of an Instrument.
Definition: dispersion.h:12
static int add_file_and_line(lua_State *ls)
double double_value(const std::vector< double > &Vec, int index)
Definition: register_lua.cc:43
This registers the portions of the StandardForwardModel class that should be written as output...
This registers the portions of the Altitude class that should be written as output.
In a retrieval, there are typically two different pressure levels of interest.
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
#define REGISTER_LUA_END()
Definition: register_lua.h:134
This class maintains the pressure portion of the state.
This class handles the solar Doppler stretch to calculate the shift of the solar lines with respect t...
This reads averages a set of Level1b classes to get the various values.
The base class for all iterative optimizers.
This registers the portions of the AbsorberVmrFixedLevel class that should be written as output...
This class calculates the solar absorption spectrum.
This registers the portions of the GroundCoxmunk class that should be written as output.
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 atmosphere portion of the state, and uses this to set up the atmosphere and ...
This class maintains the absorber portion of the state.
Definition: absorber.h:27
def(luabind::constructor<>()) .def("size"
This class maintains the temperature portion of the state.
Definition: temperature.h:22
This registers the portions of the GasVmrApriori class that should be written as output.
For timing purposes, it can be useful to separate out the high resolution radiative transfer vs...
Definition: hres_wrapper.h:19
This registers the portions of the TemperatureMet class that should be written as output...
This registers the portions of the EmpiricalOrthogonalFunction class that should be written as output...
This class is used to read the absco tables.
Definition: absco_hdf.h:20
This class implements a Coxmunk ground type.
#define REGISTER_LUA_LIST(X)
Definition: register_lua.h:112
This registers the portions of the TemperatureFixedLevel class that should be written as output...
This registers the portions of the PressureFixedLevel class that should be written as output...
double value(const FullPhysics::AutoDerivative< double > &Ad)
Scales the measured radiance of another Level1b class for each spectral band.
This is the implementation of the Logger used for the Full Physics program.
Definition: fp_logger.h:12
This class maps the state vector to the aerosol extinction on each level.
This class calculates the solar continuum spectrum.
This is a simple SpectrumSampling that is just a nonuniform sampling.
This class models an Instrument correction.
This registers the portions of the GroundBrdf class that should be written as output.
std::string double_vector_tostring(const std::vector< double > &Vec)
Definition: register_lua.cc:21

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