13 #include "ioda/ObsSpace.h"
15 #include "oops/base/Variables.h"
16 #include "oops/util/abor1_cpp.h"
17 #include "oops/util/Logger.h"
19 #include "ufo/GeoVaLs.h"
20 #include "ufo/ObsDiagnostics.h"
32 if (
conf.has(
"predictor.options.order")) {
40 geovars_ += oops::Variables({
"air_temperature",
42 "average_surface_temperature_within_field_of_view"});
43 if (jobs.size() > 0) {
44 hdiags_ += oops::Variables({
"transmittances_of_atmosphere_layer"}, jobs);
46 oops::Log::error() <<
"Channels size is ZERO !" << std::endl;
47 ABORT(
"Channels size is ZERO !");
52 if (
conf.has(
"predictor.options.tlapse")) {
53 const std::string tlapse_file =
conf.getString(
"predictor.options.tlapse");
54 std::ifstream infile(tlapse_file);
59 if (infile.is_open()) {
60 while (!infile.eof()) {
68 oops::Log::error() <<
"Unable to open file : "
69 << tlapse_file << std::endl;
70 ABORT(
"Unable to open tlap file ");
73 oops::Log::error() <<
"tlapse file is not provided !" << std::endl;
74 ABORT(
"tlapse file is not provided !");
83 ioda::ObsVector & out)
const {
84 const std::size_t njobs =
jobs_.size();
85 const std::size_t nlocs = odb.nlocs();
88 ASSERT(out.nlocs() == nlocs);
91 std::vector <float> pred(nlocs, 0.0);
94 std::vector<float> tsavg5(nlocs, 0.0);
95 geovals.
get(tsavg5,
"average_surface_temperature_within_field_of_view");
98 std::vector<std::vector<std::vector<float>>> ptau5;
99 std::vector<std::vector<float>> tmpvar;
102 for (std::size_t jb = 0; jb < njobs; ++jb) {
103 hdiags =
"transmittances_of_atmosphere_layer_" + std::to_string(
jobs_[jb]);
105 for (std::size_t js = 0; js < ydiags.
nlevs(hdiags); ++js) {
106 ydiags.
get(pred, hdiags, js+1);
107 tmpvar.push_back(pred);
109 ptau5.push_back(tmpvar);
113 std::vector<std::vector<float>> tvp;
114 std::size_t nlevs = geovals.
nlevs(
"air_temperature");
115 for (std::size_t js = 0; js < nlevs; ++js) {
116 geovals.
get(pred,
"air_temperature", js+1);
119 nlevs = geovals.
nlevs(
"air_pressure");
123 std::vector<float> tlap;
124 for (std::size_t jb = 0; jb < njobs; ++jb) {
127 tlap.push_back(it->second);
129 oops::Log::error() <<
"Could not locate tlapemean for channel: " <<
jobs_[jb] << std::endl;
130 ABORT(
"Could not locate tlapemean value");
134 for (std::size_t jl = 0; jl < nlocs; ++jl) {
135 for (std::size_t jb = 0; jb < njobs; ++jb) {
136 tlapchn = (ptau5[jb][nlevs-2][jl]-ptau5[jb][nlevs-1][jl])*(tsavg5[jl]-tvp[nlevs-2][jl]);
137 for (std::size_t k = 1; k < nlevs-1; ++k) {
138 tlapchn = tlapchn+(ptau5[jb][nlevs-k-2][jl]-ptau5[jb][nlevs-k-1][jl])*
139 (tvp[nlevs-k][jl]-tvp[nlevs-k-2][jl]);
141 out[jl*njobs+jb] = pow((tlapchn - tlap[jb]),
order_);