ReFRACtor
absorber_vmr_fixed_level.cc
Go to the documentation of this file.
1 #include <boost/bind.hpp>
3 #include "ostream_pad.h"
4 #include "linear_interpolate.h"
5 using namespace FullPhysics;
6 using namespace blitz;
7 
8 #ifdef HAVE_LUA
9 #include "register_lua.h"
11 .def(luabind::constructor<const boost::shared_ptr<Pressure>&,
13  const blitz::Array<bool, 1>&,
14  const blitz::Array<double, 1>&,
15  const std::string&>())
17 #endif
18 
19 //-----------------------------------------------------------------------
21 //-----------------------------------------------------------------------
22 
25  const boost::shared_ptr<PressureLevelInput>& Press_level,
26  const blitz::Array<bool, 1>& Used_flag,
27  const blitz::Array<double, 1>& Vmr,
28  const std::string& Gas_name)
29 : AbsorberVmrImpBase(Gas_name, Vmr, Used_flag, Press),
30  press_level(Press_level)
31 {
32 }
33 
35 {
36  boost::shared_ptr<Pressure> pressure_clone = press->clone();
37  return clone(pressure_clone);
38 }
39 
41 (const boost::shared_ptr<Pressure>& Press) const
42 {
44  (new AbsorberVmrFixedLevel(Press, press_level, used_flag, coeff.value(),
45  gas_name()));
46 }
47 
49 {
50  AutoDerivative<double> p = log(press->surface_pressure().value);
51  std::vector<AutoDerivative<double> > plist;
52  std::vector<AutoDerivative<double> > vmrlist;
53  for(int i = 0; i < press->pressure_grid().rows() - 1; ++i) {
54  vmrlist.push_back(coeff(i));
55  plist.push_back(press->pressure_grid()(i).value);
56  }
57  int i = press->pressure_grid().rows() - 1;
58  double p1 = log(press_level->pressure_level()(i - 1));
59  double p2 = log(press_level->pressure_level()(i));
60  AutoDerivative<double> v = coeff(i - 1) +
61  (p - p1) * (coeff(i) - coeff(i - 1)) / (p2 - p1);
62  plist.push_back(press->surface_pressure().value);
63  vmrlist.push_back(v);
65  lin_type;
67  (new lin_type(plist.begin(), plist.end(), vmrlist.begin()));
68  vmr = boost::bind(&lin_type::operator(), lin, _1);
69 }
70 
71 void AbsorberVmrFixedLevel::print(std::ostream& Os) const
72 {
73  OstreamPad opad(Os, " ");
74  Os << "AbsorberVmrFixedLevel:\n"
75  << " Gas name: " << gas_name() << "\n"
76  << " Coefficient:\n";
77  opad << coeff.value() << "\n";
78  opad.strict_sync();
79  Os << " Retrieval Flag:\n";
80  opad << used_flag << "\n";
81  opad.strict_sync();
82 }
This is a filtering stream that adds a pad to the front of every line written out.
Definition: ostream_pad.h:32
This class takes a set of points and values, and linearly interpolates between those values...
#define REGISTER_LUA_DERIVED_CLASS(X, Y)
Definition: register_lua.h:136
As a design principle, we have each base class with the absolutely minimum interface needed for use f...
AbsorberVmrFixedLevel(const boost::shared_ptr< Pressure > &Press, const boost::shared_ptr< PressureLevelInput > &Press_level, const blitz::Array< bool, 1 > &Used_flag, const blitz::Array< double, 1 > &Vmr, const std::string &Gas_name)
Constructor.
Apply value function to a blitz array.
virtual boost::shared_ptr< AbsorberVmr > clone() const
Clone a AbsorberVmr object.
virtual void print(std::ostream &Os) const
Print to stream.
This gives the Gas Absorber Volumn mixing ratio for a single gas.
Definition: absorber_vmr.h:17
This class maps the state vector to the absorber VMR on each level.
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 void calc_vmr() const
Derived classes should provide a function to fill in vmr when this is called.
double value(const FullPhysics::AutoDerivative< double > &Ad)

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