UFO
ModelBestFitPressure.h
Go to the documentation of this file.
1 /*
2  * (C) 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_FILTERS_MODELBESTFITPRESSURE_H_
9 #define UFO_FILTERS_MODELBESTFITPRESSURE_H_
10 
11 #include <memory>
12 #include <ostream>
13 #include <string>
14 #include <vector>
15 
16 #include "oops/util/ObjectCounter.h"
17 #include "oops/util/parameters/Parameter.h"
18 #include "oops/util/parameters/RequiredParameter.h"
19 #include "ufo/filters/FilterBase.h"
20 #include "ufo/filters/QCflags.h"
21 #include "ufo/filters/Variable.h"
23 
24 namespace eckit {
25 }
26 
27 namespace ioda {
28  template <typename DATATYPE> class ObsDataVector;
29  class ObsSpace;
30 }
31 
32 namespace ufo {
33 
34 /// \brief Parameters controlling the operation of the ModelBestFitPressure filter.
36  OOPS_CONCRETE_PARAMETERS(ModelBestFitPressureParameters, FilterParametersBase)
37 
38  public:
39  /// Name of the observation pressure variable to correct.
40  oops::RequiredParameter<Variable> obs_pressure{"observation pressure", this};
41  /// Minimum allowed pressure region. Model levels will not be considered if their
42  /// pressure is below this value.
43  oops::Parameter<float> top_pressure{"top pressure", 10000, this};
44  /// Winds within this pressure-range of the best-fit pressure will be checked for
45  /// consistency within this range of the minimum speed.
46  oops::Parameter<float> pressure_band_half_width{"pressure band half-width", 10000, this};
47  /// Maximum vector difference allowed, for calculating constraint.
48  oops::Parameter<float> upper_vector_diff{"upper vector diff", 4, this};
49  /// Minimum vector difference allowed, for calculating constraint.
50  oops::Parameter<float> lower_vector_diff{"lower vector diff", 2, this};
51  /// Tolerance for vec_diff comparison.
52  /// Used when calculating bestfit pressure using parabolic fit.
53  oops::Parameter<float> tolerance_vector_diff{"tolerance vector diff", 1.0e-8, this};
54  /// Tolerance for pressure comparison. Used for calculating bestfit winds when comparing
55  /// pressure with bestfit pressure. Only used if calculate_best_fit_winds is true.
56  oops::Parameter<float> tolerance_pressure{"tolerance pressure", 0.01, this};
57  /// To calculate bestfit eastward/northward winds by linear interpolation.
58  oops::Parameter<bool> calculate_best_fit_winds{"calculate bestfit winds", false, this};
59 };
60 
61 /// \brief A filter to calculate the best fit pressure and if the pressure is well constrained.
62 /// Also can calculate the best fit eastward/northward winds.
63 ///
64 /// \details The model best-fit pressure is defined as the model pressure (Pa) with the
65 /// smallest vector difference between the AMV and model background wind, but
66 /// additionally is not allowed to be above top pressure (top_pressure) (can reasonably
67 /// expect that AMVs should not be above this level). Vertical interpolation is performed
68 /// between model levels to find the minimum vector difference.
69 ///
70 /// Checking if the pressure is well-constrained:
71 /// 1. Remove any winds where the minimum vector difference between the AMV eastward and
72 /// northward winds and the background column u and v is greater than upper_vector_diff.
73 /// This check aims to remove cases where there is no good agreement between the AMV
74 /// and the winds at any level in the background wind column.
75 /// 2. Remove any winds where the vector difference is less than the minimum vector
76 /// difference + lower_vector_diff outside of a band +/- pressure_band_half_width from the
77 /// best-fit pressure level. This aims to catch cases where there are secondary minima
78 /// or very broad minima. In both cases the best-fit pressure is not well constrained.
79 /// The default parameter values were chosen by eye-balling vector difference profiles and together
80 /// remove just over half the winds.
81 ///
82 /// See ModelBestFitPressureParameters for the documentation of
83 /// the parameters controlling this filter.
85  private util::ObjectCounter<ModelBestFitPressure> {
86  public:
87  /// The type of parameters accepted by the constructor of this filter.
88  /// This typedef is used by the FilterFactory.
90 
91  static const std::string classname() {return "ufo::ModelBestFitPressure";}
92 
93  ModelBestFitPressure(ioda::ObsSpace &, const Parameters_ &,
94  std::shared_ptr<ioda::ObsDataVector<int> >,
95  std::shared_ptr<ioda::ObsDataVector<float> >);
97 
98  private:
99  void print(std::ostream &) const override;
100  void applyFilter(const std::vector<bool> &, const Variables &,
101  std::vector<std::vector<bool>> &) const override;
102  int qcFlag() const override {return QCflags::pass; }
103 
105 };
106 
107 } // namespace ufo
108 
109 #endif // UFO_FILTERS_MODELBESTFITPRESSURE_H_
Base class for UFO QC filters.
Definition: FilterBase.h:45
Parameters shared by all filters having a default action (typically "reject").
A filter to calculate the best fit pressure and if the pressure is well constrained....
static const std::string classname()
void applyFilter(const std::vector< bool > &, const Variables &, std::vector< std::vector< bool >> &) const override
A filter that calculates the pressure at which the AMV wind vector (u,v) is a best match to the model...
void print(std::ostream &) const override
ModelBestFitPressureParameters Parameters_
ModelBestFitPressure(ioda::ObsSpace &, const Parameters_ &, std::shared_ptr< ioda::ObsDataVector< int > >, std::shared_ptr< ioda::ObsDataVector< float > >)
Parameters controlling the operation of the ModelBestFitPressure filter.
oops::RequiredParameter< Variable > obs_pressure
Name of the observation pressure variable to correct.
oops::Parameter< float > upper_vector_diff
Maximum vector difference allowed, for calculating constraint.
oops::Parameter< bool > calculate_best_fit_winds
To calculate bestfit eastward/northward winds by linear interpolation.
oops::Parameter< float > pressure_band_half_width
oops::Parameter< float > tolerance_vector_diff
oops::Parameter< float > tolerance_pressure
oops::Parameter< float > lower_vector_diff
Minimum vector difference allowed, for calculating constraint.
Forward declarations.
Definition: ObsAodExt.h:21
Forward declarations.
Definition: ObsAodExt.h:25
constexpr int pass
Definition: QCflags.h:14
Definition: RunCRTM.h:27