12 #include "eckit/exception/Exceptions.h"
14 #include "../RowSlice.h"
29 std::vector<std::string> categories;
32 categories.push_back(
name.second);
42 std::map<std::string, BufrDataMap> dataMaps;
49 std::vector<size_t> indexVec;
51 rowIdx < static_cast<int>(dataMap.at(
mnemonic_).rows());
54 if (mnemonicArr.row(rowIdx)[0] == mapPair.first)
56 indexVec.push_back(rowIdx);
62 for (
const auto& dataPair : dataMap)
64 const auto newArr =
rowSlice(dataPair.second, indexVec);
65 newDataMap.insert({dataPair.first, newArr});
68 dataMaps.insert({mapPair.second, newDataMap});
79 for (
auto rowIdx = 0; rowIdx < array.rows(); rowIdx++)
81 auto itemVal = array.row(rowIdx)[0];
82 if (trunc(itemVal) == itemVal)
84 nameMap_.insert({
static_cast<int> (itemVal),
85 std::to_string(
static_cast<int> (itemVal))});
89 std::stringstream errStr;
90 errStr <<
"Can't turn " <<
mnemonic_ <<
" into a category as it contains ";
91 errStr <<
"non-integer values.";
92 throw eckit::BadParameter(errStr.str());
99 std::stringstream errStr;
100 errStr <<
"No categories could be identified for " <<
mnemonic_ <<
".";
101 throw eckit::BadParameter(errStr.str());
EigenType rowSlice(const EigenType &arr, const EigenIdxType &idxVec)
Collection of template methods that are used to slice array and vector data.
std::map< int, std::string > NameMap
Map of integers to strings where the key represents the split mnemonics integer value and the value i...
CategorySplit(const std::string &mnemonic, const NameMap &map)
constructor
std::map< std::string, BufrDataMap > split(const BufrDataMap &dataMap) final
Split the data according to internal rules.
std::vector< std::string > subCategories(const BufrDataMap &dataMap) final
Get list of sub categories this split will create.
const std::string mnemonic_
void updateNameMap(const BufrDataMap &dataMap)
Adds values to nameMap_ using the data if nameMap_ is empty.
Eigen::Array< FloatType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > IngesterArray
IngesterArrayMap BufrDataMap