UFO
ModelHeightAdjustedMarineWind.cc
Go to the documentation of this file.
1 /* -----------------------------------------------------------------------------
2  * (C) British Crown Copyright 2021 Met Office
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 
9 #include <vector>
10 
11 #include "ioda/ObsDataVector.h"
12 #include "oops/util/missingValues.h"
14 #include "ufo/filters/Variable.h"
15 #include "ufo/utils/Constants.h"
16 
17 namespace ufo {
18 
19 static ObsFunctionMaker<ModelHeightAdjustedEastwardMarineWind>
20  eastwardMaker_("ModelHeightAdjustedEastwardMarineWind");
22  northwardMaker_("ModelHeightAdjustedNorthwardMarineWind");
23 
24 // -----------------------------------------------------------------------------
25 
27  const eckit::LocalConfiguration & conf, const Variable &windComponent)
28  : invars_(), wind_(windComponent) {
29  // Required observation station height
30  invars_ += Variable("anemometer_height@MetaData");
31  // Required wind component
32  invars_ += wind_;
33 }
34 
35 // -----------------------------------------------------------------------------
36 
38  ioda::ObsDataVector<float> & out) const {
39  const size_t nlocs = in.nlocs();
40  std::vector<float> WindComponent(nlocs);
41  std::vector<float> StationHeight(nlocs);
42 
43  in.get(Variable(wind_), WindComponent);
44  in.get(Variable("anemometer_height@MetaData"), StationHeight);
45 
46  const float missing = util::missingValue(missing);
47  const float a = 1.0/0.0016;
48  const float ref_height = std::log(10.0*a);
49  // TODO(jwaller): When QC flaging is availiable add flags indicate corrected values
50  // Compute adjusted marine wind.
51  for (size_t jj = 0; jj < nlocs; ++jj) {
52  if (StationHeight[jj] == missing || WindComponent[jj] == missing) {
53  out[0][jj] = missing;
54  } else {
55  float ScaleFactor = ref_height/std::log(std::abs(StationHeight[jj])*a);
56  out[0][jj] = WindComponent[jj]*ScaleFactor;
57  }
58  }
59 }
60 
61 // -----------------------------------------------------------------------------
62 
64  return invars_;
65 }
66 
67 
68 // -----------------------------------------------------------------------------
69 
70 } // namespace ufo
ModelHeightAdjustedMarineWindComponent(const eckit::LocalConfiguration &conf, const Variable &windComponent)
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
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.
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< ModelHeightAdjustedEastwardMarineWind > eastwardMaker_("ModelHeightAdjustedEastwardMarineWind")
static ObsFunctionMaker< ModelHeightAdjustedNorthwardMarineWind > northwardMaker_("ModelHeightAdjustedNorthwardMarineWind")
util::Duration abs(const util::Duration &duration)