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  oops::Log::debug() << "u, v: " << u[jj] << ", "
48  << v[jj] << ", speed=" << out[0][jj] << std::endl;
49  } else {
50  out[0][jj] = missing;
51  oops::Log::debug() << "u and v are missing at index, " << jj << std::endl;
52  }
53  }
54 }
55 
56 // -----------------------------------------------------------------------------
57 
59  return invars_;
60 }
61 
62 // -----------------------------------------------------------------------------
63 
64 } // namespace ufo
ufo::ObsFilterData::nlocs
size_t nlocs() const
Returns number of locations.
Definition: ObsFilterData.cc:66
ufo::Variables
Definition: src/ufo/filters/Variables.h:24
ufo::ObsFunctionVelocity::ObsFunctionVelocity
ObsFunctionVelocity(const eckit::LocalConfiguration)
Definition: ObsFunctionVelocity.cc:23
ufo_radiancerttov_utils_mod::debug
logical, public debug
Definition: ufo_radiancerttov_utils_mod.F90:100
ufo::makerObsFuncVelocity_
static ObsFunctionMaker< ObsFunctionVelocity > makerObsFuncVelocity_("Velocity")
ufo::ObsFunctionVelocity::~ObsFunctionVelocity
~ObsFunctionVelocity()
Definition: ObsFunctionVelocity.cc:32
ufo
Definition: RunCRTM.h:27
ufo::ObsFunctionMaker
Definition: ObsFunctionBase.h:60
ObsFunctionVelocity.h
ufo::QCflags::missing
constexpr int missing
Definition: QCflags.h:15
ufo::ObsFunctionVelocity::group_
std::string group_
Definition: ObsFunctionVelocity.h:31
ufo::ObsFunctionVelocity::requiredVariables
const ufo::Variables & requiredVariables() const
geovals required to compute the function
Definition: ObsFunctionVelocity.cc:58
ufo::ObsFunctionVelocity::compute
void compute(const ObsFilterData &, ioda::ObsDataVector< float > &) const
compute the result of the function
Definition: ObsFunctionVelocity.cc:36
ioda::ObsDataVector
Definition: BackgroundCheck.h:26
ufo::ObsFilterData::get
void get(const Variable &, std::vector< float > &) const
Gets requested data from ObsFilterData.
Definition: ObsFilterData.cc:130
ufo::Variable
Definition: Variable.h:23
ufo::ObsFunctionVelocity::invars_
ufo::Variables invars_
Definition: ObsFunctionVelocity.h:30
ufo::ObsFilterData
ObsFilterData provides access to all data related to an ObsFilter.
Definition: src/ufo/filters/ObsFilterData.h:40
conf
Definition: conf.py:1
Variable.h