2 #include <boost/lexical_cast.hpp> 9 .def(luabind::constructor<
const HdfFile&,
11 const std::string&,
const std::string&,
12 const std::string&>())
13 .def(luabind::constructor<
const HdfFile&,
15 const std::string&,
const std::string&>())
16 .def(luabind::constructor<
const blitz::Array<double, 1>&,
17 const blitz::Array<double, 2>&,
18 const blitz::Array<double, 2>&,
19 const std::string&,
const std::string&,
27 const
std::
string&, const
std::
string&,
28 const
std::
string&>())
29 .
def(luabind::constructor<const HdfFile&,
31 const
std::
string&, const
std::
string&>())
32 .
def(luabind::constructor<const
blitz::Array<
double, 1>&,
33 const
blitz::Array<
double, 2>&,
34 const
blitz::Array<
double, 2>&,
35 const
std::
string&, const
std::
string&,
37 .
def("band_name", &IlsTableLog::band_name)
52 const std::string& Band_name,
const std::string& Hdf_band_name,
53 const std::string& Hdf_group)
54 : band_name_(Band_name), hdf_band_name_(Hdf_band_name),
56 hdf_file_name(Hdf_static_input.file_name())
58 hdf_group = Hdf_group +
"/ILS_" +
59 boost::lexical_cast<std::string>(Spec_index + 1);
61 (Hdf_static_input.
read_field<
double, 1>(hdf_group +
"/wavenumber"));
63 (Hdf_static_input.
read_field<
double, 2>(hdf_group +
"/delta_lambda"));
65 (Hdf_static_input.
read_field<
double, 2>(hdf_group +
"/response"));
67 Hdf_static_input.
read_field<std::string>(hdf_group +
"/function_type");
69 interpolate_wavenumber =
false;
70 else if(ftype ==
"interpol")
71 interpolate_wavenumber =
true;
74 e <<
"Unrecognized function_type given in the file " 75 << Hdf_static_input.
file_name() <<
" HDF group " << hdf_group
76 <<
". The value was '" << ftype <<
"'. This should be one of " 77 <<
"'table' or 'interpol'";
85 (
const blitz::Array<double, 1>& Wavenumber,
86 const blitz::Array<double, 2>& Delta_lambda,
87 const blitz::Array<double, 2>& Response)
89 wavenumber_.reference(Wavenumber);
90 delta_lambda_.reference(Delta_lambda);
91 response_.reference(Response);
93 delta_lambda_to_response.clear();
94 for(
int i = 0; i < Wavenumber.rows(); ++i) {
100 delta_lambda_to_response[Wavenumber(i)] =
110 const blitz::Array<double, 1>&
wn,
127 it inter = delta_lambda_to_response.lower_bound(wn_center.
value());
130 if(inter != delta_lambda_to_response.begin())
132 for(
int i = 0; i < res.
rows(); ++i) {
134 inter->second.interpolate(w, res(i));
138 if(interpolate_wavenumber) {
139 double wn1 = inter->first;
141 if(inter != delta_lambda_to_response.end()) {
142 double wn2 = inter->first;
143 f = (wn_center - wn1) / (wn2 - wn1);
144 for(
int i = 0; i < res.
rows(); ++i) {
146 inter->second.interpolate(w, tref);
147 double v = res(i).
value();
149 res(i).gradient_ref() *= (1 - f.
value());
160 Os <<
"IlsTable for band " <<
band_name() <<
"\n" 161 <<
" Interpolate wavenumber: " << (interpolate_wavenumber ?
"true" :
"false");
164 <<
" Hdf file name: " << hdf_file_name <<
"\n" 165 <<
" Hdf group: " << hdf_group;
blitz::Array< T, D > read_field(const std::string &Dataname) const
Read a given field.
This class takes a set of points and values, and linearly interpolates between those values...
virtual std::string band_name() const
Descriptive name of the band.
This is the base of the exception hierarchy for Full Physics code.
#define REGISTER_LUA_DERIVED_CLASS(X, Y)
virtual void print(std::ostream &Os) const
const blitz::Array< T, 1 > & gradient() const
This class models an Instrument Line Shape (ILS) function.
Helper class that gives us a reference that we can assign a AutoDerivative to and write into the corr...
This class reads and writes a HDF5 file.
Apply value function to a blitz array.
void create_delta_lambda_to_response(const blitz::Array< double, 1 > &Wavenumber, const blitz::Array< double, 2 > &Delta_lambda, const blitz::Array< double, 2 > &Response)
Creates the datastructures needed for setting up the ILS table, only necessary to rerun if modifying ...
const blitz::Array< T, D > & value() const
void resize(const blitz::TinyVector< int, D > &Shape, int nvar)
IlsTable(const blitz::Array< double, 1 > &Wavenumber, const blitz::Array< double, 2 > &Delta_lambda, const blitz::Array< double, 2 > &Response, const std::string &Band_name, const std::string &Hdf_band_name, bool Interpolate_wavenumber=false)
Constructor where we just supply the wavenumber, delta_lambda and response values.
virtual blitz::Array< double, 1 > wavenumber() const
Accessors for retrieving arrays used to create table.
virtual void ils(const AutoDerivative< double > &wn_center, const blitz::Array< double, 1 > &wn, ArrayAd< double, 1 > &res) const
Return response function.
int number_variable() const
Number of variables in gradient.
const blitz::Array< T, 1 > & gradient() const
Gradient.
virtual blitz::Array< double, 2 > response() const
const std::string & file_name() const
File name.
virtual blitz::Array< double, 2 > delta_lambda() const
This class in a IlsFunction where we get the ILS response by using a table of measured values...
Contains classes to abstract away details in various Spurr Radiative Transfer software.
const T & value() const
Convert to type T.
#define REGISTER_LUA_END()
def(luabind::constructor< int >()) .def("rows"