UFO
ImpactHeight.cc
Go to the documentation of this file.
1 /* -----------------------------------------------------------------------------
2  * (C) British Crown Copyright 2020 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 /* -----------------------------------------------------------------------------
10  * Function to calculate the impact height for GNSS-RO. This is the difference
11  * between the impact parameter and the earth's radius of curvature.
12  * -----------------------------------------------------------------------------
13  */
15 
16 #include <math.h>
17 #include <vector>
18 
19 #include "ioda/ObsDataVector.h"
20 #include "oops/util/missingValues.h"
21 #include "ufo/filters/Variable.h"
22 
23 namespace ufo {
24 
26 
27 /* -----------------------------------------------------------------------------
28  * Specify that impact_parameter and earth_radius_of_curvature need to be
29  * provided to this function
30  * -----------------------------------------------------------------------------
31  */
32 ImpactHeight::ImpactHeight(const eckit::LocalConfiguration & conf)
33  : invars_() {
34  invars_ += Variable("impact_parameter@MetaData");
35  invars_ += Variable("earth_radius_of_curvature@MetaData");
36 }
37 
38 // -----------------------------------------------------------------------------
39 
41 
42 /* -----------------------------------------------------------------------------
43  * Perform the computation. Read in the required variables, and calculate
44  * their difference, storing the difference in the output vector.
45  * -----------------------------------------------------------------------------
46  */
48  ioda::ObsDataVector<float> & out) const {
49  const size_t nlocs = in.nlocs();
50  std::vector<float> impact_parameter;
51  in.get(Variable("impact_parameter@MetaData"), impact_parameter);
52  std::vector<float> radius_curvature;
53  in.get(Variable("earth_radius_of_curvature@MetaData"), radius_curvature);
54  for (size_t jj = 0; jj < nlocs; ++jj) {
55  if (impact_parameter[jj] == util::missingValue(impact_parameter[jj]) ||
56  radius_curvature[jj] == util::missingValue(radius_curvature[jj])) {
57  out[0][jj] = util::missingValue(out[0][jj]);
58  } else {
59  out[0][jj] = impact_parameter[jj] - radius_curvature[jj];
60  }
61  }
62 }
63 
64 // -----------------------------------------------------------------------------
65 
67  return invars_;
68 }
69 
70 // -----------------------------------------------------------------------------
71 
72 } // namespace ufo
void compute(const ObsFilterData &, ioda::ObsDataVector< float > &) const
compute the result of the function
Definition: ImpactHeight.cc:47
const ufo::Variables & requiredVariables() const
geovals required to compute the function
Definition: ImpactHeight.cc:66
ImpactHeight(const eckit::LocalConfiguration &)
Definition: ImpactHeight.cc:32
ufo::Variables invars_
Definition: ImpactHeight.h:32
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
static ObsFunctionMaker< ImpactHeight > makerImpactHeight_("ImpactHeight")