9 #include "ioda/ObsSpace.h"
10 #include "ufo/GeoVaLs.h"
23 geovars_ += oops::Variables({
"air_temperature",
40 ioda::ObsVector & out)
const {
41 const std::size_t
nlocs = odb.nlocs();
42 const std::size_t nvars = out.nvars();
45 ASSERT(out.nlocs() ==
nlocs);
47 const int t_levs = geovals.
nlevs(
"air_temperature");
48 const int p_levs = geovals.
nlevs(
"air_pressure");
49 std::vector <double> p_prof(t_levs, 0.0);
50 std::vector<double> t_prof(p_levs, 0.0);
51 std::vector <double> thick(odb.nlocs(), 0.0);
58 for (std::size_t jl = 0; jl <
nlocs; ++jl) {
65 if (p_high > p_prof.back()) {
66 oops::Log::error() <<
"layer top is greater than largest model pressure level" << std::endl;
67 throw eckit::BadValue(
"layer top is greater than largest model pressure level", Here());
70 auto lower = std::lower_bound(p_prof.begin(), p_prof.end(), p_high);
71 int i = lower - p_prof.begin();
74 double dp = p_prof[i] - p_high;
75 double f = dp/(p_prof[i] - p_prof[i-1]);
76 double p_av = p_prof[i] - 0.5*dp;
77 double t_av = 0.5*((2.0-
f)*t_prof[i]+
f*t_prof[i-1]);
78 thick[jl] = t_av*(dp/p_av);
82 while (p_prof[i] < p_low && i < p_levs - 1) {
83 dp = p_prof[i] - p_prof[i-1];
84 p_av = p_prof[i] - 0.5*dp;
85 t_av = 0.5*(t_prof[i] + t_prof[i-1]);
86 thick[jl] += t_av*(dp/p_av);
91 if (p_prof[i] >= p_low) {
92 dp = p_low - p_prof[i-1];
93 f = dp/(p_prof[i] - p_prof[i-1]);
94 p_av = p_low - 0.5*dp;
95 t_av = 0.5*((
f)*t_prof[i]+ (2.0-
f)*t_prof[i-1]);
96 thick[jl] += t_prof[i-1]*(dp/p_av);
101 dp = p_prof[i] - p_prof[i-1];
102 p_av = p_prof[i] - 0.5*dp;
103 t_av = 0.5*(t_prof[i] + t_prof[i-1]);
104 thick[jl] += t_av*(dp/p_av);
106 dp = p_low - p_prof[i];
107 p_av = p_low - 0.5*dp;
109 thick[jl] += t_av*(dp/p_av);
113 const double km_per_m = 1e-3;
114 const double dry_air_gas_const = 287.0;
116 for (std::size_t jl = 0; jl <
nlocs; ++jl) {
117 for (std::size_t jb = 0; jb < nvars; ++jb) {
118 out[jl*nvars+jb] = (thick[jl]
GeoVaLs: geophysical values at locations.
size_t nlevs(const std::string &var) const
Return number of levels for a specified variable.
void getAtLocation(std::vector< double > &, const std::string &, const int) const
Get GeoVaLs at a specified location.
std::string & name()
predictor name
oops::Variables geovars_
required GeoVaLs
void compute(const ioda::ObsSpace &, const GeoVaLs &, const ObsDiagnostics &, ioda::ObsVector &) const override
compute the predictor
Thickness(const Parameters_ &, const oops::Variables &)
Configuration parameters of the thickness predictor.
oops::RequiredParameter< double > layerBase
Pressure value (Pa) at the bottom of the required thickness layer.
oops::RequiredParameter< double > stDev
Climatological standard deviation of predictor.
oops::RequiredParameter< double > layerTop
Pressure value (Pa) at the top of the required thickness layer.
oops::RequiredParameter< double > mean
Climatological mean of predictor.
ObsPair reverse(const ObsPair &pair)
integer function nlocs(this)
Return the number of observational locations in this Locations object.
static PredictorMaker< Thickness > makerFuncThickness_("thickness")
static constexpr double grav