ReFRACtor
double_with_unit.cc
Go to the documentation of this file.
1 #include "double_with_unit.h"
2 #include "spectral_domain.h"
3 
4 using namespace FullPhysics;
5 
6 #ifdef HAVE_LUA
7 #include "register_lua.h"
8 
9 std::string double_with_unit_unit_get(const DoubleWithUnit& V)
10 {
11  return V.units.name();
12 }
13 
14 void double_with_unit_unit_set(DoubleWithUnit& V, std::string& Unit_name)
15 {
16  V.units = Unit(Unit_name);
17 }
18 
20 .def(luabind::constructor<double, const std::string&>())
21 .def_readwrite("value", &DoubleWithUnit::value)
22 .property("units",
23  &double_with_unit_unit_get,
24  &double_with_unit_unit_set)
26 #endif
27 
28 //-----------------------------------------------------------------------
31 //-----------------------------------------------------------------------
32 
34 (const Unit& R,
35  const SpectralDomain& Pixel_grid) const
36 {
37  if(units.is_commensurate(units::sample_index)) {
38  int ind = (int) round(value) - 1;
39  range_check(ind, 0, Pixel_grid.data().rows());
40  DoubleWithUnit d(Pixel_grid.data()(ind), Pixel_grid.units());
41  return d.convert_wave(R);
42  } else {
43  return convert_wave(R);
44  }
45 }
#define range_check(V, Min, Max)
Range check.
Definition: fp_exception.h:140
DoubleWithUnit convert_wave(const Unit &R) const
We often need to handle conversion from wavenumber to/from wavelength.
For different instruments, it is more natural to either work with wavenumbers (e.g., GOSAT) or wavelength (e.g., OCO).
const Unit sample_index("sample_index", 1.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1)
#define REGISTER_LUA_CLASS(X)
Definition: register_lua.h:116
We frequently have a double with units associated with it.
Libraries such as boost::units allow unit handling where we know the units at compile time...
Definition: unit.h:25
const Unit units() const
Units that go with data()
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
const std::string & name() const
Name of unit. May be an empty string if a name wasn&#39;t assigned.
Definition: unit.h:77
double value(const FullPhysics::AutoDerivative< double > &Ad)
const blitz::Array< double, 1 > & data() const
Return data.

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