UFO
ObsLocSOAR.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020-2021 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 
8 #ifndef UFO_OBSLOCALIZATION_OBSLOCSOAR_H_
9 #define UFO_OBSLOCALIZATION_OBSLOCSOAR_H_
10 
11 #include <ostream>
12 #include <vector>
13 
14 #include "eckit/config/Configuration.h"
15 
16 #include "ioda/ObsSpace.h"
17 #include "ioda/ObsVector.h"
18 
19 #include "oops/generic/soar.h"
20 
23 
24 namespace ufo {
25 
26 /// Horizontal SOAR observation space localization
27 template<class MODEL>
28 class ObsLocSOAR: public ufo::ObsLocalization<MODEL> {
29  typedef typename MODEL::GeometryIterator GeometryIterator_;
30 
31  public:
32  ObsLocSOAR(const eckit::Configuration &, const ioda::ObsSpace &);
33 
34  /// compute localization and save localization values in \p locvector
35  /// (missing values indicate that observation is outside of localization)
37  ioda::ObsVector & locvector) const override;
38 
39  private:
40  void print(std::ostream &) const override;
41 
43 };
44 // -----------------------------------------------------------------------------
45 
46 template<typename MODEL>
47 ObsLocSOAR<MODEL>::ObsLocSOAR(const eckit::Configuration & config,
48  const ioda::ObsSpace & obsspace):
49  ObsLocalization<MODEL>::ObsLocalization(config, obsspace) {
50  options_.deserialize(config);
51  oops::Log::debug()<< "SOAR horizontal localization with " << options_.SOARexpDecayH
52  << " soar decay" << std::endl;
53 }
54 // -----------------------------------------------------------------------------
55 
56 template<typename MODEL>
58  ioda::ObsVector & locvector) const {
59  oops::Log::trace() << "ObsLocSOAR::computeLocalization" << std::endl;
60  // do distance search and compute box-car locvector
62 
63  // return refs to internals of ObsLocalization
64  const std::vector<int> & localobs = ObsLocalization<MODEL>::localobs();
65  const std::vector<double> & horizontalObsdist = ObsLocalization<MODEL>::horizontalObsdist();
66 
67  const double SOARexpDecayH = options_.SOARexpDecayH;
68  const size_t nvars = locvector.nvars();
69  for (size_t jlocal = 0; jlocal < localobs.size(); ++jlocal) {
70  double locFactor = oops::soar(horizontalObsdist[jlocal]*SOARexpDecayH);
71  // obsdist is calculated at each location; need to update R for each variable
72  for (size_t jvar = 0; jvar < nvars; ++jvar) {
73  locvector[jvar + localobs[jlocal] * nvars] *= locFactor;
74  }
75  }
76 }
77 
78 // -----------------------------------------------------------------------------
79 
80 template<typename MODEL>
81 void ObsLocSOAR<MODEL>::print(std::ostream & os) const {
82  os << "SOAR horizontal localization with " << options_.SOARexpDecayH
83  << " soar decay" << std::endl;
84 }
85 
86 } // namespace ufo
87 
88 #endif // UFO_OBSLOCALIZATION_OBSLOCSOAR_H_
Horizontal SOAR observation space localization.
Definition: ObsLocSOAR.h:28
void computeLocalization(const GeometryIterator_ &, ioda::ObsVector &locvector) const override
Definition: ObsLocSOAR.h:57
void print(std::ostream &) const override
Definition: ObsLocSOAR.h:81
ObsLocSOARParameters options_
Definition: ObsLocSOAR.h:42
ObsLocSOAR(const eckit::Configuration &, const ioda::ObsSpace &)
Definition: ObsLocSOAR.h:47
MODEL::GeometryIterator GeometryIterator_
Definition: ObsLocSOAR.h:29
Options controlling SOAR obs localization. Inherits options from general horizontal obs localization.
oops::RequiredParameter< double > SOARexpDecayH
The SOAR function decay parameter.
Horizontal Box car observation space localization.
const std::vector< int > & localobs() const
MODEL::GeometryIterator GeometryIterator_
void computeLocalization(const GeometryIterator_ &, ioda::ObsVector &locvector) const override
const std::vector< double > & horizontalObsdist() const
Definition: RunCRTM.h:27