UFO
InterpolateDataFromFile.h
Go to the documentation of this file.
1 /*
2  * (C) 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 #ifndef UFO_PREDICTORS_INTERPOLATEDATAFROMFILE_H_
9 #define UFO_PREDICTORS_INTERPOLATEDATAFROMFILE_H_
10 
11 #include <map>
12 #include <memory>
13 #include <string>
14 #include <vector>
15 
16 #include "oops/util/parameters/Parameter.h"
17 #include "oops/util/parameters/Parameters.h"
18 #include "oops/util/parameters/RequiredParameter.h"
19 
22 
23 namespace ufo {
24 
25 class VariableCorrectionParameters : public oops::Parameters {
26  OOPS_CONCRETE_PARAMETERS(VariableCorrectionParameters, Parameters)
27 
28  public:
29  /// Name of the variable to be bias-corrected.
30  oops::RequiredParameter<std::string> name{"name", this};
31 
32  /// Options controlling bias correction of this variable.
34 };
35 
36 /// Configuration parameters of the `interpolate_data_from_file` predictor.
39 
40  public:
41  oops::Parameter<std::vector<VariableCorrectionParameters>> correctedVariables{
42  "corrected variables", {}, this};
43 };
44 
45 /// \brief A predictor returning values produced by the DrawValueFromFile ObsFunction.
46 ///
47 /// Let's start with a simple example. Suppose this predictor is configured with the following
48 /// YAML snippet:
49 ///
50 /// \code{.yaml}
51 /// name: interpolate_data_from_file
52 /// options:
53 /// corrected variables:
54 /// - name: air_temperature
55 /// file: Data/ufo/testinput_tier_1/air_temperature_bias.nc4
56 /// interpolation:
57 /// - name: station_id@MetaData
58 /// method: exact
59 /// \endcode
60 ///
61 /// and the `air_temperature_bias.nc4` file contains a 1D array `air_temperature@ObsBias` indexed
62 /// by a `station_id@MetaData` coordinate. The DrawValueFromFile ObsFunction will then load this
63 /// file and for each location produce the element of the `air_temperature@ObsBias` array
64 /// corresponding to the element of the `station_id@MetaData` array matching the value of the
65 /// `station_id@MetaData` ObsSpace variable at that location. This will also be the value produced
66 /// by this predictor.
67 ///
68 /// The predictor will produce zeros for all bias-corrected variables missing from the `corrected
69 /// variables` list.
70 ///
71 /// It is possible to make the bias correction dependent on more than one ObsSpace variable and to
72 /// use a different matching method than `exact`. For more details, see the documentation of
73 /// DrawValueFromFile and DataExtractor.
75  public:
76  /// The type of parameters accepted by the constructor of this predictor.
77  /// This typedef is used by the PredictorFactory.
79 
80  InterpolateDataFromFile(const Parameters_ &, const oops::Variables &);
81 
82  void compute(const ioda::ObsSpace &, const GeoVaLs &,
83  const ObsDiagnostics &, ioda::ObsVector &) const override;
84 
85  private:
86  /// `obsFunctions_[varName]` is the ObsFunction that will calculate the predictions for variable
87  /// `varName`.
88  // The map is storing unique_ptrs to make it possible to compile this code with GCC 4.8.5,
89  // whose STL implementation is affected by LWG 2397
90  // (http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2397), later resolved by
91  // amending the C++11 standard as described in N4387
92  // (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4387.html).
93  std::map<std::string, std::unique_ptr<DrawValueFromFile<float>>> obsFunctions_;
94 };
95 
96 } // namespace ufo
97 
98 #endif // UFO_PREDICTORS_INTERPOLATEDATAFROMFILE_H_
Options controlling the DrawValueFromFile ObsFunction (excluding the group option).
GeoVaLs: geophysical values at locations.
A predictor returning values produced by the DrawValueFromFile ObsFunction.
void compute(const ioda::ObsSpace &, const GeoVaLs &, const ObsDiagnostics &, ioda::ObsVector &) const override
compute the predictor
std::map< std::string, std::unique_ptr< DrawValueFromFile< float > > > obsFunctions_
InterpolateDataFromFile(const Parameters_ &, const oops::Variables &)
InterpolateDataFromFileParameters Parameters_
Configuration parameters of the interpolate_data_from_file predictor.
oops::Parameter< std::vector< VariableCorrectionParameters > > correctedVariables
OOPS_CONCRETE_PARAMETERS(InterpolateDataFromFileParameters, PredictorParametersBase)
Base class for predictor parameters.
Definition: PredictorBase.h:37
DrawValueFromFileParametersWithoutGroup details
Options controlling bias correction of this variable.
oops::RequiredParameter< std::string > name
Name of the variable to be bias-corrected.
Definition: RunCRTM.h:27