IODA Bundle
BufrAccumulator.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020 NOAA/NWS/NCEP/EMC
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 
8 #pragma once
9 
10 #include <set>
11 
12 #include "Eigen/Dense"
13 
14 #include "BufrParser/BufrTypes.h"
15 
16 namespace Ingester
17 {
18  /// \brief Accumulates provided data into a dynamically expanding Eigen Array
20  {
21  public:
22  /// \param numColumns Width of collected data.
23  /// \param blockSize The amount to allocate when we need to extend the Eigen Array
24  explicit BufrAccumulator(Eigen::Index numColumns, Eigen::Index blockSize = 50000);
25 
26  /// \brief Add row of data to the internal data structure
27  /// \param newRow Collection of values to add (size must match the number of columns)
28  void addRow(std::vector<FloatType>& newRow);
29 
30  /// \brief Get an Eigen Array that contains a slice of the collected data.
31  /// \param elementPos Position of mnemonic in the list of read mnemonics.
32  /// \param numElementsPerSet Number of mnemonics in the list.
33  /// \param indices indices to collect starting from the start position
34  IngesterArray getData(Eigen::Index elementPos,
35  Eigen::Index numElementsPerSet,
36  const Channels& indices = {1});
37 
38  /// \brief Start over
39  void reset();
40 
41  // Getters
42  inline Eigen::Index getNumColumns() const { return numColumns_; }
43 
44  private:
45  /// \brief Eigen Array that holds the accumulated data
47 
48  /// \brief Total number of columns (width of data structure)
49  Eigen::Index numColumns_;
50 
51  /// \brief Number of data rows of collected data.
52  Eigen::Index numDataRows_;
53 
54  /// \brief Amount to allocate when we need to extend the Eigen Array
55  Eigen::Index blockSize_;
56  };
57 } // namespace Ingester
Accumulates provided data into a dynamically expanding Eigen Array.
void addRow(std::vector< FloatType > &newRow)
Add row of data to the internal data structure.
BufrAccumulator(Eigen::Index numColumns, Eigen::Index blockSize=50000)
Eigen::Index numColumns_
Total number of columns (width of data structure)
Eigen::Index getNumColumns() const
IngesterArray dataArray_
Eigen Array that holds the accumulated data.
IngesterArray getData(Eigen::Index elementPos, Eigen::Index numElementsPerSet, const Channels &indices={1})
Get an Eigen Array that contains a slice of the collected data.
Eigen::Index blockSize_
Amount to allocate when we need to extend the Eigen Array.
Eigen::Index numDataRows_
Number of data rows of collected data.
Eigen::Array< FloatType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > IngesterArray
Definition: IngesterTypes.h:19
std::set< size_t > Channels
Definition: BufrTypes.h:18