UFO
LinearObsOperatorBase.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2017-2018 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 
9 
10 #include <memory>
11 
12 #include "ioda/ObsSpace.h"
13 #include "oops/util/abor1_cpp.h"
14 #include "oops/util/Logger.h"
15 
16 namespace ufo {
17 
18 // -----------------------------------------------------------------------------
19 
20 oops::Variables LinearObsOperatorBase::simulatedVars() const {
21  return odb_.obsvariables();
22 }
23 
24 // -----------------------------------------------------------------------------
25 
27  if (getMakers().find(name) != getMakers().end()) {
28  oops::Log::error() << name << " already registered in ufo::LinearObsOperatorFactory."
29  << std::endl;
30  ABORT("Element already registered in ufo::LinearObsOperatorFactory.");
31  }
32  getMakers()[name] = this;
33 }
34 
35 // -----------------------------------------------------------------------------
36 
38  const ioda::ObsSpace & odb, const ObsOperatorParametersBase & params) {
39  oops::Log::trace() << "LinearObsOperatorBase::create starting" << std::endl;
40 
41  const std::string &id = params.name.value().value();
42 
43  typename std::map<std::string, LinearObsOperatorFactory*>::iterator jloc = getMakers().find(id);
44  if (jloc == getMakers().end()) {
45  oops::Log::error() << id << " does not exist in ufo::LinearObsOperatorFactory." << std::endl;
46  ABORT("Element does not exist in ufo::LinearObsOperatorFactory.");
47  }
48  LinearObsOperatorBase * ptr = jloc->second->make(odb, params);
49  oops::Log::trace() << "LinearObsOperatorBase::create done" << std::endl;
50  return ptr;
51 }
52 
53 // -----------------------------------------------------------------------------
54 
55 std::unique_ptr<ObsOperatorParametersBase>
57  typename std::map<std::string, LinearObsOperatorFactory*>::iterator it =
58  getMakers().find(name);
59  if (it == getMakers().end()) {
60  throw std::runtime_error(name + " does not exist in ufo::LinearObsOperatorFactory");
61  }
62  return it->second->makeParameters();
63 }
64 // -----------------------------------------------------------------------------
65 
66 } // namespace ufo
virtual oops::Variables simulatedVars() const
List of variables simulated by this operator.
const ioda::ObsSpace & odb_
static std::unique_ptr< ObsOperatorParametersBase > createParameters(const std::string &name)
Create and return an instance of the subclass of ObsOperatorParametersBase storing parameters of line...
LinearObsOperatorFactory(const std::string &name)
Register a maker able to create linear observation operators of type name.
static std::map< std::string, LinearObsOperatorFactory * > & getMakers()
static LinearObsOperatorBase * create(const ioda::ObsSpace &, const ObsOperatorParametersBase &)
Create and return a new linear observation operator.
Base class of classes storing configuration parameters of specific observation operators and linear o...
oops::OptionalParameter< std::string > name
Observation operator type.
Definition: RunCRTM.h:27