ReFRACtor
dispersion_polynomial.cc
Go to the documentation of this file.
2 #include <boost/lexical_cast.hpp>
3 using namespace FullPhysics;
4 using namespace blitz;
5 
6 #ifdef HAVE_LUA
7 #include "register_lua.h"
8 
10 .def(luabind::constructor<const blitz::Array<double, 1>&,
11  const blitz::Array<bool, 1>&,
12  const std::string&,
13  const std::string&,
14  int, bool>())
16 #endif
17 
18 //-----------------------------------------------------------------------
22 //-----------------------------------------------------------------------
23 
25 (const blitz::Array<double, 1>& Coeff,
26  const blitz::Array<bool, 1>& Used_flag,
27  const Unit& Coeff_unit,
28  const std::string& Band_name,
29  int Number_pixel,
30  bool Is_one_based)
31 : SubStateVectorArray<Dispersion>(Coeff, Used_flag),
32  is_one_based(Is_one_based),
33  coeff_unit(Coeff_unit),
34  band_name_(Band_name),
35  index_array(Number_pixel),
36  spectral_index(Number_pixel)
37 {
38  initialize();
39 }
40 
41 //-----------------------------------------------------------------------
45 //-----------------------------------------------------------------------
46 
48 (const blitz::Array<double, 1>& Coeff,
49  const blitz::Array<bool, 1>& Used_flag,
50  const std::string& Coeff_unit_name,
51  const std::string& Band_name,
52  int Number_pixel, bool Is_one_based)
53 : SubStateVectorArray<Dispersion>(Coeff, Used_flag),
54  is_one_based(Is_one_based),
55  coeff_unit(Coeff_unit_name),
56  band_name_(Band_name),
57  index_array(Number_pixel),
58  spectral_index(Number_pixel)
59 {
60  initialize();
61 }
62 
63 // Initialize class internals
64 void DispersionPolynomial::initialize() {
65  for(int i = 0; i < index_array.rows(); ++i) {
66  index_array(i) = i + (is_one_based ? 1 : 0);
67  spectral_index(i) = i + 1;
68  }
69 }
70 
71 // See base class for description.
73 {
74  std::string res = "Instrument Dispersion " + band_name_;
75  if(i == 0)
76  res += " Offset";
77  else if(i == 1)
78  res += " Scale";
79  else
80  res += " Parm " + boost::lexical_cast<std::string>(i + 1);
81  return res;
82 }
83 
84 // See base class for description.
87 {
88  Poly1d spectral_poly = Poly1d(coeff, false);
89  ArrayAd<double, 1> index_array_ad(index_array, coeff.number_variable());
90  SpectralDomain sample_grid = SpectralDomain(spectral_poly(index_array_ad), spectral_index, coeff_unit);
91  return sample_grid;
92 }
93 
95 {
97  (new DispersionPolynomial(coeff.value(), used_flag, coeff_unit,
98  band_name_, index_array.rows(),
99  is_one_based));
100 }
101 
102 void DispersionPolynomial::print(std::ostream& Os) const
103 {
104  Os << "DispersionPolynomial for band " << band_name_ << "\n"
105  << " 1 based: " << (is_one_based ? "True" : "False") << "\n"
106  << " Coeff: (";
107  for(int i = 0; i < coeff.rows() - 1; ++i)
108  Os << coeff.value()(i) << ", ";
109  Os << coeff.value()(coeff.rows() - 1) << ")\n"
110  << " Retrieve: (";
111  for(int i = 0; i < used_flag.rows() - 1; ++i)
112  Os << (used_flag(i) ? "true" : "false") << ", ";
113  Os << (used_flag(used_flag.rows() - 1) ? "true" : "false") << ")";
114 }
virtual std::string state_vector_name_i(int i) const
Return state vector name for ith entry in coeff.
DispersionPolynomial(const blitz::Array< double, 1 > &Coeff, const blitz::Array< bool, 1 > &Used_flag, const Unit &Coeff_unit, const std::string &Band_name, int Number_pixel, bool Is_one_based)
Constructor.
virtual SpectralDomain pixel_grid() const
Returns as list of grid points for each instrument pixel, and the gradient of the points wrt the stat...
For different instruments, it is more natural to either work with wavenumbers (e.g., GOSAT) or wavelength (e.g., OCO).
virtual void print(std::ostream &Os) const
#define REGISTER_LUA_DERIVED_CLASS(X, Y)
Definition: register_lua.h:136
Apply value function to a blitz array.
A one-dimensional polynomial class.
This is an implementation of Dispersion that uses a polynomial expression to calculate the wavenumber...
Libraries such as boost::units allow unit handling where we know the units at compile time...
Definition: unit.h:25
This class calculates the wavenumber for each pixel in a single band of an Instrument.
Definition: dispersion.h:12
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
virtual boost::shared_ptr< Dispersion > clone() const
Clone an Dispersion object.

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