ReFRACtor
standard_forward_model.cc
Go to the documentation of this file.
2 #include "ostream_pad.h"
3 using namespace FullPhysics;
4 using namespace blitz;
5 
6 #ifdef HAVE_LUA
7 #include "register_lua.h"
9 .def(luabind::constructor <
14  const std::vector<std::vector<boost::shared_ptr<SpectrumEffect> > >& > ())
15 .def("spectral_grid", &StandardForwardModel::spectral_grid)
17 #endif
18 
19 //-----------------------------------------------------------------------
21 //-----------------------------------------------------------------------
22 
25  const boost::shared_ptr<SpectralWindow>& Spectral_window,
27  const boost::shared_ptr<SpectrumSampling>& Spectrum_sampling,
28  const std::vector<std::vector<boost::shared_ptr<SpectrumEffect> > >& Spectrum_effect)
29  : spec_effect(Spectrum_effect), inst(Inst), swin(Spectral_window), rt(Rt), spectrum_sampling_(Spectrum_sampling)
30 {
31  if(spec_effect.size() == 0) {
32  spec_effect.resize(num_channels());
33  }
34 
35  if(num_channels() != (int) spec_effect.size()) {
36  throw Exception("Spectrum effect needs to be the same size as the number of spectrometers");
37  }
38 }
39 
40 // See bass class for description.
42 (int channel_index, bool Skip_jacobian) const
43 {
44  if(!g) {
45  throw Exception ("setup_grid needs to be called before calling radiance");
46  }
47 
48  range_check(channel_index, 0, num_channels());
49  Spectrum highres_spec =
50  rt->reflectance(g->high_resolution_grid(channel_index), channel_index,
51  Skip_jacobian);
52  notify_spectrum_update(highres_spec, "high_res_rt", channel_index);
53 
54  return apply_spectrum_corrections(highres_spec, channel_index);
55 }
56 
57 //-----------------------------------------------------------------------
62 //-----------------------------------------------------------------------
63 
64 Spectrum StandardForwardModel::apply_spectrum_corrections(const Spectrum& highres_spec, int channel_index) const
65 {
66  if(!g) {
67  throw Exception ("setup_grid needs to be called before calling apply_spectrum_corrections");
68  }
69 
70  Spectrum highres_spec_intepolated =
71  g->interpolate_spectrum(highres_spec, channel_index);
72  notify_spectrum_update(highres_spec_intepolated, "high_res_interpolated", channel_index);
73 
74  BOOST_FOREACH(const boost::shared_ptr<SpectrumEffect>& i, spec_effect[channel_index]) {
75  i->apply_effect(highres_spec_intepolated, *g);
76  notify_spectrum_update(highres_spec_intepolated, "high_res_spec_effect_" + i->name(), channel_index);
77  }
78 
79  return inst->apply_instrument_model(highres_spec_intepolated,
80  g->pixel_list(channel_index), channel_index);
81 }
82 
83 void StandardForwardModel::notify_spectrum_update(const Spectrum& updated_spec, const std::string& spec_name, int channel_index) const
84 {
85  if (olist.size() > 0) {
86  const_cast<StandardForwardModel *>(this)->notify_update_do(boost::shared_ptr<NamedSpectrum>(new NamedSpectrum(updated_spec, spec_name, channel_index)));
87  }
88 }
89 
90 void StandardForwardModel::print(std::ostream& Os) const
91 {
92  OstreamPad opad(Os, " ");
93  Os << "StandardForwardModel:\n";
94  Os << " Spectral Window:\n";
95  opad << *swin << "\n";
96  opad.strict_sync();
97  Os << " Spectrum Sampling:\n";
98  opad << *spectrum_sampling_ << "\n";
99  opad.strict_sync();
100  Os << " Instrument:\n";
101  opad << *inst << "\n";
102  opad.strict_sync();
103  Os << " Radiative Transfer:\n";
104  opad << *rt << "\n";
105  opad.strict_sync();
106 
107  for(int i = 0; i < num_channels(); ++i) {
108  Os << " Spectrum Effect[" << i << "]:\n";
109  BOOST_FOREACH(boost::shared_ptr<SpectrumEffect> se, spec_effect[i])
110  opad << *se << "\n";
111  opad.strict_sync();
112  }
113 }
#define range_check(V, Min, Max)
Range check.
Definition: fp_exception.h:140
virtual int num_channels() const
The number of spectral channels associated with forward model.
virtual Spectrum radiance(int channel_index, bool Skip_jacobian=false) const
Spectrum for the given spectral band.
This is a filtering stream that adds a pad to the front of every line written out.
Definition: ostream_pad.h:32
std::list< boost::weak_ptr< Observer< boost::shared_ptr< NamedSpectrum > > > > olist
Definition: observer.h:200
This is the base of the exception hierarchy for Full Physics code.
Definition: fp_exception.h:16
virtual void print(std::ostream &Os) const
#define REGISTER_LUA_DERIVED_CLASS(X, Y)
Definition: register_lua.h:136
Adds name and spec index fields to a Spectrum.
void notify_update_do(const boost::shared_ptr< NamedSpectrum > &Self)
Function to call to notify Observers of a state change.
Definition: observer.h:121
StandardForwardModel(const boost::shared_ptr< Instrument > &Inst, const boost::shared_ptr< SpectralWindow > &Spectral_window, const boost::shared_ptr< RadiativeTransfer > &Rt, const boost::shared_ptr< SpectrumSampling > &Spectrum_sampling, const std::vector< std::vector< boost::shared_ptr< SpectrumEffect > > > &Spectrum_effect=std::vector< std::vector< boost::shared_ptr< SpectrumEffect > > >())
Constructor.
Apply value function to a blitz array.
This is the forward model used form GOSAT/OCO.
This is a full spectrum, which contains a SpectralRange and SpectralDomain.
Definition: spectrum.h:18
The forward model represents the encapsulation of modeling spectra from an atmospheric state then app...
Definition: forward_model.h:14
Spectrum apply_spectrum_corrections(const Spectrum &highres_spec, int channel_index) const
Applies corrections and modeling to modeled spectrum:
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
void notify_spectrum_update(const Spectrum &updated_spec, const std::string &spec_name, int channel_index) const
const boost::shared_ptr< ForwardModelSpectralGrid > & spectral_grid() const

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