UFO
GeoVaLs.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2017-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 "ufo/GeoVaLs.h"
9 
10 #include <cassert>
11 #include <iomanip>
12 #include <utility>
13 #include <vector>
14 
15 #include "eckit/config/Configuration.h"
16 #include "eckit/exception/Exceptions.h"
17 
18 #include "ioda/distribution/Accumulator.h"
19 #include "ioda/distribution/Distribution.h"
20 #include "ioda/ObsSpace.h"
21 
22 #include "oops/base/Variables.h"
23 #include "oops/util/Logger.h"
24 
25 #include "ufo/Fortran.h"
26 #include "ufo/Locations.h"
27 
28 namespace ufo {
29 
30 // -----------------------------------------------------------------------------
31 /*! \brief Deprecated default constructor - does not allocate fields.
32  *
33  * \details Please do not use this constructor in new code.
34  */
35 GeoVaLs::GeoVaLs(std::shared_ptr<const ioda::Distribution> dist,
36  const oops::Variables & vars)
37  : keyGVL_(-1), vars_(vars), dist_(std::move(dist))
38 {
39  oops::Log::trace() << "GeoVaLs default constructor starting" << std::endl;
41  oops::Log::trace() << "GeoVaLs default constructor end" << std::endl;
42 }
43 
44 /*! \brief Deprecated constructor given Locations and Variables
45  *
46  * \details Please do not use in any new code. This constructor is currently
47  * only used for ObsDiagnostics and will be removed soon. Use the
48  * GeoVaLs(const Locations &, const oops::Variables &, const std::vector<size_t> &)
49  * constructor instead.
50  * This ufo::GeoVaLs constructor is used to initialize GeoVaLs for specified
51  * ufo::Locations and oops::Variables hold all. Note that nothing is allocated
52  * when this constructor is called.
53  */
54 GeoVaLs::GeoVaLs(const Locations & locs, const oops::Variables & vars)
55  : keyGVL_(-1), vars_(vars), dist_(locs.distribution())
56 {
57  oops::Log::trace() << "GeoVaLs contructor starting" << std::endl;
59  oops::Log::trace() << "GeoVaLs contructor key = " << keyGVL_ << std::endl;
60 }
61 
62 // -----------------------------------------------------------------------------
63 /*! \brief Allocating constructor for specified Locations \p locs, Variables \p vars
64  * and number of levels \p nlevs
65  *
66  * \details This ufo::GeoVaLs constructor is used in all oops H(x) and DA
67  * applications.
68  * Sizes of GeoVaLs for i-th variable at a single location are defined by i-th value
69  * of \p nlevs.
70  */
71 GeoVaLs::GeoVaLs(const Locations & locs, const oops::Variables & vars,
72  const std::vector<size_t> & nlevs)
73  : keyGVL_(-1), vars_(vars), dist_(locs.distribution())
74 {
75  oops::Log::trace() << "GeoVaLs contructor starting" << std::endl;
76  ufo_geovals_setup_f90(keyGVL_, locs.size(), vars_, nlevs.size(), nlevs[0]);
77  oops::Log::trace() << "GeoVaLs contructor key = " << keyGVL_ << std::endl;
78 }
79 
80 // -----------------------------------------------------------------------------
81 /*! \brief Constructor for tests
82  *
83  * \details This ufo::GeoVaLs constructor is typically used in tests, GeoVaLs
84  * are read from the file.
85  */
86 GeoVaLs::GeoVaLs(const eckit::Configuration & config,
87  const ioda::ObsSpace & obspace,
88  const oops::Variables & vars)
89  : keyGVL_(-1), vars_(vars), dist_(obspace.distribution())
90 {
91  oops::Log::trace() << "GeoVaLs constructor config starting" << std::endl;
93  // only read if there are variables specified
94  if (vars_.size() > 0) ufo_geovals_read_file_f90(keyGVL_, config, obspace, vars_);
95  oops::Log::trace() << "GeoVaLs contructor config key = " << keyGVL_ << std::endl;
96 }
97 // -----------------------------------------------------------------------------
98 /*! \brief Construct a new GeoVaLs with just one location
99 *
100 * \details This ufo::GeoVaLs constructor takes a GeoVaLs object and an index to
101 * create a new GeoVaLs with just one location
102 */
103 GeoVaLs::GeoVaLs(const GeoVaLs & other, const int & index)
104  : keyGVL_(-1), vars_(other.vars_), dist_(other.dist_)
105 {
106  oops::Log::trace() << "GeoVaLs copy one GeoVaLs constructor starting" << std::endl;
108  oops::Log::trace() << "GeoVaLs copy one GeoVaLs constructor key = " << keyGVL_ << std::endl;
109 }
110 // -----------------------------------------------------------------------------
111 /*! \brief Copy constructor */
112 
113 GeoVaLs::GeoVaLs(const GeoVaLs & other)
114  : keyGVL_(-1), vars_(other.vars_), dist_(other.dist_)
115 {
116  oops::Log::trace() << "GeoVaLs copy constructor starting" << std::endl;
118  oops::Log::trace() << "GeoVaLs copy constructor key = " << keyGVL_ << std::endl;
119 }
120 // -----------------------------------------------------------------------------
121 /*? \brief Destructor */
123  oops::Log::trace() << "GeoVaLs destructor starting" << std::endl;
125  oops::Log::trace() << "GeoVaLs destructor done" << std::endl;
126 }
127 // -----------------------------------------------------------------------------
128 void GeoVaLs::allocate(const int & nlevels, const oops::Variables & vars)
129 {
130  oops::Log::trace() << "GeoVaLs::allocate starting" << std::endl;
131  ufo_geovals_allocate_f90(keyGVL_, nlevels, vars);
132  oops::Log::trace() << "GeoVaLs::allocate done" << std::endl;
133 }
134 // -----------------------------------------------------------------------------
135 /*! \brief Zero out the GeoVaLs */
137  oops::Log::trace() << "GeoVaLs::zero starting" << std::endl;
139  oops::Log::trace() << "GeoVaLs::zero done" << std::endl;
140 }
141 // -----------------------------------------------------------------------------
142 /*! \brief Reorder GeoVaLs in vertical dimension based on vertical coordinate variable */
143 void GeoVaLs::reorderzdir(const std::string & varname, const std::string & vardir) {
144  oops::Log::trace() << "GeoVaLs::reorderzdir starting" << std::endl;
145  ufo_geovals_reorderzdir_f90(keyGVL_, varname.size(), varname.c_str(),
146  vardir.size(), vardir.c_str());
147  oops::Log::trace() << "GeoVaLs::reorderzdir done" << std::endl;
148 }
149 // -----------------------------------------------------------------------------
150 /*! \brief Calculate rms */
151 double GeoVaLs::rms() const {
152  oops::Log::trace() << "GeoVaLs::rms starting" << std::endl;
153  double zz;
155  oops::Log::trace() << "GeoVaLs::rms done" << std::endl;
156  return zz;
157 }
158 // -----------------------------------------------------------------------------
159 /*! \brief Calculate normalized rms */
160 double GeoVaLs::normalizedrms(const GeoVaLs & other) const {
161  oops::Log::trace() << "GeoVaLs::normalizerms starting" << std::endl;
162  GeoVaLs temp_gval(*this);
163  ufo_geovals_normalize_f90(temp_gval.keyGVL_, other.keyGVL_);
164  double zz = temp_gval.rms();
165  oops::Log::trace() << "GeoVaLs::normalizerms done" << std::endl;
166  return zz;
167 }
168 // -----------------------------------------------------------------------------
169 /*! \brief Randomize GeoVaLs */
171  oops::Log::trace() << "GeoVaLs::random starting" << std::endl;
173  oops::Log::trace() << "GeoVaLs::random done" << std::endl;
174 }
175 // -----------------------------------------------------------------------------
176 /*! \brief Multiply by a constant scalar */
177 GeoVaLs & GeoVaLs::operator*=(const double zz) {
178  oops::Log::trace() << "GeoVaLs::operator*= starting" << std::endl;
180  oops::Log::trace() << "GeoVaLs::operator*= done" << std::endl;
181  return *this;
182 }
183 // -----------------------------------------------------------------------------
184 /*! \brief Multiply by a constant scalar for each profile */
185 GeoVaLs & GeoVaLs::operator*=(const std::vector<float> & vals) {
186  oops::Log::trace() << "GeoVaLs::operator*= starting" << std::endl;
187  size_t nlocs;
189  oops::Log::trace() << "vals, nlocs = " << vals.size() << " " << nlocs << std::endl;
190  ASSERT(vals.size() == nlocs);
192  oops::Log::trace() << "GeoVaLs::operator*= done" << std::endl;
193  return *this;
194 }
195 // -----------------------------------------------------------------------------
196 /*! \brief Copy operator */
198  oops::Log::trace() << "GeoVaLs::operator= starting" << std::endl;
200  oops::Log::trace() << "GeoVaLs::operator= done" << std::endl;
201  return *this;
202 }
203 // -----------------------------------------------------------------------------
204 /*! \brief Add another GeoVaLs */
206  oops::Log::trace() << "GeoVaLs::operator+= starting" << std::endl;
208  oops::Log::trace() << "GeoVaLs::operator+= done" << std::endl;
209  return *this;
210 }
211 // -----------------------------------------------------------------------------
212 /*! \brief Subtract another GeoVaLs */
214  oops::Log::trace() << "GeoVaLs::operator-= starting" << std::endl;
216  oops::Log::trace() << "GeoVaLs::operator-= done" << std::endl;
217  return *this;
218 }
219 // -----------------------------------------------------------------------------
220 /*! \brief Multiply another GeoVaLs */
222  oops::Log::trace() << "GeoVaLs::operator*= starting" << std::endl;
224  oops::Log::trace() << "GeoVaLs::operator*= done" << std::endl;
225  return *this;
226 }
227 // -----------------------------------------------------------------------------
228 /*! \brief Scalar product of two GeoVaLs */
229 double GeoVaLs::dot_product_with(const GeoVaLs & other) const {
230  oops::Log::trace() << "GeoVaLs::dot_product_with starting" << std::endl;
231  const size_t nlocs = this->nlocs();
232  assert(nlocs == other.nlocs());
233  assert(vars_ == other.vars_);
234  auto accumulator = dist_->createAccumulator<double>();
235  std::vector<double> this_values(nlocs), other_values(nlocs);
236  const double missing = util::missingValue(missing);
237  // loop over all variables in geovals
238  for (size_t jvar = 0; jvar < vars_.size(); ++jvar) {
239  const size_t nlevs = this->nlevs(vars_[jvar]);
240  assert(nlevs == other.nlevs(vars_[jvar]));
241  // loop over all levels for this variable
242  for (size_t jlev = 0; jlev < nlevs; ++jlev) {
243  this->getAtLevel(this_values, vars_[jvar], jlev);
244  other.getAtLevel(other_values, vars_[jvar], jlev);
245  // loop over all locations
246  for (size_t jloc = 0; jloc < nlocs; ++jloc) {
247  if ((this_values[jloc] != missing) && (other_values[jloc] != missing)) {
248  accumulator->addTerm(jloc, this_values[jloc]*other_values[jloc]);
249  }
250  }
251  }
252  }
253  const double dotprod = accumulator->computeResult();
254  oops::Log::trace() << "GeoVaLs::dot_product_with done" << std::endl;
255  return dotprod;
256 }
257 // -----------------------------------------------------------------------------
258 /*! \brief Split two GeoVaLs */
259 void GeoVaLs::split(GeoVaLs & other1, GeoVaLs & other2) const {
260  oops::Log::trace() << "GeoVaLs::split GeoVaLs into 2" << std::endl;
261  ufo_geovals_split_f90(keyGVL_, other1.keyGVL_, other2.keyGVL_);
262  oops::Log::trace() << "GeoVaLs::split GeoVaLs into 2" << std::endl;
263  return;
264 }
265 // -----------------------------------------------------------------------------
266 /*! \brief Merge two GeoVaLs */
267 void GeoVaLs::merge(const GeoVaLs & other1, const GeoVaLs & other2) {
268  oops::Log::trace() << "GeoVaLs::merge 2 GeoVaLs" << std::endl;
269  ufo_geovals_merge_f90(keyGVL_, other1.keyGVL_, other2.keyGVL_);
270  oops::Log::trace() << "GeoVaLs::merge 2 GeoVaLs" << std::endl;
271  return;
272 }
273 // -----------------------------------------------------------------------------
274 /*! \brief Output GeoVaLs to a stream */
275 void GeoVaLs::print(std::ostream & os) const {
276  int nn;
277  double zmin, zmax, zrms;
278 
279  os << "GeoVaLs: variables = " << vars_ << std::endl;
280  for (size_t jv = 0; jv < vars_.size(); ++jv) {
281  int nv = jv;
282  ufo_geovals_minmaxavg_f90(keyGVL_, nn, nv, zmin, zmax, zrms);
283  os << "GeoVaLs: nobs= " << nn << " " << vars_[jv] << " Min=" << zmin << ", Max=" << zmax
284  << ", RMS=" << zrms << std::endl;
285  }
286 
287  /*! Verbose print statement (debug mode)
288  *
289  * \detail If the min value across all variables is positive, then this may be
290  * an error measurement. If so, compute the rms over the vertical profile and
291  * tell the user where the maximum rms value occurs, in terms of the
292  * observation number and the variable number. This is intended to help
293  * with debugging.
294  */
295 
296  if (zmin >= 0.0) {
297  double mxval;
298  int ivar, iobs;
299 
300  ufo_geovals_maxloc_f90(keyGVL_, mxval, iobs, ivar);
301 
302  oops::Log::debug() << "GeoVaLs: Maximum Value (vertical rms) = "
303  << std::setprecision(4)
304  << mxval << " for observation = " << iobs
305  << " and variable = " << ivar << std::endl;
306  }
307 }
308 // -----------------------------------------------------------------------------
309 /*! \brief Return number of levels for a specified variable */
310 size_t GeoVaLs::nlevs(const std::string & var) const {
311  oops::Log::trace() << "GeoVaLs::nlevs starting" << std::endl;
312  int nlevs;
313  ufo_geovals_nlevs_f90(keyGVL_, var.size(), var.c_str(), nlevs);
314  oops::Log::trace() << "GeoVaLs::nlevs done" << std::endl;
315  return nlevs;
316 }
317 // -----------------------------------------------------------------------------
318 /*! \brief Return all values for a specific 2D variable */
319 void GeoVaLs::get(std::vector<float> & vals, const std::string & var) const {
320  oops::Log::trace() << "GeoVaLs::get 2D starting" << std::endl;
321  /// Call method to get double values (Fortran data structure stores data in double)
322  /// and convert to floats
323  std::vector<double> doublevals(vals.size());
324  this->get(doublevals, var);
325  vals.assign(doublevals.begin(), doublevals.end());
326  oops::Log::trace() << "GeoVaLs::get 2D done" << std::endl;
327 }
328 // -----------------------------------------------------------------------------
329 /*! \brief Return all values for a specific variable and level */
330 void GeoVaLs::getAtLevel(std::vector<double> & vals, const std::string & var, const int lev) const {
331  oops::Log::trace() << "GeoVaLs::getAtLevel(double) starting" << std::endl;
332  size_t nlocs;
334  ASSERT(vals.size() == nlocs);
335  ufo_geovals_getdouble_f90(keyGVL_, var.size(), var.c_str(), lev, nlocs, vals[0]);
336  oops::Log::trace() << "GeoVaLs::getAtLevel(double) done" << std::endl;
337 }
338 // -----------------------------------------------------------------------------
339 /*! \brief Return all values for a specific variable and level and convert to float */
340 void GeoVaLs::getAtLevel(std::vector<float> & vals, const std::string & var, const int lev) const {
341  oops::Log::trace() << "GeoVaLs::getAtLevel(float) starting" << std::endl;
342  size_t nlocs;
344  ASSERT(vals.size() == nlocs);
345  ufo_geovals_get_f90(keyGVL_, var.size(), var.c_str(), lev, nlocs, vals[0]);
346  oops::Log::trace() << "GeoVaLs::getAtLevel(float) done" << std::endl;
347 }
348 // -----------------------------------------------------------------------------
349 /*! \brief Return all values for a specific variable and level and convert to int */
350 void GeoVaLs::getAtLevel(std::vector<int> & vals, const std::string & var, const int lev) const {
351  oops::Log::trace() << "GeoVaLs::getAtLevel(int) starting" << std::endl;
352  std::vector<double> doublevals(vals.size());
353  this->getAtLevel(doublevals, var, lev);
354  vals.assign(doublevals.begin(), doublevals.end());
355  oops::Log::trace() << "GeoVaLs::getAtLevel(int) done" << std::endl;
356 }
357 // -----------------------------------------------------------------------------
358 /*! \brief Return all values for a specific 2D variable */
359 void GeoVaLs::get(std::vector<double> & vals, const std::string & var) const {
360  oops::Log::trace() << "GeoVaLs::get 2D starting" << std::endl;
361  size_t nlocs;
363  ASSERT(vals.size() == nlocs);
364  ufo_geovals_get2d_f90(keyGVL_, var.size(), var.c_str(), nlocs, vals[0]);
365  oops::Log::trace() << "GeoVaLs::get 2D done" << std::endl;
366 }
367 // -----------------------------------------------------------------------------
368 /*! \brief Return all values for a specific 2D variable */
369 void GeoVaLs::get(std::vector<int> & vals, const std::string & var) const {
370  oops::Log::trace() << "GeoVaLs::get 2D starting" << std::endl;
371  /// Call method to get double values (Fortran data structure stores data in double)
372  /// and convert to ints
373  std::vector<double> doublevals(vals.size());
374  this->get(doublevals, var);
375  vals.assign(doublevals.begin(), doublevals.end());
376  oops::Log::trace() << "GeoVaLs::get 2D done" << std::endl;
377 }
378 // -----------------------------------------------------------------------------
379 /*! \brief Return all values for a specific variable and location */
380 void GeoVaLs::getAtLocation(std::vector<double> & vals,
381  const std::string & var,
382  const int loc) const {
383  oops::Log::trace() << "GeoVaLs::getAtLocation(double) starting" << std::endl;
384  const size_t nlevs = this->nlevs(var);
385  ASSERT(vals.size() == nlevs);
386  ASSERT(loc >= 0 && loc < this->nlocs());
387  ufo_geovals_get_loc_f90(keyGVL_, var.size(), var.c_str(), loc, nlevs, vals[0]);
388  oops::Log::trace() << "GeoVaLs::getAtLocation(double) done" << std::endl;
389 }
390 // -----------------------------------------------------------------------------
391 /*! \brief Return all values for a specific variable and location and convert to float */
392 void GeoVaLs::getAtLocation(std::vector<float> & vals,
393  const std::string & var,
394  const int loc) const {
395  oops::Log::trace() << "GeoVaLs::getAtLocation(float) starting" << std::endl;
396  std::vector <double> doublevals(vals.size());
397  this->getAtLocation(doublevals, var, loc);
398  vals.assign(doublevals.begin(), doublevals.end());
399  oops::Log::trace() << "GeoVaLs::getAtLocation(float) done" << std::endl;
400 }
401 // -----------------------------------------------------------------------------
402 /*! \brief Return all values for a specific variable and location and convert to int */
403 void GeoVaLs::getAtLocation(std::vector<int> & vals,
404  const std::string & var,
405  const int loc) const {
406  oops::Log::trace() << "GeoVaLs::getAtLocation(int) starting" << std::endl;
407  std::vector <double> doublevals(vals.size());
408  this->getAtLocation(doublevals, var, loc);
409  vals.assign(doublevals.begin(), doublevals.end());
410  oops::Log::trace() << "GeoVaLs::getAtLocation(int) done" << std::endl;
411 }
412 // -----------------------------------------------------------------------------
413 /*! \brief Put double values for a specific variable and level */
414 void GeoVaLs::putAtLevel(const std::vector<double> & vals,
415  const std::string & var,
416  const int lev) const {
417  oops::Log::trace() << "GeoVaLs::putAtLevel(double) starting" << std::endl;
418  size_t nlocs;
420  ASSERT(vals.size() == nlocs);
421  ufo_geovals_putdouble_f90(keyGVL_, var.size(), var.c_str(), lev, nlocs, vals[0]);
422  oops::Log::trace() << "GeoVaLs::putAtLevel(double) done" << std::endl;
423 }
424 // -----------------------------------------------------------------------------
425 /*! \brief Put float values for a specific variable and level */
426 void GeoVaLs::putAtLevel(const std::vector<float> & vals,
427  const std::string & var,
428  const int lev) const {
429  oops::Log::trace() << "GeoVaLs::putAtLevel(float) starting" << std::endl;
430  size_t nlocs;
432  ASSERT(vals.size() == nlocs);
433  std::vector<double> doublevals(vals.begin(), vals.end());
434  ufo_geovals_putdouble_f90(keyGVL_, var.size(), var.c_str(), lev, nlocs, doublevals[0]);
435  oops::Log::trace() << "GeoVaLs::putAtLevel(float) done" << std::endl;
436 }
437 // -----------------------------------------------------------------------------
438 /*! \brief Put int values for a specific variable and level */
439 void GeoVaLs::putAtLevel(const std::vector<int> & vals,
440  const std::string & var,
441  const int lev) const {
442  oops::Log::trace() << "GeoVaLs::putAtLevel(int) starting" << std::endl;
443  size_t nlocs;
445  ASSERT(vals.size() == nlocs);
446  std::vector<double> doublevals(vals.begin(), vals.end());
447  ufo_geovals_putdouble_f90(keyGVL_, var.size(), var.c_str(), lev, nlocs, doublevals[0]);
448  oops::Log::trace() << "GeoVaLs::putAtLevel(int) done" << std::endl;
449 }
450 /*! \brief Put double values for a specific variable and location */
451 void GeoVaLs::putAtLocation(const std::vector<double> & vals,
452  const std::string & var,
453  const int loc) const {
454  oops::Log::trace() << "GeoVaLs::putAtLocation(double) starting" << std::endl;
455  const size_t nlevs = this->nlevs(var);
456  ASSERT(vals.size() == nlevs);
457  ASSERT(loc >= 0 && loc < this->nlocs());
458  ufo_geovals_put_loc_f90(keyGVL_, var.size(), var.c_str(), loc, nlevs, vals[0]);
459  oops::Log::trace() << "GeoVaLs::putAtLocation(double) done" << std::endl;
460 }
461 /*! \brief Put float values for a specific variable and location */
462 void GeoVaLs::putAtLocation(const std::vector<float> & vals,
463  const std::string & var,
464  const int loc) const {
465  oops::Log::trace() << "GeoVaLs::putAtLocation(float) starting" << std::endl;
466  const size_t nlevs = this->nlevs(var);
467  ASSERT(vals.size() == nlevs);
468  ASSERT(loc >= 0 && loc < this->nlocs());
469  std::vector<double> doublevals(vals.begin(), vals.end());
470  ufo_geovals_put_loc_f90(keyGVL_, var.size(), var.c_str(), loc, nlevs, doublevals[0]);
471  oops::Log::trace() << "GeoVaLs::putAtLocation(float) done" << std::endl;
472 }
473 /*! \brief Put int values for a specific variable and location */
474 void GeoVaLs::putAtLocation(const std::vector<int> & vals,
475  const std::string & var,
476  const int loc) const {
477  oops::Log::trace() << "GeoVaLs::putAtLocation(int) starting" << std::endl;
478  const size_t nlevs = this->nlevs(var);
479  ASSERT(vals.size() == nlevs);
480  ASSERT(loc >= 0 && loc < this->nlocs());
481  std::vector<double> doublevals(vals.begin(), vals.end());
482  ufo_geovals_put_loc_f90(keyGVL_, var.size(), var.c_str(), loc, nlevs, doublevals[0]);
483  oops::Log::trace() << "GeoVaLs::putAtLocation(int) done" << std::endl;
484 }
485 // -----------------------------------------------------------------------------
486 /*! \brief Read GeoVaLs from the file */
487 void GeoVaLs::read(const eckit::Configuration & config,
488  const ioda::ObsSpace & obspace) {
489  oops::Log::trace() << "GeoVaLs::read starting" << std::endl;
490  ufo_geovals_read_file_f90(keyGVL_, config, obspace, vars_);
491  oops::Log::trace() << "GeoVaLs::read done" << std::endl;
492 }
493 // -----------------------------------------------------------------------------
494 /*! \brief Write GeoVaLs to the file */
495 void GeoVaLs::write(const eckit::Configuration & config) const {
496  oops::Log::trace() << "GeoVaLs::write starting" << std::endl;
497  ufo_geovals_write_file_f90(keyGVL_, config, dist_->rank());
498  oops::Log::trace() << "GeoVaLs::write done" << std::endl;
499 }
500 // -----------------------------------------------------------------------------
501 /*! \brief Return the number of geovals */
502 size_t GeoVaLs::nlocs() const {
503  oops::Log::trace() << "GeoVaLs::nlocs starting" << std::endl;
504  size_t nlocs;
506  oops::Log::trace() << "GeoVaLs::nlocs done" << std::endl;
507  return nlocs;
508 }
509 // -----------------------------------------------------------------------------
510 } // namespace ufo
GeoVaLs: geophysical values at locations.
GeoVaLs & operator+=(const GeoVaLs &)
Add another GeoVaLs.
Definition: GeoVaLs.cc:205
size_t nlevs(const std::string &var) const
Return number of levels for a specified variable.
Definition: GeoVaLs.cc:310
std::shared_ptr< const ioda::Distribution > dist_
void split(GeoVaLs &, GeoVaLs &) const
Split two GeoVaLs.
Definition: GeoVaLs.cc:259
void zero()
Zero out the GeoVaLs.
Definition: GeoVaLs.cc:136
void print(std::ostream &) const
Output GeoVaLs to a stream.
Definition: GeoVaLs.cc:275
void reorderzdir(const std::string &, const std::string &)
Reorder GeoVaLs in vertical dimension based on vertical coordinate variable.
Definition: GeoVaLs.cc:143
GeoVaLs & operator*=(const double)
Multiply by a constant scalar.
Definition: GeoVaLs.cc:177
oops::Variables vars_
double dot_product_with(const GeoVaLs &) const
Scalar product of two GeoVaLs.
Definition: GeoVaLs.cc:229
void write(const eckit::Configuration &) const
Write GeoVaLs to the file.
Definition: GeoVaLs.cc:495
double rms() const
Calculate rms.
Definition: GeoVaLs.cc:151
GeoVaLs(std::shared_ptr< const ioda::Distribution >, const oops::Variables &)
Deprecated default constructor - does not allocate fields.
Definition: GeoVaLs.cc:35
void getAtLevel(std::vector< double > &, const std::string &, const int) const
Get GeoVaLs at a specified level.
Definition: GeoVaLs.cc:330
void putAtLocation(const std::vector< double > &vals, const std::string &var, const int loc) const
Put GeoVaLs for double variable var at location loc.
Definition: GeoVaLs.cc:451
size_t nlocs() const
Return the number of geovals.
Definition: GeoVaLs.cc:502
GeoVaLs & operator-=(const GeoVaLs &)
Subtract another GeoVaLs.
Definition: GeoVaLs.cc:213
void read(const eckit::Configuration &, const ioda::ObsSpace &)
Read GeoVaLs from the file.
Definition: GeoVaLs.cc:487
void allocate(const int &nlev, const oops::Variables &vars)
Deprecated method. Allocates GeoVaLs for vars variables with nlev number of levels.
Definition: GeoVaLs.cc:128
double normalizedrms(const GeoVaLs &) const
Calculate normalized rms.
Definition: GeoVaLs.cc:160
void get(std::vector< double > &, const std::string &var) const
Get 2D GeoVaLs for variable var (fails for 3D GeoVaLs)
Definition: GeoVaLs.cc:359
void merge(const GeoVaLs &, const GeoVaLs &)
Merge two GeoVaLs.
Definition: GeoVaLs.cc:267
void putAtLevel(const std::vector< double > &vals, const std::string &var, const int lev) const
Put GeoVaLs for double variable var at level lev.
Definition: GeoVaLs.cc:414
void random()
Randomize GeoVaLs.
Definition: GeoVaLs.cc:170
void getAtLocation(std::vector< double > &, const std::string &, const int) const
Get GeoVaLs at a specified location.
Definition: GeoVaLs.cc:380
GeoVaLs & operator=(const GeoVaLs &)
Copy operator.
Definition: GeoVaLs.cc:197
Locations class to handle simple lat-lon-time locations.
size_t size() const
size of locations
Definition: Locations.cc:96
constexpr int missing
Definition: QCflags.h:20
Definition: RunCRTM.h:27
void ufo_geovals_rms_f90(const F90goms &, double &)
void ufo_geovals_copy_one_f90(F90goms &, const F90goms &, const int &)
void ufo_geovals_get_loc_f90(const F90goms &, const int &, const char *, const int &, const int &, double &)
void ufo_geovals_read_file_f90(const F90goms &, const eckit::Configuration &, const ioda::ObsSpace &, const oops::Variables &)
void ufo_geovals_split_f90(const F90goms &, const F90goms &, const F90goms &)
void ufo_geovals_profmult_f90(const F90goms &, const int &, const float &)
void ufo_geovals_delete_f90(F90goms &)
void ufo_geovals_partial_setup_f90(F90goms &key, const size_t &nlocs, const oops::Variables &vars)
void ufo_geovals_copy_f90(const F90goms &, F90goms &)
void ufo_geovals_nlocs_f90(const F90goms &, size_t &)
void ufo_geovals_put_loc_f90(const F90goms &, const int &, const char *, const int &, const int &, const double &)
void ufo_geovals_scalmult_f90(const F90goms &, const double &)
void ufo_geovals_nlevs_f90(const F90goms &, const int &, const char *, int &)
void ufo_geovals_maxloc_f90(const F90goms &, double &, int &, int &)
void ufo_geovals_zero_f90(const F90goms &)
void ufo_geovals_default_constr_f90(F90goms &)
Interface to Fortran UFO GeoVals routines.
void ufo_geovals_random_f90(const F90goms &)
void ufo_geovals_getdouble_f90(const F90goms &, const int &, const char *, const int &, const int &, double &)
void ufo_geovals_assign_f90(const F90goms &, const F90goms &)
void ufo_geovals_setup_f90(F90goms &key, const size_t &nlocs, const oops::Variables &vars, const size_t &nvars, const size_t &nlevs)
void ufo_geovals_normalize_f90(const F90goms &, const F90goms &)
void ufo_geovals_write_file_f90(const F90goms &, const eckit::Configuration &, const size_t &)
void ufo_geovals_merge_f90(const F90goms &, const F90goms &, const F90goms &)
void ufo_geovals_get_f90(const F90goms &, const int &, const char *, const int &, const int &, float &)
void ufo_geovals_diff_f90(const F90goms &, const F90goms &)
void ufo_geovals_schurmult_f90(const F90goms &, const F90goms &)
void ufo_geovals_putdouble_f90(const F90goms &, const int &, const char *, const int &, const int &, const double &)
void ufo_geovals_allocate_f90(const F90goms &, const size_t &nlevels, const oops::Variables &vars)
void ufo_geovals_reorderzdir_f90(const F90goms &, const int &, const char *, const int &, const char *)
void ufo_geovals_get2d_f90(const F90goms &, const int &, const char *, const int &, double &)
void ufo_geovals_minmaxavg_f90(const F90goms &, int &, int &, double &, double &, double &)
void ufo_geovals_add_f90(const F90goms &, const F90goms &)