SOCA
LinearGetValues.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020-2021 UCAR
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  */
7 
8 #include "oops/util/DateTime.h"
9 
10 #include "soca/Geometry/Geometry.h"
14 #include "soca/State/State.h"
17 
18 #include "ufo/GeoVaLs.h"
19 #include "ufo/Locations.h"
20 
21 namespace soca {
22 
23 // -----------------------------------------------------------------------------
24 /// Constructor, destructor
25 // -----------------------------------------------------------------------------
27  const ufo::Locations & locs,
28  const eckit::Configuration &config)
29  : locs_(locs), geom_(new Geometry(geom)),
30  model2geovals_(new Model2GeoVaLs(geom, config))
31 {
33  geom.toFortran(),
34  locs);
35 }
36 
38 {
40 }
41 // -----------------------------------------------------------------------------
42 /// Interpolate to obs locations
43 // -----------------------------------------------------------------------------
45  const util::DateTime & t1,
46  const util::DateTime & t2,
47  ufo::GeoVaLs & geovals) {
48  std::unique_ptr<State> varChangeState;
49  const State * state_ptr;
50 
51  // Do variable change if it has not already been done.
52  // TODO(travis): remove this once Yannick is done rearranging things in oops.
53  if ( geovals.getVars() <= state.variables() ) {
54  state_ptr = &state;
55  } else {
56  varChangeState.reset(new State(*geom_, geovals.getVars(),
57  state.validTime()));
58  model2geovals_->changeVar(state, *varChangeState);
59  state_ptr = varChangeState.get();
60  }
61 
62  // TODO(travis) : change to a map to store multiple time slices?
63  eckit::LocalConfiguration conf;
64  linearmodel2geovals_.reset(new LinearModel2GeoVaLs(state, state,
65  *geom_, conf));
66 
68  geom_->toFortran(),
69  state_ptr->toFortran(),
70  t1, t2, locs_,
71  geovals.toFortran());
72 }
73 // -------------------------------------------------------------------------------------------------
75  const util::DateTime & t1,
76  const util::DateTime & t2,
77  ufo::GeoVaLs & geovals) const {
78  Increment incrGeovals(*geom_, geovals.getVars(), incr.validTime());
79  linearmodel2geovals_->multiply(incr, incrGeovals);
81  geom_->toFortran(),
82  incrGeovals.toFortran(),
83  t1, t2, locs_,
84  geovals.toFortran());
85 }
86 // -------------------------------------------------------------------------------------------------
88  const util::DateTime & t1,
89  const util::DateTime & t2,
90  const ufo::GeoVaLs & geovals) const {
91  Increment incrGeovals(*geom_, geovals.getVars(), incr.validTime());
93  geom_->toFortran(),
94  incrGeovals.toFortran(),
95  t1, t2, locs_,
96  geovals.toFortran());
97  linearmodel2geovals_->multiplyAD(incrGeovals, incr);
98 }
99 
100 // -----------------------------------------------------------------------------
101 void LinearGetValues::print(std::ostream & os) const {
102  os << "LinearGetValues" << std::endl;
103 }
104 // -----------------------------------------------------------------------------
105 
106 } // namespace soca
Geometry handles geometry for SOCA model.
Definition: Geometry.h:48
int & toFortran()
Definition: Geometry.h:61
Increment Class: Difference between two states.
Definition: Increment.h:61
int & toFortran()
Definition: Increment.h:112
const util::DateTime & validTime() const
Definition: Increment.cc:253
std::unique_ptr< Model2GeoVaLs > model2geovals_
void print(std::ostream &) const
ufo::Locations locs_
void fillGeoVaLsAD(Increment &inc, const util::DateTime &t1, const util::DateTime &t2, const ufo::GeoVaLs &geovals) const
LinearGetValues(const Geometry &, const ufo::Locations &, const eckit::Configuration &)
Constructor, destructor.
std::shared_ptr< const Geometry > geom_
void fillGeoVaLsTL(const Increment &inc, const util::DateTime &t1, const util::DateTime &t2, ufo::GeoVaLs &geovals) const
Forward and backward interpolation.
void setTrajectory(const State &state, const util::DateTime &t1, const util::DateTime &t2, ufo::GeoVaLs &geovals)
Trajectory for the linearized interpolation.
std::unique_ptr< LinearModel2GeoVaLs > linearmodel2geovals_
SOCA model state.
Definition: State.h:48
const util::DateTime & validTime() const
Definition: State.cc:218
int & toFortran()
Definition: State.h:88
const oops::Variables & variables() const
Definition: State.h:91
void soca_getvalues_fill_geovals_tl_f90(const F90getval &, const F90geom &, const F90flds &, const util::DateTime &, const util::DateTime &, const ufo::Locations &, const F90goms &)
void soca_getvalues_fill_geovals_ad_f90(const F90getval &, const F90geom &, const F90flds &, const util::DateTime &, const util::DateTime &, const ufo::Locations &, const F90goms &)
void soca_getvalues_delete_f90(F90getval &)
void soca_getvalues_fill_geovals_f90(const F90getval &, const F90geom &, const F90flds &, const util::DateTime &, const util::DateTime &, const ufo::Locations &, const F90goms &)
void soca_getvalues_create_f90(F90getval &, const F90geom &, const ufo::Locations &)