Class DataFrameDimension¶
Defined in File Dimensions.hpp
Inheritance Relationships¶
Base Type¶
public nix::base::ImplContainer< base::IDataFrameDimension >
(Template Class ImplContainer)
Class Documentation¶
-
class DataFrameDimension : public nix::base::ImplContainer<base::IDataFrameDimension>¶
Dimension descriptor to be used in conjunction with Information stored in a DataFrame.
Suppose that a set of measurements have been made under certain settings. These settings are stored in the table-like structure of a DataFrame. The DataArray can use the information of the DataFrame to describe the respective dimension of the data.
A DataFrameDimension is defined by the DataFrame and the index of the column that should be used to annotate the axis of the data.
Creating a :
The following example will create a DataArray that stores a set of regularly sampled data recorded under conditions stored in a DataFrame.
nix::NDSize data_shape = {1000, 10} double dt = 0.001; double pi = 3.1415; // create dummy data std::vector<double> frequencies(10); for (size_t i = 0; i < 10; ++i) frequencies[i] = (i + 1) * 10; typedef boost::multi_array<double, 2> array_type; typedef array_type::index index; array_type data(boost::extents[1000][10]); for(index i = 0; i < 1000; ++i) { for(index j = 0; j < 10; ++j) { data[i][j] = std::sin(i * st * 2 * pi * frequencies[j]); } } // create the DataFrame std::vector<nix::Column> cols = {{"frequency", "Hz", nix::DataType::Double}}; nix::DataFrame df = block.createDataFrame("frequencies", "nix.df", cols); df.rows(10) df.writeColumn(0, frequencies); // store data in a DataArray nix::DataArray data_array = b.createDataArray("columnDimTest", "test", nix::DataType::Double, data_shape); data_array.setData(data, {0, 0}); data_array.label("voltage"); data_array.unit("mV") // define first data dimension, i.e. regularly sampled in time SampledDimension dim = data_array.appendSampledDimension(time_axis_samplingInterval) dim.label = "time"; dim.unit = "s"; // define second data dimension, information is stored in the // 'frequency' column of the DataFrame data_array.appendDataFrameDimension(df, 0);
Public Functions
-
DataFrameDimension()¶
-
DataFrameDimension(const DataFrameDimension &other)¶
-
inline boost::optional<unsigned> columnIndex() const¶
The column index used from the referenced DataFrame.
- Returns
the index the specified column index or -1 if none was set upon creation.
-
inline std::shared_ptr<base::IDataFrame> data() const¶
Returns the DataFrame to which this Dimension links.
- Returns
shared pointer of the type IDataFrame
-
inline std::string label(boost::optional<unsigned> col_index = {}) const¶
Getter of the Column label.
- Parameters
col_index – the index of the DataFrame column. When called with no arguments, the default column specified during creation of the Dimension will be chosen. If no default column was specified upon creation of the DataFrameDimension and no argument is given the DataFrame’s name will be returned.
- Returns
the label, that is defined in the Column, or if not otherwise specified, the name of the DataFrame.
-
inline std::string unit(boost::optional<unsigned> col_index = {}) const¶
Getter of the Column’s unit.
- Parameters
col_index – the index of the DataFrame column. When called with no arguments, the default column specified during creation of the Dimension will be chosen. If no default column was specified upon creation of the DataFrameDimension and no argument is given an exception will be thrown.
- Returns
the unit, if any, that is defined in the Column.
-
inline nix::DataType columnDataType(boost::optional<unsigned> col_index = {}) const¶
Getter of the column’s data type.
- Parameters
col_index – the index of the DataFrame column. When called with no arguments, the default column specified during creation of the Dimension will be chosen. If no default column was specified upon creation of the DataFrameDimension and no argument is given an exception will be thrown.
- Returns
the column’s data type
-
template<typename T>
inline void ticks(std::vector<T> &ticks, boost::optional<unsigned> col_index = {}, bool resize = false, ndsize_t offset = 0) const¶ The values (ticks) of the DataFrameDimension.
- Parameters
col_index – the index of the DataFrame column. When called with no arguments, the default column specified during creation of the Dimension will be chosen. If no default column was specified upon creation of the DataFrameDimension and no argument is given an exception will be thrown.
ticks – std::vector<T> return argument to store the ticks.
resize – boolean to indicate whether or not the ticks vector should be resized. If false (default), the size of the vector is taken as the number of ticks to read. If true, all ticks will be read and returned.
offset – the offset (default 0) relative to the start of the column.
-
boost::optional<ndsize_t> indexOf(const double position, const PositionMatch match) const¶
returns the index in this dimension that matches the given position.
- Parameters
position – The position that should be converted to a corresponding index in the dimension.
match – The matching rule for the position PositionMatch.
- Returns
an boost::optional containing the index.
-
boost::optional<std::pair<ndsize_t, ndsize_t>> indexOf(double start_position, double end_position, RangeMatch range_match) const¶
Converts a range defined by start and end position to the corresponding indices in the dimension.
- Parameters
start_position – The start position that should be converted to a corresponding index in the dimension.
end_position – The start position that should be converted to a corresponding index in the dimension.
range_match – The matching rule for the position RangeMatch.
- Returns
an boost::optional containing a std::pair of start and end index.
-
boost::optional<std::pair<ndsize_t, ndsize_t>> indexOf(double start_position, double end_position, ndsize_t tick_count, RangeMatch range_match) const¶
Converts a range defined by start and end position to the corresponding indices in the dimension. Mostly needed internally.
- Parameters
start_position – The start position that should be converted to a corresponding index in the dimension.
end_position – The start position that should be converted to a corresponding index in the dimension.
tick_count – The number of of ticks stored in this dimension.
range_match – The matching rule for the range RangeMatch.
- Returns
an boost::optional containing a std::pair of start and end index.
-
std::vector<boost::optional<std::pair<ndsize_t, ndsize_t>>> indexOf(const std::vector<double> &start_positions, const std::vector<double> &end_positions, const RangeMatch range_match) const¶
Converts a set of start and end positions to a vector of pairs of start and end indices.
- Parameters
start_positions – std::vector of start positions.
end_positions – std::vector of end positions.
range_match – The matching rule for the range RangeMatch.
- Returns
A std::vector of boost::optionals containing pairs of start and end indices.
-
inline ndsize_t size() const¶
returns the number of entries in the dimension, aka the number of rows in the DataFrame.
- Returns
the size
-
inline DimensionType dimensionType() const¶
The type of the dimension.
This field indicates whether the dimension is a SampledDimension, SetDimension or RangeDimension.
- Returns
The dimension type.
-
DataFrameDimension &operator=(const DataFrameDimension &other)¶
Assignment operator.
- Parameters
other – The dimension to assign.
-
DataFrameDimension &operator=(const Dimension &other)¶
Assignment operator that converts a Dimension to a DataFrameDimension.
- Parameters
other – The dimension to assign.
-
inline DataFrameDimension &operator=(const none_t &t)¶
Assignment operator for none.
-
DataFrameDimension()¶