IODA
ioda::detail::DataLayoutPolicy Class Reference

Policy used for setting locations for Variable access. More...

#include <Layout.h>

Inheritance diagram for ioda::detail::DataLayoutPolicy:
Collaboration diagram for ioda::detail::DataLayoutPolicy:

Public Types

enum class  Policies { None , ObsGroup , ObsGroupODB }
 
enum class  MergeMethod { Concat }
 

Public Member Functions

virtual ~DataLayoutPolicy ()
 
virtual void initializeStructure (Group_Base &) const
 
virtual std::string doMap (const std::string &) const
 Map a user-specified Variable path to the correct location. More...
 
virtual bool isComplementary (const std::string &) const
 Check if the named variable will be a part of a derived variable. More...
 
virtual bool isMapped (const std::string &) const
 Check if the named variable is in the Variables section of the ODB mapping file. More...
 
virtual size_t getComplementaryPosition (const std::string &) const
 
virtual std::string getOutputNameFromComponent (const std::string &) const
 
virtual std::type_index getOutputVariableDataType (const std::string &) const
 
virtual MergeMethod getMergeMethod (const std::string &) const
 
virtual size_t getInputsNeeded (const std::string &) const
 
virtual std::pair< bool, std::string > getUnit (const std::string &) const
 
virtual std::string name () const
 A descriptive name for the policy. More...
 
 DataLayoutPolicy ()
 

Static Public Member Functions

static std::shared_ptr< const DataLayoutPolicygenerate (const std::string &polid="")
 Factory generator. More...
 
static std::shared_ptr< const DataLayoutPolicygenerate (const std::string &polid, const std::string &mapPath)
 
static std::shared_ptr< const DataLayoutPolicygenerate (Policies pol=Policies::None)
 Factory generator. More...
 
static std::shared_ptr< const DataLayoutPolicygenerate (Policies pol, const std::string &mapPath)
 
static std::shared_ptr< const DataLayoutPolicy_py_generate1 (const std::string &polid)
 
static std::shared_ptr< const DataLayoutPolicy_py_generate2 (Policies pol)
 

Detailed Description

Policy used for setting locations for Variable access.

Note
Using std::enable_shared_from_this as part of the pybind11 interface. We pass this to ObsGroup as a shared_ptr. See https://pybind11.readthedocs.io/en/stable/advanced/smart_ptrs.html#std-shared-ptr

Definition at line 35 of file Layout.h.

Member Enumeration Documentation

◆ MergeMethod

Enumerator
Concat 

Concatenate complementary variables entry-by-entry.

Definition at line 49 of file Layout.h.

◆ Policies

Enumerator
None 

Do no manipulation of the Group / Variable layout.

ObsGroup 

Transform "Variable@Group" into "Group/Variable". Ensure that group names match a few predefined keys.

ObsGroupODB 

Uses an auxiliary YAML dictionary to convert ODB variable/group naming conventions to IODA equivalents. Transform "Variable@Group" into "Group/Variable". Ensure that the new group names match a few predefined keys.

Definition at line 38 of file Layout.h.

Constructor & Destructor Documentation

◆ ~DataLayoutPolicy()

ioda::detail::DataLayoutPolicy::~DataLayoutPolicy ( )
virtual

Definition at line 62 of file Layout.cpp.

◆ DataLayoutPolicy()

ioda::detail::DataLayoutPolicy::DataLayoutPolicy ( )

Definition at line 63 of file Layout.cpp.

Member Function Documentation

◆ _py_generate1()

static std::shared_ptr<const DataLayoutPolicy> ioda::detail::DataLayoutPolicy::_py_generate1 ( const std::string &  polid)
inlinestatic

Definition at line 69 of file Layout.h.

Here is the caller graph for this function:

◆ _py_generate2()

static std::shared_ptr<const DataLayoutPolicy> ioda::detail::DataLayoutPolicy::_py_generate2 ( Policies  pol)
inlinestatic

Definition at line 73 of file Layout.h.

Here is the caller graph for this function:

◆ doMap()

std::string ioda::detail::DataLayoutPolicy::doMap ( const std::string &  str) const
virtual

Map a user-specified Variable path to the correct location.

This allows us to keep the frontend paths consistent, and we can instead do a path transformation to hide implementation details from end users.

The default policy is to pass paths expressed with forward slashes ("MetaData/Longitude") unchanged. If we pass paths using '@' notation, then reverse the path component (i.e. "TB@ObsValue" becomes "ObsValue/TB").

Note
We can apply these policies in both the frontend and inside of the engines.
Parameters
inStris the user-provided string. Ex: "TB@ObsValue" or "MetaData/Latitude", or even a fundamental dimension ("ChannelNumber").
Returns
A canonical path, always of the form "Group/Variable". In case of a dimension scale, then there is no group name, but for every other Variable, there is a Group name.

Reimplemented in ioda::detail::DataLayoutPolicy_ObsGroup_ODB, and ioda::detail::DataLayoutPolicy_ObsGroup.

Definition at line 70 of file Layout.cpp.

Here is the caller graph for this function:

◆ generate() [1/4]

std::shared_ptr< const DataLayoutPolicy > ioda::detail::DataLayoutPolicy::generate ( const std::string &  polid,
const std::string &  mapPath 
)
static

Factory generator (ODB-specific) mapPath path to a yaml file that defines how input file variables should be renamed upon import to ioda.

Definition at line 39 of file Layout.cpp.

◆ generate() [2/4]

std::shared_ptr< const DataLayoutPolicy > ioda::detail::DataLayoutPolicy::generate ( const std::string &  polid = "")
static

Factory generator.

Definition at line 28 of file Layout.cpp.

Here is the caller graph for this function:

◆ generate() [3/4]

std::shared_ptr< const DataLayoutPolicy > ioda::detail::DataLayoutPolicy::generate ( Policies  pol,
const std::string &  mapPath 
)
static

Factory generator (ODB-specific) mapPath path to a yaml file that defines how input file variables should be renamed upon import to ioda.

Definition at line 50 of file Layout.cpp.

◆ generate() [4/4]

std::shared_ptr< const DataLayoutPolicy > ioda::detail::DataLayoutPolicy::generate ( Policies  pol = Policies::None)
static

Factory generator.

Definition at line 34 of file Layout.cpp.

◆ getComplementaryPosition()

size_t ioda::detail::DataLayoutPolicy::getComplementaryPosition ( const std::string &  str) const
virtual

Returns the position of the input variable in the derived variable.

Exceptions
Ifthe input is not part of a derived variable.

Reimplemented in ioda::detail::DataLayoutPolicy_ObsGroup_ODB.

Definition at line 76 of file Layout.cpp.

Here is the caller graph for this function:

◆ getInputsNeeded()

size_t ioda::detail::DataLayoutPolicy::getInputsNeeded ( const std::string &  str) const
virtual

Returns the count of input variables needed.

Exceptions
Ifthe input is not part of a derived variable.

Reimplemented in ioda::detail::DataLayoutPolicy_ObsGroup_ODB.

Definition at line 92 of file Layout.cpp.

Here is the caller graph for this function:

◆ getMergeMethod()

DataLayoutPolicy::MergeMethod ioda::detail::DataLayoutPolicy::getMergeMethod ( const std::string &  str) const
virtual

Returns the merge method for derived variables.

Exceptions
Ifthe input is not part of a derived variable.

Reimplemented in ioda::detail::DataLayoutPolicy_ObsGroup_ODB.

Definition at line 88 of file Layout.cpp.

Here is the caller graph for this function:

◆ getOutputNameFromComponent()

std::string ioda::detail::DataLayoutPolicy::getOutputNameFromComponent ( const std::string &  str) const
virtual

Returns the derived variable name to be used in ioda.

Exceptions
Ifthe input is not part of a derived variable.

Reimplemented in ioda::detail::DataLayoutPolicy_ObsGroup_ODB.

Definition at line 80 of file Layout.cpp.

Here is the caller graph for this function:

◆ getOutputVariableDataType()

std::type_index ioda::detail::DataLayoutPolicy::getOutputVariableDataType ( const std::string &  str) const
virtual

Returns the data type of the derived variable.

Exceptions
Ifthe input is not part of a derived variable.

Reimplemented in ioda::detail::DataLayoutPolicy_ObsGroup_ODB.

Definition at line 84 of file Layout.cpp.

Here is the caller graph for this function:

◆ getUnit()

std::pair< bool, std::string > ioda::detail::DataLayoutPolicy::getUnit ( const std::string &  ) const
virtual

Returns the variable's unit if it has been specified.

Returns
A pair of (found, unit) indicating if a unit was found and what it is.
Exceptions
Ifthe input is not listed in Variables section of mapping file.

Reimplemented in ioda::detail::DataLayoutPolicy_ObsGroup_ODB.

Definition at line 96 of file Layout.cpp.

Here is the caller graph for this function:

◆ initializeStructure()

void ioda::detail::DataLayoutPolicy::initializeStructure ( Group_Base ) const
virtual

Create default groups and write default attributes upon object creation / initialization.

Reimplemented in ioda::detail::DataLayoutPolicy_ObsGroup_ODB, and ioda::detail::DataLayoutPolicy_ObsGroup.

Definition at line 64 of file Layout.cpp.

◆ isComplementary()

bool ioda::detail::DataLayoutPolicy::isComplementary ( const std::string &  str) const
virtual

Check if the named variable will be a part of a derived variable.

Reimplemented in ioda::detail::DataLayoutPolicy_ObsGroup_ODB.

Definition at line 72 of file Layout.cpp.

Here is the caller graph for this function:

◆ isMapped()

bool ioda::detail::DataLayoutPolicy::isMapped ( const std::string &  ) const
virtual

Check if the named variable is in the Variables section of the ODB mapping file.

Reimplemented in ioda::detail::DataLayoutPolicy_ObsGroup_ODB.

Definition at line 74 of file Layout.cpp.

Here is the caller graph for this function:

◆ name()

std::string ioda::detail::DataLayoutPolicy::name ( ) const
virtual

A descriptive name for the policy.

Reimplemented in ioda::detail::DataLayoutPolicy_ObsGroup_ODB, and ioda::detail::DataLayoutPolicy_ObsGroup.

Definition at line 68 of file Layout.cpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: