ReFRACtor
aerosol_property_hdf.cc
Go to the documentation of this file.
1 #include "aerosol_property_hdf.h"
2 #include "ostream_pad.h"
3 using namespace FullPhysics;
4 using namespace blitz;
5 
6 #ifdef HAVE_LUA
7 #include "register_lua.h"
9 .def(luabind::constructor<const HdfFile&, const std::string&,
12 #endif
13 
14 //-----------------------------------------------------------------------
16 //-----------------------------------------------------------------------
17 
19 (const HdfFile& F,
20  const std::string& Group_name,
21  const boost::shared_ptr<Pressure>& Press
22 )
23 : hdf_file(F.file_name()), hdf_group(Group_name)
24 {
25  press = Press;
26  Array<double, 1> wn(F.read_field<double, 1>(Group_name + "/wave_number"));
27  Array<double, 1>
28  qscatv(F.read_field<double, 1>(Group_name + "/scattering_coefficient"));
29  Array<double, 1>
30  qextv(F.read_field<double, 1>(Group_name + "/extinction_coefficient"));
31  Array<double, 3>
32  pfv(F.read_field<double, 3>(Group_name + "/phase_function_moment"));
33  qext.reset(new LinearInterpolate<double, double>(wn.begin(), wn.end(),
34  qextv.begin()));
35  qscat.reset(new LinearInterpolate<double, double>(wn.begin(), wn.end(),
36  qscatv.begin()));
37  std::vector<Array<double, 2> > pf_vec;
38  for(int i = 0; i < pfv.rows(); ++i)
39  pf_vec.push_back(Array<double, 2>(pfv(i, Range::all(), Range::all())));
40  pf.reset(new ScatteringMomentInterpolate(wn.begin(), wn.end(),
41  pf_vec.begin()));
42 }
43 
45 {
47  return clone(press->clone(), rh_dummy);
48 }
49 
53 {
54  HdfFile f(hdf_file);
56  (new AerosolPropertyHdf(f, hdf_group, Press));
57 }
58 
60 (double wn) const
61 {
62  firstIndex i1; secondIndex i2;
63  AutoDerivative<double> t = (*qext)(wn);
64  ArrayAd<double, 1> res(press->number_layer(), t.number_variable());
65  res.value() = t.value();
66  if(t.number_variable() > 0)
67  res.jacobian() = t.gradient()(i2);
68  return res;
69 }
70 
72 (double wn) const
73 {
74  firstIndex i1; secondIndex i2;
75  AutoDerivative<double> t = (*qscat)(wn);
76  ArrayAd<double, 1> res(press->number_layer(), t.number_variable());
77  res.value() = t.value();
78  if(t.number_variable() > 0)
79  res.jacobian() = t.gradient()(i2);
80  return res;
81 }
82 
84 (double wn, int nmom, int nscatt) const
85 {
86  firstIndex i1; secondIndex i2; thirdIndex i3; fourthIndex i4;
87  ArrayAd<double, 2> t = (*pf)(wn, nmom, nscatt);
88  ArrayAd<double, 3> res(t.rows(), press->number_layer(),
89  t.cols(), t.number_variable());
90  res.value() = t.value()(i1, i3);
91  if(t.number_variable() > 0)
92  res.jacobian() = t.jacobian()(i1, i3, i4);
93  return res;
94 }
95 
96 void AerosolPropertyHdf::print(std::ostream& Os) const
97 {
98  Os << "AerosolPropertyHdf:\n"
99  << " Hdf file: " << hdf_file << "\n"
100  << " Hdf group: " << hdf_group << "\n";
101 }
virtual ArrayAd< double, 3 > phase_function_moment_each_layer(double wn, int nmom=-1, int nscatt=-1) const
Return phase function moments for the given wave number for each layer.
This gives the Aerosol properties for an Aerosol.
int cols() const
Definition: array_ad.h:369
AerosolPropertyHdf(const HdfFile &F, const std::string &Group_name, const boost::shared_ptr< Pressure > &Press)
Read the given group in the given file for the aerosol properties.
blitz::Array< T, D > read_field(const std::string &Dataname) const
Read a given field.
Definition: hdf_file.h:564
This gives the Aerosol properties for an Aerosol.
#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
This class reads and writes a HDF5 file.
Definition: hdf_file.h:39
Apply value function to a blitz array.
const blitz::Array< T, D > & value() const
Definition: array_ad.h:306
virtual ArrayAd< double, 1 > extinction_coefficient_each_layer(double wn) const
Return extinction coefficient for the given wave number, for each layer.
int number_variable() const
Number of variables in gradient.
const blitz::Array< T, 1 > & gradient() const
Gradient.
const std::string & file_name() const
File name.
Definition: hdf_file.h:131
virtual void print(std::ostream &Os) const
Print to stream.
int number_variable() const
Definition: array_ad.h:376
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
const T & value() const
Convert to type T.
#define REGISTER_LUA_END()
Definition: register_lua.h:134
virtual boost::shared_ptr< AerosolProperty > clone() const
Clone a AerosolProperty object.
virtual ArrayAd< double, 1 > scattering_coefficient_each_layer(double wn) const
Return scattering coefficient for the given wave number 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:08