UFO
ObsFunctionVelocity.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2019 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 
9 
10 #include <math.h>
11 #include <vector>
12 
13 #include "ioda/ObsDataVector.h"
14 #include "oops/util/missingValues.h"
15 #include "ufo/filters/Variable.h"
16 
17 namespace ufo {
18 
20 
21 // -----------------------------------------------------------------------------
22 
23 ObsFunctionVelocity::ObsFunctionVelocity(const eckit::LocalConfiguration conf)
24  : invars_(), group_() {
25  group_ = conf.getString("type", "ObsValue");
26  invars_ += Variable("eastward_wind@" + group_);
27  invars_ += Variable("northward_wind@" + group_);
28 }
29 
30 // -----------------------------------------------------------------------------
31 
33 
34 // -----------------------------------------------------------------------------
35 
37  ioda::ObsDataVector<float> & out) const {
38  // TODO(AS): should use constants for variable names
39  const size_t nlocs = in.nlocs();
40  const float missing = util::missingValue(missing);
41  std::vector<float> u, v;
42  in.get(Variable("eastward_wind@" + group_), u);
43  in.get(Variable("northward_wind@" + group_), v);
44  for (size_t jj = 0; jj < nlocs; ++jj) {
45  if (u[jj] != missing && v[jj] != missing) {
46  out[0][jj] = sqrt(u[jj]*u[jj] + v[jj]*v[jj]);
47  } else {
48  out[0][jj] = missing;
49  }
50  }
51 }
52 
53 // -----------------------------------------------------------------------------
54 
56  return invars_;
57 }
58 
59 // -----------------------------------------------------------------------------
60 
61 } // namespace ufo
ObsFilterData provides access to all data related to an ObsFilter.
size_t nlocs() const
Returns the number of locations in the associated ObsSpace.
void get(const Variable &varname, std::vector< float > &values) const
Fills a std::vector with values of the specified variable.
void compute(const ObsFilterData &, ioda::ObsDataVector< float > &) const
compute the result of the function
const ufo::Variables & requiredVariables() const
geovals required to compute the function
ObsFunctionVelocity(const eckit::LocalConfiguration)
constexpr int missing
Definition: QCflags.h:20
integer function nlocs(this)
Return the number of observational locations in this Locations object.
Definition: RunCRTM.h:27
static ObsFunctionMaker< ObsFunctionVelocity > makerObsFuncVelocity_("Velocity")