ReFRACtor
relative_humidity.cc
Go to the documentation of this file.
1 #include "relative_humidity.h"
2 #include "ostream_pad.h"
3 #include "default_constant.h"
4 using namespace FullPhysics;
5 
6 #ifdef HAVE_LUA
7 #include "register_lua.h"
9 .def(luabind::constructor<const boost::shared_ptr<Absorber>&,
13 #endif
14 
15 //-----------------------------------------------------------------------
17 //-----------------------------------------------------------------------
18 
22  const boost::shared_ptr<Pressure>& Press)
23  : absorber(Abs), temp(Temp), press(Press)
24 {
25  DefaultConstant cs;
27 }
28 
30 {
31  return boost::shared_ptr<RelativeHumidity>(new RelativeHumidity(absorber, temp, press));
32 }
33 
34 
38  const boost::shared_ptr<Pressure>& Press) const
39 {
40  return boost::shared_ptr<RelativeHumidity>(new RelativeHumidity(Abs, Temp, Press));
41 }
42 
43 //-----------------------------------------------------------------------
45 //-----------------------------------------------------------------------
46 void RelativeHumidity::print(std::ostream& Os)
47 {
48  OstreamPad opad(Os, " ");
49  Os << "RelativeHumidity:\n";
50  Os << " Absorber:\n";
51  opad << *absorber << "\n";
52  opad.strict_sync();
53  Os << " Temperature:\n";
54  opad << *temp << "\n";
55  opad.strict_sync();
56  Os << " Pressure:\n";
57  opad << *press << "\n";
58  opad.strict_sync();
59 }
60 
61 //-----------------------------------------------------------------------
63 //-----------------------------------------------------------------------
64 
66 {
67  blitz::Array<AutoDerivative<double>, 1> vgrid =
68  absorber->absorber_vmr("H2O")->vmr_grid(*press).to_array();
69  blitz::Array<AutoDerivative<double>, 1> shgrid(vgrid.rows());
70  shgrid = vgrid / (c + vgrid);
71  return ArrayAd<double, 1>(shgrid);
72 }
73 
74 //-----------------------------------------------------------------------
76 //-----------------------------------------------------------------------
77 
79 {
80  // This comes Suniti. Not sure of a reference for this.
81  blitz::Array<AutoDerivative<double>, 1> pgrid =
82  press->pressure_grid().convert(Unit("Pa")).value.to_array();
83  blitz::Array<AutoDerivative<double>, 1> shgrid =
85  blitz::Array<AutoDerivative<double>, 1> tgrid =
86  temp->temperature_grid(*press).convert(Unit("K")).value.to_array();
87  blitz::Array<AutoDerivative<double>, 1> res(pgrid.rows());
88  res = 0.263 * pgrid * shgrid * exp(-17.67*(tgrid-273.16)/(tgrid-29.65));
89  return ArrayAd<double, 1>(res);
90 }
91 
92 //-----------------------------------------------------------------------
95 //-----------------------------------------------------------------------
96 
98 {
100  ArrayAd<double, 1> res(rh_lev.rows() - 1, rh_lev.number_variable());
101  for(int i = 0; i < res.rows(); ++i)
102  res(i) = (rh_lev(i) + rh_lev(i+1)) / 2.0;
103  return res;
104 }
This is a filtering stream that adds a pad to the front of every line written out.
Definition: ostream_pad.h:32
void print(std::ostream &Os)
Print to a string.
This class is an implementation of Constant that uses hard coded values suitable for Earth...
ArrayAd< double, 1 > specific_humidity_grid() const
Calculate specific humidity.
blitz::Array< AutoDerivative< T >, D > to_array() const
Definition: array_ad.h:316
#define REGISTER_LUA_CLASS(X)
Definition: register_lua.h:116
This calculates the relative humidity.
virtual DoubleWithUnit molar_weight_dry_air() const
Molar weight of dry air.
int number_variable() const
Definition: array_ad.h:376
Libraries such as boost::units allow unit handling where we know the units at compile time...
Definition: unit.h:25
virtual DoubleWithUnit molar_weight_water() const
Molar weight of water.
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 boost::shared_ptr< RelativeHumidity > clone() const
double value(const FullPhysics::AutoDerivative< double > &Ad)
ArrayAd< double, 1 > relative_humidity_grid() const
Calculate relative humidity.
RelativeHumidity(const boost::shared_ptr< Absorber > &Abs, const boost::shared_ptr< Temperature > &Temp, const boost::shared_ptr< Pressure > &Press)
Constructor.
ArrayAd< double, 1 > relative_humidity_layer() const
Relative humidity for each layer.
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:10