14 #include "ioda/ObsVector.h"
16 #include "oops/base/Variables.h"
17 #include "oops/util/Logger.h"
18 #include "oops/util/missingValues.h"
20 #include "ufo/GeoVaLs.h"
21 #include "ufo/ObsDiagnostics.h"
30 const eckit::Configuration & config)
33 oops::Log::trace() <<
"ObsProfileAverageTLAD constructed" << std::endl;
39 oops::Log::trace() <<
"ObsProfileAverageTLAD destructed" << std::endl;
47 oops::Log::trace() <<
"ObsProfileAverageTLAD: trajectory set" << std::endl;
53 oops::Log::trace() <<
"ObsProfileAverageTLAD: simulateObsTL started" << std::endl;
56 const std::vector<std::size_t> &recnums =
odb_.recidx_all_recnums();
59 const std::size_t nprofs = recnums.size() / 2;
62 for (std::size_t jprof = 0; jprof < nprofs; ++jprof) {
63 const std::vector<std::size_t> &locsOriginal =
odb_.recidx_vector(recnums[jprof]);
64 const std::vector<std::size_t> &locsExtended =
odb_.recidx_vector(recnums[jprof + nprofs]);
67 const std::vector<std::size_t>& slant_path_location =
71 const auto& variable = dy.varnames().variables()[jvar];
72 const std::size_t nlevs_var = dx.
nlevs(variable);
73 std::vector<double> var_gv(nlevs_var);
74 for (std::size_t mlev = 0; mlev < nlevs_var; ++mlev) {
75 const std::size_t jloc = slant_path_location[mlev];
77 dy[locsExtended[mlev] * dy.nvars() + jvar] = var_gv[mlev];
82 oops::Log::trace() <<
"ObsProfileAverageTLAD: simulateObsTL finished" << std::endl;
88 oops::Log::trace() <<
"ObsProfileAverageTLAD: simulateObsAD started" << std::endl;
93 const std::vector<std::size_t> &recnums =
odb_.recidx_all_recnums();
96 const std::size_t nprofs = recnums.size() / 2;
99 for (std::size_t jprof = 0; jprof < nprofs; ++jprof) {
100 const std::vector<std::size_t> &locsOriginal =
odb_.recidx_vector(recnums[jprof]);
101 const std::vector<std::size_t> &locsExtended =
odb_.recidx_vector(recnums[jprof + nprofs]);
104 const std::vector<std::size_t>& slant_path_location =
108 const auto& variable = dy.varnames().variables()[jvar];
109 const std::size_t nlevs_var = dx.
nlevs(variable);
110 std::vector<double> var_gv(nlevs_var);
111 for (std::size_t mlev = 0; mlev < nlevs_var; ++mlev) {
112 const std::size_t jloc = slant_path_location[mlev];
115 const std::size_t idx = locsExtended[mlev] * dy.nvars() + jvar;
117 var_gv[mlev] += dy[idx];
124 oops::Log::trace() <<
"ObsProfileAverageTLAD: simulateObsAD finished" << std::endl;
130 os <<
"ObsProfileAverageTLAD operator" << std::endl;
GeoVaLs: geophysical values at locations.
size_t nlevs(const std::string &var) const
Return number of levels for a specified variable.
void putAtLocation(const std::vector< double > &vals, const std::string &var, const int loc) const
Put GeoVaLs for double variable var at location loc.
void getAtLocation(std::vector< double > &, const std::string &, const int) const
Get GeoVaLs at a specified location.
std::vector< std::size_t > getSlantPathLocations(const std::vector< std::size_t > &locsOriginal, const std::vector< std::size_t > &locsExtended) const
void cacheGeoVaLs(const GeoVaLs &gv) const
Cache the initial values of the GeoVaLs.
const std::vector< int > & operatorVarIndices() const
Return operator variable indices for the operator.
virtual ~ObsProfileAverageTLAD()
ObsProfileAverageData data_
Data handler for the ProfileAverage operator and TL/AD code.
void setTrajectory(const GeoVaLs &, ObsDiagnostics &) override
Obs Operator.
ObsProfileAverageTLAD(const ioda::ObsSpace &, const eckit::Configuration &)
void print(std::ostream &) const override
void simulateObsTL(const GeoVaLs &, ioda::ObsVector &) const override
const ioda::ObsSpace & odb_
ObsSpace.
void simulateObsAD(GeoVaLs &, const ioda::ObsVector &) const override
static ObsOperatorMaker< ObsProfileAverage > obsProfileAverageMaker_("ProfileAverage")