ReFRACtor
level_1b_sample_coefficient.cc
Go to the documentation of this file.
2 #include "fe_disable_exception.h"
3 
4 using namespace FullPhysics;
5 using namespace blitz;
6 
7 #ifdef HAVE_LUA
8 
9 // Convenience functions to give us spectral_coefficients in different forms for Lua
10 blitz::Array<double, 2> level_1b_s_coeffs(const Level1bSampleCoefficient& Lev1)
11 {
12  int nparam = Lev1.spectral_coefficient(0).value.rows();
13  blitz::Array<double, 2> res(Lev1.number_spectrometer(), nparam);
14  for(int i = 0; i < res.rows(); ++i)
15  res(i, blitz::Range::all()) = Lev1.spectral_coefficient(i).value;
16  return res;
17 }
18 
19 ArrayWithUnit<double, 2> level_1b_s_coeffs_with_unit(const Level1bSampleCoefficient& Lev1)
20 {
21  int nparam = Lev1.spectral_coefficient(0).value.rows();
23  blitz::Array<double, 2> res(Lev1.number_spectrometer(), nparam);
24  for(int i = 0; i < res.rows(); ++i)
25  res(i, blitz::Range::all()) = Lev1.spectral_coefficient(i).value;
26  return ArrayWithUnit<double,2>(res, units);
27 }
28 
29 
30 #include "register_lua.h"
32 .def("spectral_coefficient", &level_1b_s_coeffs)
33 .def("spectral_coefficient_with_unit", &Level1bSampleCoefficient::spectral_coefficient)
34 .def("spectral_coefficient_with_unit", &level_1b_s_coeffs_with_unit)
36 
37 // typedef to distinguish between copying value or moving value (C++11) push_back prototoypes
38 typedef void(std::vector<boost::shared_ptr<Level1bSampleCoefficient> >::*pbt1)(
39  const std::vector<boost::shared_ptr<Level1bSampleCoefficient> >::value_type&);
40 
42  VectorLevel1bSampleCoefficient)
43 .def(luabind::constructor<>())
44 .def("push_back", ((pbt1) &std::vector<boost::shared_ptr<Level1bSampleCoefficient> >::push_back))
46 
47 #endif
48 
49 double Level1bSampleCoefficient::calculate_sample_value_from_coeffs(int Spec_index, int sample_index) const {
50  ArrayWithUnit<double, 1> spectral_coefficients = this->spectral_coefficient(Spec_index);
51  ArrayAd<double, 1> spectral_coeff_ad = ArrayAd<double, 1>(spectral_coefficients.value);
52  Poly1d spectral_poly = Poly1d(spectral_coeff_ad, false);
53  return spectral_poly(sample_index);
54 }
55 
56 
58  int num_samples = this->radiance(Spec_index).data().rows();
59  int sample_offset = (this->one_based_) ? 1 : 0;
60  Array<double, 1> grid_data = Array<double, 1>(num_samples);
61  for (int sample_index = 0; sample_index < num_samples; sample_index++) {
62  grid_data(sample_index) = this->calculate_sample_value_from_coeffs(Spec_index, sample_index + sample_offset);
63  }
64  ArrayWithUnit<double, 1> sample_grid_data = ArrayWithUnit<double, 1>(grid_data, this->spectral_coefficient(Spec_index).units);
65  SpectralDomain sample_grid = SpectralDomain(sample_grid_data);
66  return sample_grid;
67 }
68 
69 
virtual SpectralDomain sample_grid(int Spec_index) const
Returns the sample grid (ie wavenumber, wavelength, etc) for the corresponding radiance values...
Definition: doxygen.h:52
This is used to wrap the nominal Level 1B file reader.
We frequently have a array of numbers with units associated with them.
virtual ArrayWithUnit< double, 1 > spectral_coefficient(int Spec_index) const =0
Returns coefficients for an equation describing the special domain used to translate radiance value i...
For different instruments, it is more natural to either work with wavenumbers (e.g., GOSAT) or wavelength (e.g., OCO).
STL namespace.
#define REGISTER_LUA_DERIVED_CLASS(X, Y)
Definition: register_lua.h:136
This is used to read a Level 1B file.
Definition: level_1b.h:15
blitz::Array< T, D > value
const Unit sample_index("sample_index", 1.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1)
Apply value function to a blitz array.
#define REGISTER_LUA_CLASS_NAME(X, Y)
Definition: register_lua.h:129
A one-dimensional polynomial class.
void(std::vector< std::string >::* pbt1)(const std::vector< std::string >::value_type &)
Definition: register_lua.cc:52
Libraries such as boost::units allow unit handling where we know the units at compile time...
Definition: unit.h:25
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
def(luabind::constructor< int >()) .def("rows"
const blitz::Array< double, 1 > & data() const
Return data.
virtual int number_spectrometer() const =0
Number of spectrometers.

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