ReFRACtor
absorber_vmr_fixed_level_output.cc
Go to the documentation of this file.
1 #include <boost/algorithm/string.hpp>
2 
4 #include "fill_value.h"
5 
6 using namespace FullPhysics;
7 using namespace blitz;
8 
9 #ifdef HAVE_LUA
10 #include "register_lua.h"
11 // Lua doesn't know to cast a pointer type of base class to a derived class.
12 // Add a conversion routine.
13 boost::shared_ptr<RegisterOutputBase> abs_vmr_fixed_level_create
16 {
19  (boost::dynamic_pointer_cast<AbsorberVmrFixedLevel>(A), Sv));
20 }
22 .scope
23 [
24  luabind::def("create", &abs_vmr_fixed_level_create)
25 ]
27 #endif
28 
30 public:
34  : absvmr(Absvmr), sv (Sv) {}
35  Array<double, 2> vmr_covariance() const
36  {
37  firstIndex i1; secondIndex i2; thirdIndex i3; fourthIndex i4;
38  ArrayAd<double, 1> p = absvmr->pressure()->pressure_grid().value;
39  Array<AutoDerivative<double>, 1> vmrv_t(p.rows());
40  for(int i = 0; i < p.rows(); ++i)
41  vmrv_t(i) = absvmr->volume_mixing_ratio(p(i));
42  ArrayAd<double, 1> vmrv(vmrv_t);
43  Array<double, 2> res(vmrv.rows(), vmrv.rows());
44  if(vmrv.is_constant())
45  res = 0; // Normal only encounter this in
46  // testing, when we haven't yet set up
47  // a covariance matrix and state vector.
48  else {
49  Array<double, 2> dvmr_dstate(vmrv.jacobian());
50  Array<double, 2> cov(sv->state_covariance());
51  Array<double, 2> t(dvmr_dstate.rows(), cov.cols()) ;
52  t = sum(dvmr_dstate(i1, i3) * cov(i3, i2), i3);
53  res = sum(t(i1, i3) * dvmr_dstate(i2, i3), i3);
54  }
55  return res;
56  }
57  Array<double, 1> vmr_uncertainty() const
58  {
59  Array<double, 2> cov(vmr_covariance());
60  Array<double, 1> res(cov.rows());
61  for(int i = 0; i < res.rows(); ++i)
62  res(i) = (cov(i, i) > 0 ? sqrt(cov(i, i)) : 0.0);
63  return res;
64  }
65 private:
68 };
69 
70 
71 // See base class for description
72 
74 {
75  // Freeze the pressure state
77  boost::dynamic_pointer_cast<AbsorberVmrFixedLevel>(a->clone());
78  std::string gname = a->gas_name();
79  boost::to_lower(gname);
80  out->register_data_source_pad
81  ("/RetrievalResults/" + gname + "_profile_apriori",
83  afreeze, num_level, fill_value<double>());
84 }
85 
87 {
88  std::string gname = a->gas_name();
89  boost::to_lower(gname);
92  out->register_data_source_pad
93  ("/RetrievalResults/" + gname + "_profile",
95  a, num_level, fill_value<double>());
96  out->register_data_source_pad
97  ("/RetrievalResults/" + gname + "_profile_uncert",
98  &AbsorberVmrFixedLevelOutputHelper::vmr_uncertainty, h, num_level, fill_value<double>());
99  out->register_data_source_pad
100  ("/RetrievalResults/" + gname + "_profile_covariance_matrix",
101  &AbsorberVmrFixedLevelOutputHelper::vmr_covariance, h, num_level, fill_value<double>());
102 }
bool is_constant() const
Definition: array_ad.h:371
#define REGISTER_LUA_DERIVED_CLASS(X, Y)
Definition: register_lua.h:136
const blitz::Array< T, D+1 > jacobian() const
Definition: array_ad.h:307
Apply value function to a blitz array.
const Unit A("A", 1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0)
blitz::Array< double, 1 > volume_mixing_ratio_active_level() const
Volume mixing ratio on the fixed pressure levels, restricted to the active levels.
As described in the Output class, we have a decentralized model of producing output for L2 Full Physi...
This class maps the state vector to the absorber VMR on each level.
virtual void register_output_apriori(const boost::shared_ptr< Output > &out) const
Register apriori portions of class.
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"
This registers the portions of the AbsorberVmrFixedLevel class that should be written as output...
virtual void register_output(const boost::shared_ptr< Output > &out) const
Register portions of class that will be written to output.
virtual std::string gas_name() const
This indicates the name of this particular Absorber.
int rows() const
Definition: array_ad.h:368

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