IODA Bundle
MnemonicVariable.cpp
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020 NOAA/NWS/NCEP/EMC
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 "MnemonicVariable.h"
9 
10 #include <ostream>
11 
12 #include "eckit/exception/Exceptions.h"
13 
14 #include "IngesterTypes.h"
15 
16 
17 namespace Ingester
18 {
19  MnemonicVariable::MnemonicVariable(const std::string& mnemonic, const Transforms& transforms) :
20  mnemonic_(mnemonic),
21  transforms_(transforms)
22  {
23  }
24 
25  std::shared_ptr<DataObject> MnemonicVariable::exportData(const BufrDataMap& map)
26  {
27  if (map.find(mnemonic_) == map.end())
28  {
29  std::stringstream errStr;
30  errStr << "Mnemonic " << mnemonic_;
31  errStr << " could not be found during export.";
32 
33  eckit::BadParameter(errStr.str());
34  }
35 
36  auto data = map.at(mnemonic_);
37  applyTransforms(data);
38  return std::make_shared<ArrayDataObject>(data);
39  }
40 
42  {
43  for (auto transform : transforms_)
44  {
45  transform->apply(data);
46  }
47  }
48 } // namespace Ingester
MnemonicVariable(const std::string &mnemonicStr, const Transforms &transforms)
std::string mnemonic_
The BUFR mnemonic of interest.
Transforms transforms_
Collection of transforms to apply to the data during export.
std::shared_ptr< DataObject > exportData(const BufrDataMap &map) final
Gets the requested data, applies transforms, and returns the requested data.
void applyTransforms(IngesterArray &data)
Apply the transforms.
Eigen::Array< FloatType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > IngesterArray
Definition: IngesterTypes.h:19
IngesterArrayMap BufrDataMap
Definition: BufrTypes.h:21
std::vector< std::shared_ptr< Transform > > Transforms