IODA Bundle
IodaEncoder.h
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 #pragma once
9 
10 #include <memory>
11 
12 #include "eckit/config/LocalConfiguration.h"
13 #include "ioda/Group.h"
14 #include "ioda/Engines/Factory.h"
15 #include "ioda/ObsGroup.h"
16 
17 #include "DataContainer.h"
18 #include "IodaDescription.h"
19 
20 
21 namespace Ingester
22 {
23  /// \brief Uses IodaDescription and parsed data to create IODA data.
25  {
26  public:
27  explicit IodaEncoder(const eckit::Configuration& conf);
28  explicit IodaEncoder(const IodaDescription& description);
29 
30  /// \brief Encode the data into an ioda::ObsGroup object
31  /// \param data The data container to use
32  /// \param append Add data to existing file?
33  std::map<SubCategory, ioda::ObsGroup> encode(const std::shared_ptr<DataContainer>& data,
34  bool append = false);
35 
36  private:
37  /// \brief The description
39 
40  /// \brief Create a string from a template string.
41  /// \param prototype A template string ex: "my {dogType} barks". Sections labeled {__key__}
42  /// are treated as keys into the dictionary that defines their replacment values.
43  std::string makeStrWithSubstitions(const std::string& prototype,
44  const std::map<std::string, std::string>& subMap);
45 
46  /// \brief Used to find indecies of { and } by the makeStrWithSubstitions method.
47  /// \param str Template string to search.
48  std::vector<std::pair<std::string, std::pair<int, int>>>
49  findSubIdxs(const std::string& str);
50 
51  bool isInteger(const std::string& str) const;
52 
53  // Todo: Delete with USE_OLD_LAYOUT
54  std::string fixCoordinatesStr(const std::string& coordStr,
55  std::map<std::string, std::string> varMap);
56 
57  // Todo: Delete with USE_OLD_LAYOUT
58  std::pair<std::string, std::string> splitVar(const std::string& varNameStr);
59  };
60 } // namespace Ingester
Definitions for setting up backends with file and memory I/O.
Interfaces for ioda::Group and related classes.
Interfaces for ioda::ObsGroup and related classes.
Describes how to write data to IODA.
Uses IodaDescription and parsed data to create IODA data.
Definition: IodaEncoder.h:25
std::pair< std::string, std::string > splitVar(const std::string &varNameStr)
IodaEncoder(const eckit::Configuration &conf)
Definition: IodaEncoder.cpp:21
std::string fixCoordinatesStr(const std::string &coordStr, std::map< std::string, std::string > varMap)
std::map< SubCategory, ioda::ObsGroup > encode(const std::shared_ptr< DataContainer > &data, bool append=false)
Encode the data into an ioda::ObsGroup object.
Definition: IodaEncoder.cpp:32
std::string makeStrWithSubstitions(const std::string &prototype, const std::map< std::string, std::string > &subMap)
Create a string from a template string.
const IodaDescription description_
The description.
Definition: IodaEncoder.h:38
std::vector< std::pair< std::string, std::pair< int, int > > > findSubIdxs(const std::string &str)
Used to find indecies of { and } by the makeStrWithSubstitions method.
bool isInteger(const std::string &str) const