SOCA
GetValues.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2019-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 "eckit/config/LocalConfiguration.h"
9 
10 #include "ioda/ObsSpace.h"
11 
12 #include "oops/mpi/mpi.h"
13 #include "oops/util/DateTime.h"
14 
15 #include "soca/Geometry/Geometry.h"
18 #include "soca/State/State.h"
20 
21 #include "ufo/GeoVaLs.h"
22 #include "ufo/Locations.h"
23 
24 namespace soca {
25 
26 // -----------------------------------------------------------------------------
27 /// Constructor, destructor
28 // -----------------------------------------------------------------------------
30  const ufo::Locations & locs,
31  const eckit::Configuration & config)
32  : locs_(locs), geom_(new Geometry(geom)),
33  model2geovals_(new Model2GeoVaLs(geom, config)) {
35 }
36 // -----------------------------------------------------------------------------
38 {
40 }
41 // -----------------------------------------------------------------------------
42 /// Get state values at observation locations
43 // -----------------------------------------------------------------------------
44 void GetValues::fillGeoVaLs(const State & state,
45  const util::DateTime & t1,
46  const util::DateTime & t2,
47  ufo::GeoVaLs & geovals) const {
48  // overwrite with atm geovals
49  // NOTE this is a horrible hack. Remove soon?
50  if (geom_->getAtmInit())
51  {
52  // Get atm geovals
53  // The variables in vars that are also defined in soca will be
54  // over-written in the interpolation call bellow
55  getValuesFromFile(locs_, geovals.getVars(), geovals);
56  }
57 
58  // Do variable change if it has not already been done.
59  // TODO(travis): remove this once Yannick is done rearranging things in oops.
60  std::unique_ptr<State> varChangeState;
61  const State * state_ptr;
62  if (geovals.getVars() <= state.variables()) {
63  state_ptr = &state;
64  } else {
65  varChangeState.reset(new State(*geom_, geovals.getVars(),
66  state.validTime()));
67  model2geovals_->changeVar(state, *varChangeState);
68  state_ptr = varChangeState.get();
69  }
70  // Get ocean geovals
72  geom_->toFortran(),
73  state_ptr->toFortran(),
74  t1, t2, locs_,
75  geovals.toFortran());
76 }
77 // -----------------------------------------------------------------------------
78 /// Read Interpolated GeoVaLs from file
79 // TODO(Guillaume) 3D only, make it 4D
80 // -----------------------------------------------------------------------------
81 void GetValues::getValuesFromFile(const ufo::Locations & locs,
82  const oops::Variables & vars,
83  ufo::GeoVaLs & atmgom) const {
84  // Get Atm configuration
85  eckit::LocalConfiguration conf(geom_->getAtmConf());
86 
87  // Get Time Bounds
88  util::DateTime bgn = util::DateTime(conf.getString("notocean.date_begin"));
89  util::DateTime end = util::DateTime(conf.getString("notocean.date_end"));
90 
91  // Create the Atmospheric Geometry in Observation Space
92  eckit::LocalConfiguration confatmobs(conf, "notocean.obs space");
93  ioda::ObsTopLevelParameters paramsatmobs;
94  paramsatmobs.validateAndDeserialize(confatmobs);
95  ioda::ObsSpace atmobs(paramsatmobs, geom_->getComm(), bgn, end,
96  oops::mpi::myself());
97 
98  // Get GeoVaLs from file
99  eckit::LocalConfiguration confatm(conf, "notocean");
100  atmgom.read(confatm, atmobs);
101  }
102 // -----------------------------------------------------------------------------
103 void GetValues::print(std::ostream & os) const {
104  os << "GetValues" << std::endl;
105 }
106 // -----------------------------------------------------------------------------
107 
108 } // namespace soca
Geometry handles geometry for SOCA model.
Definition: Geometry.h:48
int & toFortran()
Definition: Geometry.h:61
void fillGeoVaLs(const State &, const util::DateTime &t1, const util::DateTime &t2, ufo::GeoVaLs &) const
Get state values at observation locations.
Definition: GetValues.cc:44
virtual ~GetValues()
Definition: GetValues.cc:37
std::shared_ptr< const Geometry > geom_
Definition: GetValues.h:70
ufo::Locations locs_
Definition: GetValues.h:69
void getValuesFromFile(const ufo::Locations &, const oops::Variables &, ufo::GeoVaLs &) const
Read interpolated GeoVaLs at observation location.
Definition: GetValues.cc:81
GetValues(const Geometry &, const ufo::Locations &locs, const eckit::Configuration &config)
saves all locations locs to use during filling GeoVaLs
Definition: GetValues.cc:29
std::unique_ptr< Model2GeoVaLs > model2geovals_
Definition: GetValues.h:71
F90getval keyGetValues_
Definition: GetValues.h:68
void print(std::ostream &) const
Definition: GetValues.cc:103
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_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 &)