ReFRACtor
absorber_vmr_fixed_level_scaled.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<double, 1>&,
14  bool,
15  double,
16  const std::string&>())
18 #endif
19 
22  const boost::shared_ptr<PressureLevelInput>& Press_level,
23  const blitz::Array<double, 1>& Vmr,
24  bool Used_flag,
25  double Scale,
26  const std::string& Gas_name)
27 : press_level(Press_level),
28  vmr0(Vmr.copy())
29 {
30  Array<bool, 1> uflag(1);
31  Array<double, 1> val(1);
32  val(0) = Scale;
33  uflag(0) = Used_flag;
34  init(Gas_name, val, uflag, Press, false);
35 }
36 
38 {
39  boost::shared_ptr<Pressure> pressure_clone = press->clone();
40  return clone(pressure_clone);
41 }
42 
44 (const boost::shared_ptr<Pressure>& Press) const
45 {
47  (new AbsorberVmrFixedLevelScaled(Press, press_level, vmr0,
48  used_flag(0), scale_factor(), gas_name()));
49 }
50 
52 {
53  AutoDerivative<double> p = log(press->surface_pressure().value);
54  std::vector<AutoDerivative<double> > plist;
55  std::vector<AutoDerivative<double> > vmrlist;
56  for(int i = 0; i < press->pressure_grid().rows() - 1; ++i) {
57  vmrlist.push_back(vmr0(i) * coeff(0));
58  plist.push_back(press->pressure_grid()(i).value);
59  }
60  int i = press->pressure_grid().rows() - 1;
61  double p1 = log(press_level->pressure_level()(i - 1));
62  double p2 = log(press_level->pressure_level()(i));
63  AutoDerivative<double> v = coeff(0) *
64  (vmr0(i - 1) + (p - p1) * (vmr0(i) - vmr0(i - 1)) / (p2 - p1));
65  plist.push_back(press->surface_pressure().value);
66  vmrlist.push_back(v);
68  lin_type;
70  (new lin_type(plist.begin(), plist.end(), vmrlist.begin()));
71  vmr = boost::bind(&lin_type::operator(), lin, _1);
72 }
73 
74 void AbsorberVmrFixedLevelScaled::print(std::ostream& Os) const
75 {
76  OstreamPad opad(Os, " ");
77  Os << "AbsorberVmrFixedLevelScaled:\n"
78  << " Gas name: " << gas_name() << "\n"
79  << " Scale: " << scale_factor() << "\n"
80  << " VMR:\n";
81  opad << vmr0 << "\n";
82  opad.strict_sync();
83 }
AbsorberVmrFixedLevelScaled(const boost::shared_ptr< Pressure > &Press, const boost::shared_ptr< PressureLevelInput > &Press_level, const blitz::Array< double, 1 > &Vmr, bool Used_flag, double Scale, const std::string &Gas_name)
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
Apply value function to a blitz array.
virtual void print(std::ostream &Os) const
Print to stream.
This class maps the state vector to the absorber VMR on each level.
This gives the Gas Absorber Volumn mixing ratio for a single gas.
Definition: absorber_vmr.h:17
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
double value(const FullPhysics::AutoDerivative< double > &Ad)
virtual void calc_vmr() const
Derived classes should provide a function to fill in vmr when this is called.
virtual boost::shared_ptr< AbsorberVmr > clone() const
Clone a AbsorberVmr object.

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