17 const std::string&>())
30 const std::string&>())
51 const std::string& hdf_group,
52 const std::string& gas_name,
53 const int temp_avg_window)
55 const blitz::Array<double, 1> met_press = Met_file->pressure_levels();
56 const blitz::Array<double, 1> met_temp = Met_file->temperature();
59 const double obs_latitude = L1b_file->latitude(0).value;
60 const Time obs_time = L1b_file->time(0);
62 initialize(met_press, met_temp, obs_latitude, obs_time, altitude, reference_file, hdf_group, gas_name, temp_avg_window);
66 const blitz::Array<double, 1>& temperature_levels,
67 const double& obs_latitude,
71 const std::string& hdf_group,
72 const std::string& gas_name,
73 const int temp_avg_window)
75 initialize(pressure_levels, temperature_levels, obs_latitude, obs_time, altitude, reference_file, hdf_group, gas_name, temp_avg_window);
78 void GasVmrApriori::initialize(
const blitz::Array<double, 1>& pressure_levels,
79 const blitz::Array<double, 1>& temperature_levels,
80 const double& obs_latitude,
84 const std::string& hdf_group,
85 const std::string& gas_name_in,
86 const int temp_avg_window)
89 gas_name = gas_name_in;
92 model_press.resize(pressure_levels.rows());
93 model_press = pressure_levels;
97 blitz::Array<double, 1> smoothed_model_temp(temperature_levels.rows());
98 for (
int out_idx = 0; out_idx < temperature_levels.rows(); out_idx++) {
101 int avg_beg = std::max(out_idx - temp_avg_window, 0);
102 int avg_end = std::min(out_idx + temp_avg_window, temperature_levels.rows() - 1);
103 for(
int avg_idx = avg_beg; avg_idx <= avg_end; avg_idx++) {
104 sum += temperature_levels(avg_idx);
107 smoothed_model_temp(out_idx) = sum/count;
110 model_alt.resize(model_press.rows());
111 for(
int lev_idx = 0; lev_idx < model_press.rows(); lev_idx++) {
116 Array<double, 1> ref_altitude = reference_file.
read_field<double, 1>(hdf_group +
"/altitude_grid");
117 double ref_latitude = reference_file.
read_field<
double>(hdf_group +
"/latitude");
119 double ref_tropo_alt = reference_file.
read_field<
double>(hdf_group +
"/tropopause_altitude");
120 ref_vmr.reference( reference_file.
read_field<
double, 1>(hdf_group +
"/Gas/" + gas_name_in +
"/vmr") );
123 bool in_increasing_alt = reference_file.
read_field<
int>(hdf_group +
"/increasing_altitude_order");
124 if (!in_increasing_alt) {
127 ref_altitude = ref_altitude.copy().reverse(firstDim);
128 ref_vmr = ref_vmr.copy().reverse(firstDim);
131 ref_apriori.reset(
new ReferenceVmrApriori(model_press.reverse(firstDim), model_alt.reverse(firstDim), smoothed_model_temp.reverse(firstDim), ref_altitude, ref_latitude, ref_time, ref_tropo_alt, obs_latitude, obs_time));
136 Array<double, 1> ap_vmr = ref_apriori->apriori_vmr(ref_vmr, gas_name);
137 ap_vmr.reverseSelf(firstDim);
144 Array<double, 1> model_ap_vmr(model_press.shape());
145 model_ap_vmr = apriori_vmr();
151 Array<double, 1> interp_vmr(press_levels.shape());
152 for(
int lev_idx = 0; lev_idx < interp_vmr.rows(); lev_idx++) {
153 interp_vmr(lev_idx) = mod_vmr_interp(press_levels(lev_idx));
162 blitz::Array<double, 1> rev_alt(model_alt.shape());
163 rev_alt = model_alt.copy().reverse(firstDim);
164 blitz::Array<double, 1> rev_press(rev_alt.shape());
165 rev_press = model_press.copy().reverse(firstDim);
ArrayAdWithUnit< T, D > convert(const Unit &R) const
Convert to the given units.
static Time parse_time(const std::string &Time_string)
Parse CCSDS format time (e.g., "1996-07-03T04:13:57.987654Z")
This is a AutoDerivative that also has units associated with it.
blitz::Array< T, D > read_field(const std::string &Dataname) const
Read a given field.
Creates a VMR profile for a gas using a set of dated reference VMRs with a known latitude.
const Unit Pa("Pa", N/(m *m))
const double tropopause_pressure() const
This class reads and writes a HDF5 file.
#define REGISTER_LUA_CLASS(X)
Apply value function to a blitz array.
Adapts the ReferenceVmrApriori class into a form that is easier to work with in the context of how th...
This class maintains the pressure portion of the state.
This is a simple time class.
Contains classes to abstract away details in various Spurr Radiative Transfer software.
#define REGISTER_LUA_END()
virtual ArrayAdWithUnit< double, 1 > pressure_grid() const =0
This returns the pressure grid to use for layer retrieval, along with the gradient of each of the pre...
const Unit km("km", 1e3 *m)
GasVmrApriori(const boost::shared_ptr< Meteorology > &met_file, const boost::shared_ptr< Level1b > &l1b_file, const boost::shared_ptr< Altitude > &alt, const HdfFile &hdf_static_input, const std::string &hdf_group, const std::string &gas_name, const int temp_avg_window=11)
double value(const FullPhysics::AutoDerivative< double > &Ad)
double tropopause_altitude(const boost::shared_ptr< GasVmrApriori > &ga)
const blitz::Array< double, 1 > apriori_vmr() const