ReFRACtor
high_res_spectrum_output.cc
Go to the documentation of this file.
2 
3 using namespace FullPhysics;
4 using namespace blitz;
5 
6 #ifdef HAVE_LUA
8 #include "lsi_rt.h"
9 
10 boost::shared_ptr<RegisterOutputBase> hr_spec_as_register_output_base(const boost::shared_ptr<HighResSpectrumOutput>& hr_spec) {
11  return boost::dynamic_pointer_cast<RegisterOutputBase>(hr_spec);
12 }
13 
14 void hr_spec_add_as_standard_fm_observer(HighResSpectrumOutput& hr_spec, StandardForwardModel& standard_fm) {
15  standard_fm.add_observer(hr_spec);
16 }
17 
18 void hr_spec_add_as_lsi_rt_observer(HighResSpectrumOutput& hr_spec, LsiRt& rt) {
19  rt.add_observer(hr_spec);
20 }
21 
22 #include "register_lua.h"
24 .def(luabind::constructor<>())
25 .def("as_register_output_base", &hr_spec_as_register_output_base)
26 .def("add_as_observer", &hr_spec_add_as_standard_fm_observer)
27 .def("add_as_observer", &hr_spec_add_as_lsi_rt_observer)
29 #endif
30 
31 const Array<double, 1> HighResSpectrumOutput::saved_spectral_domain(const std::string& spectra_name)
32 {
33  Array<double, 1> res(0);
34  BOOST_FOREACH(const boost::shared_ptr<Spectrum>& s, saved_spectra[spectra_name]) {
35  // Its possible to have empty spectra if a certain index is notified
36  // but not the one before it
37  if(s) {
38  int nrow = s->spectral_domain().data().rows();
39  Range save_range(res.rows(), res.rows() + nrow - 1);
40  res.resizeAndPreserve(res.rows() + nrow);
41  res(save_range) = s->spectral_domain().data();
42  }
43  }
44  return res;
45 }
46 
47 const Array<double, 1> HighResSpectrumOutput::saved_spectral_range(const std::string& spectra_name)
48 {
49  Array<double, 1> res(0);
50  BOOST_FOREACH(const boost::shared_ptr<Spectrum>& s, saved_spectra[spectra_name]) {
51  // Its possible to have empty spectra if a certain index is notified
52  // but not the one before it
53  if(s) {
54  int nrow = s->spectral_range().data().rows();
55  Range save_range(res.rows(), res.rows() + nrow - 1);
56  res.resizeAndPreserve(res.rows() + nrow);
57  res(save_range) = s->spectral_range().data();
58  }
59  }
60  return res;
61 }
62 
63 //-----------------------------------------------------------------------
68 //-----------------------------------------------------------------------
69 
71 {
72  register_named_spectrum(Obs, "grid_", "radiance_");
73 }
74 
75 //-----------------------------------------------------------------------
78 //-----------------------------------------------------------------------
79 
81  BOOST_FOREACH(boost::shared_ptr<NamedSpectrum> named_spec, Obs)
82  register_named_spectrum(named_spec, "", "reflectance_");
83 }
84 
85 void HighResSpectrumOutput::register_named_spectrum(const boost::shared_ptr<FullPhysics::NamedSpectrum>& named_spec,
86  const std::string& domain_prefix, const std::string& range_prefix) {
87  std::vector<boost::shared_ptr<Spectrum> > &name_spec_vec = saved_spectra[named_spec->name()];
88  if ((int) name_spec_vec.size() <= named_spec->index())
89  name_spec_vec.resize(named_spec->index()+1);
90 
91  boost::shared_ptr<Spectrum> spec_copy( new Spectrum(named_spec->spectral_domain().clone(),
92  named_spec->spectral_range().clone()) );
93  name_spec_vec[named_spec->index()] = boost::shared_ptr<Spectrum>(spec_copy);
94 
95  BOOST_FOREACH(boost::shared_ptr<Output> out, output_files) {
96  // Only call registration if output object is still a valid pointer
97  if (out) {
98  boost::function<Array<double, 1>() > f;
99 
100  if (domain_prefix.length() > 0) {
101  f = boost::bind(&HighResSpectrumOutput::saved_spectral_domain, this, named_spec->name());
102  out->register_data_source("/HighResSpectra/" + domain_prefix + named_spec->name(), f);
103  }
104 
105  if (range_prefix.length() > 0) {
106  f = boost::bind(&HighResSpectrumOutput::saved_spectral_range, this, named_spec->name());
107  out->register_data_source("/HighResSpectra/" + range_prefix + named_spec->name(), f);
108  }
109  }
110  }
111 }
const blitz::Array< double, 1 > saved_spectral_domain(const std::string &spectra_name)
const Unit s("s", 1.0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0)
This does a Low Stream Interpolator correction to another RadiativeTransfer object.
Definition: lsi_rt.h:20
virtual void notify_update(const boost::shared_ptr< NamedSpectrum > &Obs)
On notification this class registers a dataset based on the name in the NamedSpectrum.
This class will recieve observer notifications from any class that pushes out NamedSpectrum and write...
virtual void add_observer(Observer< std::vector< boost::shared_ptr< NamedSpectrum > > > &Obs)
Required observable functions.
#define REGISTER_LUA_CLASS(X)
Definition: register_lua.h:116
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
virtual void add_observer(Observer< boost::shared_ptr< NamedSpectrum > > &Obs)
Required observable functions.
const blitz::Array< double, 1 > saved_spectral_range(const std::string &spectra_name)
As described in the Output class, we have a decentralized model of producing output for L2 Full Physi...
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

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