UFO
ObsErrorFactorLatRad.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 "ufo/filters/Variable.h"
15 
16 namespace ufo {
17 
19 
20 // -----------------------------------------------------------------------------
21 
22 ObsErrorFactorLatRad::ObsErrorFactorLatRad(const eckit::LocalConfiguration & conf)
23  : invars_() {
24  // Check options
25  options_.deserialize(conf);
26 
27  ASSERT((options_.latitudeParameters.value()).size() == 4);
28 
29  invars_ += Variable("latitude@MetaData");
30 }
31 
32 // -----------------------------------------------------------------------------
33 
35 
36 // -----------------------------------------------------------------------------
37 
39  ioda::ObsDataVector<float> & out) const {
40  // Get parameters from options
41  const std::vector<float> &params = options_.latitudeParameters.value();
42 
43  const size_t nlocs = in.nlocs();
44  std::vector<float> lats;
45  in.get(Variable("latitude@MetaData"), lats);
46  for (size_t jj = 0; jj < nlocs; ++jj) {
47  out[0][jj] = 1.0;
48  if ( std::abs(lats[jj]) < params[0] ) {
49  out[0][jj] = params[1] *(std::abs(lats[jj]) * params[2] + params[3]);
50  }
51  out[0][jj] = sqrt(1.0 / out[0][jj]);
52  }
53 }
54 
55 // -----------------------------------------------------------------------------
56 
58  return invars_;
59 }
60 
61 // -----------------------------------------------------------------------------
62 
63 } // namespace ufo
ObsErrorFactorLatRad(const eckit::LocalConfiguration &)
void compute(const ObsFilterData &, ioda::ObsDataVector< float > &) const
compute the result of the function
ObsErrorFactorLatRadParameters options_
const ufo::Variables & requiredVariables() const
geovals required to compute the function
oops::RequiredParameter< std::vector< float > > latitudeParameters
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.
integer function nlocs(this)
Return the number of observational locations in this Locations object.
Definition: RunCRTM.h:27
util::Duration abs(const util::Duration &duration)
static ObsFunctionMaker< ObsErrorFactorLatRad > makerObsErrorFactorLatRad_("ObsErrorFactorLatRad")