UFO
ProbabilityGrossErrorWholeReport.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_PROBABILITYGROSSERRORWHOLEREPORT_H_
9 #define UFO_FILTERS_PROBABILITYGROSSERRORWHOLEREPORT_H_
10 
11 #include <memory>
12 #include <ostream>
13 #include <string>
14 #include <vector>
15 
16 #include "oops/util/ObjectCounter.h"
17 #include "ufo/filters/FilterBase.h"
18 #include "ufo/filters/QCflags.h"
19 #include "ufo/filters/Variable.h"
21 
22 namespace eckit {
23  class Configuration;
24 }
25 
26 namespace ioda {
27  template <typename DATATYPE> class ObsDataVector;
28  class ObsSpace;
29 }
30 
31 namespace ufo {
32 
33 /// Parameters controlling the operation of the ProbabilityGrossErrorWholeReport filter.
36 
37  public:
38  /// Parameters related to PGE calculations. The value of \p PGECrit
39  /// is obtained from here.
41 };
42 
43 /// \brief This filter calculates the probability that an entire report is affected by gross error.
44 /// \details Synoptic stations typically provide reports at regular intervals. A report is a
45 /// combination of variables observed by different sensors at a single location. Reports may
46 /// include some, but not necessarily all, of pressure, temperature, dew point and wind speed
47 /// and direction.
48 ///
49 /// The probability that the whole report is affected by gross error is calculated
50 /// through the Bayesian combination of the probability of gross error of individual
51 /// observations. This is based on the logic that if multiple observations within a report
52 /// appear dubious based on a Bayesian Background check, it is likely that the whole report
53 /// is affected by, for example, location error. This filter should be called after the
54 /// Bayesian Background Check.
55 ///
56 /// Variables which are to have their probability of gross error updated should be specified
57 /// using the "filter variables" YAML option. All variables included in "filter variables" will
58 /// be used to calculate the probability that the whole report is affected by gross error unless
59 /// the option \c not_used_in_whole_report is set to true for that variable.
60 ///
61 /// Variables can be either scalar or vector (with two Cartesian components, such as the eastward
62 /// and northward wind components). In the latter case the two components need to specified one
63 /// after the other in the "filter variables" list, with the second component having the
64 /// \c second_component_of_two option set to true. For each variable, the option
65 /// \c Probability_Density_Bad is used to set the prior probability density of that variable being
66 /// "bad". The filter can also apply a specific prior probability density of bad observations for
67 /// the following Met Office SubTypes:
68 /// * Bogus
69 /// * Synop (SynopManual, SynopAuto, MetarManual, MetarAuto, SynopMob, SynopBufr, WOW)
70 ///
71 /// Example:
72 ///
73 /// \code{.yaml}
74 ///- filter: Bayesian Whole Report
75 /// filter variables:
76 /// - name: pressure_at_model_surface
77 /// options:
78 /// Probability_Density_Bad: 0.1
79 /// Bogus_Probability_Density_Bad: 0.1
80 /// - name: air_temperature_at_2m
81 /// options:
82 /// Probability_Density_Bad: 0.1
83 /// - name: eastward_wind
84 /// options:
85 /// Probability_Density_Bad: 0.1
86 /// Synop_Probability_Density_Bad: 0.1
87 /// Bogus_Probability_Density_Bad: 0.1
88 /// - name: northward_wind
89 /// options:
90 /// not_used_in_whole_report: true
91 /// second_component_of_two: true
92 /// - name: relative_humidity_at_2m
93 /// options:
94 /// not_used_in_whole_report: true
95 /// Probability_Density_Bad: 0.1
96 /// PGE threshold: 0.15
97 /// \endcode
98 ///
99 
101  private util::ObjectCounter<ProbabilityGrossErrorWholeReport> {
102  public:
103  /// The type of parameters accepted by the constructor of this filter.
104  /// This typedef is used by the FilterFactory.
106 
107  static const std::string classname() {return "ufo::ProbabilityGrossErrorWholeReport";}
108 
109  ProbabilityGrossErrorWholeReport(ioda::ObsSpace &, const Parameters_ &,
110  std::shared_ptr<ioda::ObsDataVector<int>>,
111  std::shared_ptr<ioda::ObsDataVector<float>>);
113 
114  private:
115  void print(std::ostream &) const override;
116  void applyFilter(const std::vector<bool> &, const Variables &,
117  std::vector<std::vector<bool>> &) const override;
118  int qcFlag() const override {return QCflags::bayesianQC;}
119 
121 };
122 
123 } // namespace ufo
124 
125 #endif // UFO_FILTERS_PROBABILITYGROSSERRORWHOLEREPORT_H_
Base class for UFO QC filters.
Definition: FilterBase.h:45
Parameters shared by all filters having a default action (typically "reject").
This filter calculates the probability that an entire report is affected by gross error.
ProbabilityGrossErrorWholeReport(ioda::ObsSpace &, const Parameters_ &, std::shared_ptr< ioda::ObsDataVector< int >>, std::shared_ptr< ioda::ObsDataVector< float >>)
void applyFilter(const std::vector< bool > &, const Variables &, std::vector< std::vector< bool >> &) const override
ProbabilityGrossErrorWholeReportParameters Parameters_
Parameters controlling the operation of the ProbabilityGrossErrorWholeReport filter.
Options controlling the operation of the calculations involving probability of gross error.
Forward declarations.
Definition: ObsAodExt.h:21
Forward declarations.
Definition: ObsAodExt.h:25
constexpr int bayesianQC
Definition: QCflags.h:36
Definition: RunCRTM.h:27