IODA
py_ioda.cpp
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020 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 /// \file py_ioda.cpp
8 /// \brief Python bindings for the ioda / ioda-engines library.
9 
10 #include <pybind11/eigen.h>
11 #include <pybind11/pybind11.h>
12 #include <pybind11/stl.h>
13 
14 #include <iostream>
15 #include <sstream>
16 
17 #include "./macros.h"
18 #include "ioda/Engines/HH.h"
19 #include "ioda/Engines/ObsStore.h"
20 #include "ioda/Group.h"
21 #include "ioda/Layout.h"
23 #include "ioda/ObsGroup.h"
24 
25 namespace py = pybind11;
26 using namespace ioda;
27 
28 void setupTypeSystem(pybind11::module& m);
29 
30 void setupDimensions(pybind11::module& m);
31 
32 void setupAttributes(pybind11::module& m, pybind11::module& mDetail, pybind11::module& mPy);
33 
34 void setupHasAttributes(pybind11::module& m);
35 
36 void setupAttCreator(pybind11::module& m);
37 
38 void setupSelections(pybind11::module& m);
39 
40 void setupVariables(pybind11::module& m, pybind11::module& mDetail, pybind11::module& mPy);
41 
42 void setupVCPs(pybind11::module& m, pybind11::module& mDetail, pybind11::module& mPy);
43 
44 void setupHasVariables(pybind11::module& m);
45 
46 void setupGroups(pybind11::module& m);
47 
48 void setupEngines(pybind11::module& m);
49 
50 std::shared_ptr<const ioda::detail::DataLayoutPolicy> setupDLP(pybind11::module& mDLP);
51 
52 void setupNewDimensionScales(pybind11::module& m);
53 
54 void setupObsGroup(pybind11::module& m,
55  std::shared_ptr<const ioda::detail::DataLayoutPolicy> default_dlp);
56 
57 using namespace ioda;
58 PYBIND11_MODULE(_ioda_python, m) {
59  namespace py = pybind11;
60 
61  m.doc() = "Python bindings for ioda";
62 
63  auto mDetail = m.def_submodule("detail");
64  mDetail.doc() = "Implementation details";
65 
66  auto mDLP = m.def_submodule("DLP");
67  mDLP.doc() = "Data layout policies";
68 
69  auto mPy = mDetail.def_submodule("python_bindings");
70  mPy.doc() = "Python binding helper classes";
71 
72  py::enum_<ioda::ObjectType> eObjType(m, "ObjectType");
73  eObjType
74  .value("Ignored", ObjectType::Ignored, "ObjectType is ignored in search.")
75  .value("Unimplemented", ObjectType::Unimplemented, "Support for this ObjectType is "
76  "unimplemented in this ioda version")
77  .value("Group", ObjectType::Group, "Object is a group")
78  .value("Variable", ObjectType::Variable, "Object is a variable");
79 
80  setupTypeSystem(m);
81  setupDimensions(m);
82  setupAttributes(m, mDetail, mPy);
84  setupAttCreator(m);
85  setupSelections(m);
86  setupVariables(m, mDetail, mPy);
87  setupVCPs(m, mDetail, mPy);
89  setupGroups(m);
90  setupEngines(m);
91  auto default_dlp = setupDLP(mDLP);
93  setupObsGroup(m, default_dlp);
94 }
Convenience classes for constructing ObsSpaces and setting up new Dimension Scales.
Interfaces for ioda::Group and related classes.
HDF5 engine.
Contains definitions for how data are arranged in ioda internally.
Interfaces for ioda::ObsGroup and related classes.
ObsStore engine.
Python bindings - macros.
PYBIND11_MODULE(_ioda_python, m)
Definition: py_ioda.cpp:58
void setupEngines(pybind11::module &m)
Definition: py_engines.cpp:28
void setupObsGroup(pybind11::module &m, std::shared_ptr< const ioda::detail::DataLayoutPolicy > default_dlp)
Definition: py_obsgroup.cpp:28
void setupNewDimensionScales(pybind11::module &m)
Definition: py_scales.cpp:28
std::shared_ptr< const ioda::detail::DataLayoutPolicy > setupDLP(pybind11::module &mDLP)
Definition: py_dlp.cpp:28
void setupHasAttributes(pybind11::module &m)
void setupTypeSystem(pybind11::module &m)
Definition: py_types.cpp:22
void setupAttCreator(pybind11::module &m)
void setupSelections(pybind11::module &m)
void setupAttributes(pybind11::module &m, pybind11::module &mDetail, pybind11::module &mPy)
void setupVCPs(pybind11::module &m, pybind11::module &mDetail, pybind11::module &mPy)
Definition: py_vcps.cpp:29
void setupGroups(pybind11::module &m)
Definition: py_groups.cpp:28
void setupDimensions(pybind11::module &m)
void setupHasVariables(pybind11::module &m)
void setupVariables(pybind11::module &m, pybind11::module &mDetail, pybind11::module &mPy)