1#ifndef NGEN_MDFRAME_DEFINITION_HPP
2#define NGEN_MDFRAME_DEFINITION_HPP
4#include <unordered_set>
5#include <unordered_map>
7#include "dimension.hpp"
85 dimension_set::const_iterator
find_dimension(
const std::string& name)
const noexcept
96 variable_map::const_iterator
find_variable(
const std::string& name)
const noexcept
108 boost::optional<detail::dimension>
get_dimension(
const std::string& name)
const noexcept
112 boost::optional<detail::dimension> result;
157 stat.first->m_size = size;
215 template<
typename T, types::enable_if_supports<T,
bool> = true>
218 std::vector<dimension> references;
219 references.reserve(dimensions.size());
221 for (
const auto& d : dimensions) {
223 if (dopt == boost::none) {
224 throw std::runtime_error(
"not a dimension");
226 references.push_back(dopt.get());
255 void to_csv(
const std::string& path,
bool header =
true)
const;
262 void to_netcdf(
const std::string& path)
const;
A multi-dimensional, tagged data frame.
Definition mdframe.hpp:56
variable & operator[](const std::string &name) noexcept
Return reference to a mdarray representing a variable, if it exists.
Definition mdframe.hpp:186
std::unordered_map< std::string, variable > variable_map
Definition mdframe.hpp:61
bool has_variable(const std::string &name) const noexcept
Check if a variable exists.
Definition mdframe.hpp:198
void to_netcdf(const std::string &path) const
Write this mdframe to a NetCDF file.
Definition handler_netcdf.cpp:83
detail::dimension dimension
Definition mdframe.hpp:58
variable_map m_variables
Definition mdframe.hpp:266
std::unordered_set< dimension, dimension::hash > dimension_set
Definition mdframe.hpp:59
mdframe & add_variable(const std::string &name, std::initializer_list< std::string > dimensions)
Add a (vector) variable definition to this mdframe.
Definition mdframe.hpp:216
mdframe & add_dimension(const std::string &name, std::size_t size)
Add a dimension with a specified size to this mdframe, or update an existing dimension.
Definition mdframe.hpp:152
variable & get_variable(const std::string &name) noexcept
Return reference to a mdarray representing a variable, if it exists.
Definition mdframe.hpp:174
variable_map::const_iterator find_variable(const std::string &name) const noexcept
Get an iterator to a variable, if it exists in the set.
Definition mdframe.hpp:96
dimension_set m_dimensions
Definition mdframe.hpp:265
variable::mdarray_variant mdarray_variant
Definition mdframe.hpp:72
void to_csv(const std::string &path, bool header=true) const
Write this mdframe to a CSV file.
Definition handler_csv.cpp:41
mdframe & add_dimension(const std::string &name)
Add a dimension with unlimited size to this mdframe.
Definition mdframe.hpp:138
dimension_set::const_iterator find_dimension(const std::string &name) const noexcept
Get an iterator to a dimension, if it exists in the set.
Definition mdframe.hpp:85
boost::optional< detail::dimension > get_dimension(const std::string &name) const noexcept
Return a dimension if it exists.
Definition mdframe.hpp:108
bool has_dimension(const std::string &name) const noexcept
Check if a dimension exists.
Definition mdframe.hpp:127
variable::size_type size_type
Definition mdframe.hpp:62
Definition DomainLayer.hpp:9
Dimension Key.
Definition dimension.hpp:19
Variable Key.
Definition variable.hpp:24
static variable make(const std::string &name, const std::vector< dimension > &dimensions)
Constructs a named variable spanned over the given dimensions.
Definition variable.hpp:73
typename types::template variant_container< ngen::mdarray > mdarray_variant
A boost::variant type consisting of mdarrays of the support types, i.e.
Definition variable.hpp:40
traits::type_list< SupportedTypes... > types
The variable value types this frame can support.
Definition variable.hpp:32
std::size_t size_type
Definition variable.hpp:25