3 #include <boost/make_shared.hpp> 10 .def(luabind::constructor<
const HdfFile&,
const std::string&,
22 const std::string& Group_name,
26 : rh(Rh), hdf_file(F.
file_name()), hdf_group(Group_name)
29 Array<double, 1>
wn(F.
read_field<
double, 1>(Group_name +
"/wave_number"));
30 Array<double, 1> rhv(F.
read_field<
double, 1>(Group_name +
"/relative_humidity"));
32 qscatv(F.
read_field<
double, 2>(Group_name +
"/scattering_coefficient"));
34 qextv(F.
read_field<
double, 2>(Group_name +
"/extinction_coefficient"));
36 pfv(F.
read_field<
double, 4>(Group_name +
"/phase_function_moment"));
37 if(rhv.rows() != qscatv.cols() ||
38 rhv.rows() != qextv.cols() ||
39 rhv.rows() != pfv.cols())
40 throw Exception(
"Mismatch between the number of relative humidity values and the aerosol property arrays");
41 Array<double, 1> qscatvt(qscatv.rows());
42 Array<double, 1> qextvt(qextv.rows());
43 for(
int i = 0; i < rhv.rows(); ++i) {
44 rh_val.push_back(rhv(i));
45 rh_val_d.push_back(rhv(i));
46 qscatvt = qscatv(Range::all(), i);
47 qextvt = qextv(Range::all(), i);
49 (wn.begin(), wn.end(), qextvt.begin()));
51 (wn.begin(), wn.end(), qscatvt.begin()));
52 std::vector<Array<double, 2> > pf_vec;
53 for(
int j = 0; j < pfv.rows(); ++j)
54 pf_vec.push_back(Array<double, 2>(pfv(j, i, Range::all(), Range::all())));
55 pf.push_back(boost::make_shared<ScatteringMomentInterpolate>
56 (wn.begin(), wn.end(), pf_vec.begin()));
62 return clone(press->clone(), rh->clone());
85 std::vector<AutoDerivative<double> > qextv;
86 for(
int i = 0; i < (int) rh_val.size(); ++i)
87 qextv.push_back((*qext[i])(wn));
89 lin(rh_val.begin(), rh_val.end(), qextv.begin());
91 blitz::Array<AutoDerivative<double>, 1> res(rhl.rows());
92 for(
int i = 0; i < res.rows(); ++i)
100 std::vector<double> qextv;
101 for(
int i = 0; i < (int) rh_val.size(); ++i)
102 qextv.push_back((*qext[i])(wn));
104 lin(rh_val_d.begin(), rh_val_d.end(), qextv.begin());
105 blitz::Array<double, 1> rhl = rh->relative_humidity_layer().value();
106 blitz::Array<double, 1> res(rhl.rows());
107 for(
int i = 0; i < res.rows(); ++i)
108 res(i) = lin(rhl(i));
123 std::vector<AutoDerivative<double> > qscatv;
124 for(
int i = 0; i < (int) rh_val.size(); ++i)
125 qscatv.push_back((*qscat[i])(wn));
127 lin(rh_val.begin(), rh_val.end(), qscatv.begin());
129 blitz::Array<AutoDerivative<double>, 1> res(rhl.rows());
130 for(
int i = 0; i < res.rows(); ++i)
131 res(i) = lin(rhl(i));
138 std::vector<double> qscatv;
139 for(
int i = 0; i < (int) rh_val.size(); ++i)
140 qscatv.push_back((*qscat[i])(wn));
142 lin(rh_val_d.begin(), rh_val_d.end(), qscatv.begin());
143 blitz::Array<double, 1> rhl = rh->relative_humidity_layer().value();
144 blitz::Array<double, 1> res(rhl.rows());
145 for(
int i = 0; i < res.rows(); ++i)
146 res(i) = lin(rhl(i));
157 (
double wn,
int nmom,
int nscatt)
const 159 firstIndex i1; secondIndex i2; thirdIndex i3; fourthIndex i4;
160 std::vector<blitz::Array<AutoDerivative<double>, 2> > pfv;
161 for(
int i = 0; i < (int) rh_val.size(); ++i) {
162 blitz::Array<double, 2> t((*pf[i])(wn, nmom, nscatt));
163 blitz::Array<AutoDerivative<double>, 2> t2(t.shape());
164 for(
int j = 0; j < t2.rows(); ++j)
165 for(
int k = 0; k < t2.cols(); ++k)
170 blitz::Array<AutoDerivative<double>, 2> >
171 lin(rh_val.begin(), rh_val.end(), pfv.begin());
173 blitz::Array<AutoDerivative<double>, 3>
174 res(pfv[0].rows(), press->number_layer(), pfv[1].cols());
175 for(
int i = 0; i < res.cols(); ++i)
176 res(Range::all(), i, Range::all()) = lin(rhl(i));
181 (
double wn,
int nmom,
int nscatt)
const 183 firstIndex i1; secondIndex i2; thirdIndex i3; fourthIndex i4;
184 std::vector<blitz::Array<double, 2> > pfv;
185 for(
int i = 0; i < (int) rh_val.size(); ++i) {
186 blitz::Array<double, 2> t((*pf[i])(wn, nmom, nscatt));
190 lin(rh_val_d.begin(), rh_val_d.end(), pfv.begin());
191 blitz::Array<double, 1> rhl = rh->relative_humidity_layer().value();
192 blitz::Array<double, 3>
193 res(pfv[0].rows(), press->number_layer(), pfv[1].cols());
194 for(
int i = 0; i < res.cols(); ++i)
195 res(Range::all(), i, Range::all()) = lin(rhl(i));
201 Os <<
"AerosolPropertyRhHdf:\n" 202 <<
" Hdf file: " << hdf_file <<
"\n" 203 <<
" Hdf group: " << hdf_group <<
"\n";
virtual ArrayAd< double, 1 > scattering_coefficient_each_layer_not_used(double wn) const
This gives the Aerosol properties for an Aerosol.
blitz::Array< T, D > read_field(const std::string &Dataname) const
Read a given field.
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.
virtual void print(std::ostream &Os) const
Print to stream.
This is the base of the exception hierarchy for Full Physics code.
#define REGISTER_LUA_DERIVED_CLASS(X, Y)
virtual ArrayAd< double, 1 > extinction_coefficient_each_layer_not_used(double wn) const
This class reads and writes a HDF5 file.
Apply value function to a blitz array.
const std::string & file_name() const
File name.
virtual ArrayAd< double, 1 > extinction_coefficient_each_layer(double wn) const
Return extinction coefficient for the given wave number, for each layer.
This gives the Aerosol properties for an Aerosol.
virtual boost::shared_ptr< AerosolProperty > clone() const
Clone a AerosolProperty object.
Contains classes to abstract away details in various Spurr Radiative Transfer software.
#define REGISTER_LUA_END()
ArrayAd< double, 3 > phase_function_moment_each_layer_not_used(double wn, int nmom=-1, int nscatt=-1) const
AerosolPropertyRhHdf(const HdfFile &F, const std::string &Group_name, const boost::shared_ptr< Pressure > &Press, const boost::shared_ptr< RelativeHumidity > &Rh)
Read the given group in the given file for the aerosol properties.
virtual ArrayAd< double, 1 > scattering_coefficient_each_layer(double wn) const
Return scattering coefficient for the given wave number for each layer.