UFO
TransformBase.cc
Go to the documentation of this file.
1 /*
2  * (C) 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 #include <map>
9 #include <string>
10 #include "oops/util/Logger.h"
12 
13 namespace ufo {
14 
16  const ObsFilterData& data,
17  const std::shared_ptr<ioda::ObsDataVector<int>>& flags)
18  : options_(options), data_(data) , flags_(*flags) {
19  method_ = formulas::resolveMethods(options.Method.value());
21  options.Method.value());
22  UseValidDataOnly_ = options.UseValidDataOnly.value();
24  obsName_ = data_.obsspace().obsname();
25 }
26 
27 TransformFactory::TransformFactory(const std::string& name) {
28  if (getMakers().find(name) != getMakers().end())
29  throw eckit::BadParameter(
30  name + " already registered in ufo::TransformFactory.", Here());
31 
32  getMakers()[name] = this;
33 }
34 
35 std::unique_ptr<TransformBase> TransformFactory::create(
36  const std::string& name, const VariableTransformsParameters& options,
37  const ObsFilterData& data,
38  const std::shared_ptr<ioda::ObsDataVector<int>>& flags) {
39 
40  oops::Log::trace() << " --> TransformFactory::create" << std::endl;
41  oops::Log::trace() << " --> name: " << name << std::endl;
42 
43  typename std::map<std::string, TransformFactory*>::iterator jloc =
44  getMakers().find(name);
45 
46  if (jloc == getMakers().end()) {
47  std::string makerNameList;
48  for (const auto& makerDetails : getMakers())
49  makerNameList += "\n " + makerDetails.first;
50  std::cout << " --> makerNameList" << makerNameList << std::endl;
51  std::cout << " " << name
52  << " does not exist in ufo::TransformFactory. "
53  << "Possible values:" << makerNameList << std::endl;
54 
55  throw eckit::BadParameter(name +
56  " does not exist in ufo::TransformFactory. "
57  "Possible values:" +
58  makerNameList,
59  Here());
60  }
61 
62  std::unique_ptr<TransformBase> ptr = jloc->second->make(options, data, flags);
63  oops::Log::trace() << "TransformBase::create done" << std::endl;
64 
65  return ptr;
66 }
67 } // namespace ufo
ObsFilterData provides access to all data related to an ObsFilter.
ioda::ObsSpace & obsspace() const
Returns reference to ObsSpace associated with ObsFilterData.
TransformBase(const VariableTransformsParameters &options, const ObsFilterData &data, const std::shared_ptr< ioda::ObsDataVector< int >> &flags)
formulas::MethodFormulation formulation_
Definition: TransformBase.h:85
std::string obsName_
The observation name.
Definition: TransformBase.h:89
formulas::MethodFormulation method_
Method used for the calculation.
Definition: TransformBase.h:84
ObsFilterData data_
Observation and geoval data.
static std::map< std::string, TransformFactory * > & getMakers()
TransformFactory(const std::string &)
static std::unique_ptr< TransformBase > create(const std::string &, const VariableTransformsParameters &, const ObsFilterData &, const std::shared_ptr< ioda::ObsDataVector< int >> &)
Options controlling the operation of the variablestansform filter.
oops::Parameter< std::string > Formulation
MethodFormulation resolveFormulations(const std::string &input, const std::string &method)
Definition: Formulas.cc:30
MethodFormulation resolveMethods(const std::string &input)
Definition: Formulas.cc:22
Definition: RunCRTM.h:27