IODA
Layout_ObsGroup_ODB.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * (C) Copyright 2021 Met Office UK
4  *
5  * This software is licensed under the terms of the Apache Licence Version 2.0
6  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
7  */
8 /// \file Layout_ObsGroup_ODB.h
9 /// \brief Contains definitions for how ODB data are arranged in ioda internally.
10 
11 #include <memory>
12 #include <string>
13 #include <unordered_map>
14 #include <utility>
15 
16 #include "ioda/Layout.h"
17 #include "ioda/defs.h"
18 
19 namespace eckit {
20 class LocalConfiguration;
21 }
22 
23 namespace ioda {
24 namespace detail {
25 
26 class ODBLayoutParameters;
27 
29  std::string iodaName;
30  std::pair<bool,std::string> inputUnit;
31 };
32 
33 /// Layout for ObsGroup-like data.
35  /// \brief Record versioning information for this layout in the ioda object. Provides forward compatability.
36  const int32_t ObsGroup_ODB_Layout_Version = 0;
37  /// \brief Mapping with ODB equivalents as keys and IODA naming/unit pairs as values
38  std::unordered_map<std::string, variableStorageInformation> Mapping;
39  std::shared_ptr<ODBLayoutParameters> mappingParams_;
40  /// \brief Metadata for generating a variable in IODA from multiple component variables (same across components).
42  std::string outputName;
43  std::type_index outputVariableDataType;
46  };
47  typedef std::pair<size_t, std::shared_ptr<ComplementaryVariableOutputMetadata>>
48  complementaryVariableMetaData; //the position and the derived variable's MetaData
49  //The component strings mapped to the common-across-components information for creating a derived variable
50  std::unordered_map<std::string, complementaryVariableMetaData> complementaryVariableDataMap;
51 
52  public:
54  void initializeStructure(Group_Base &) const override;
55  std::string doMap(const std::string &) const override;
56  bool isComplementary(const std::string &) const override;
57  bool isMapped(const std::string &) const override;
58  bool isMapOutput(const std::string &) const override;
59  size_t getComplementaryPosition(const std::string &) const override;
60  size_t getInputsNeeded(const std::string &) const override;
61  DataLayoutPolicy::MergeMethod getMergeMethod(const std::string &) const override;
62  std::pair<bool,std::string> getUnit(const std::string &) const override;
63  std::string getOutputNameFromComponent(const std::string &) const override;
64  std::type_index getOutputVariableDataType(const std::string &) const override;
65  DataLayoutPolicy_ObsGroup_ODB(const std::string &, const std::vector<std::string> & = {});
66  /// A descriptive name for the policy.
67  std::string name() const override;
68  private:
69  void parseMappingFile(const std::string &);
70  void addUnchangedVariableName(const std::string &);
71  void parseNameChanges();
72  void parseComponentVariables();
73  DataLayoutPolicy::MergeMethod parseMergeMethod(const std::string &);
74 };
75 
76 } // namespace detail
77 } // namespace ioda
Contains definitions for how data are arranged in ioda internally.
std::unordered_map< std::string, variableStorageInformation > Mapping
Mapping with ODB equivalents as keys and IODA naming/unit pairs as values.
std::unordered_map< std::string, complementaryVariableMetaData > complementaryVariableDataMap
std::shared_ptr< ODBLayoutParameters > mappingParams_
std::pair< size_t, std::shared_ptr< ComplementaryVariableOutputMetadata > > complementaryVariableMetaData
Policy used for setting locations for Variable access.
Definition: Layout.h:36
Hidden base class to prevent constructor confusion.
Definition: Group.h:42
Common preprocessor definitions used throughout IODA.
#define IODA_DL
A preprocessor tag that indicates that a symbol is to be exported/imported.
Definition: defs.h:110
Metadata for generating a variable in IODA from multiple component variables (same across components)...
std::pair< bool, std::string > inputUnit