25 const std::vector<Dimensions_t>& dim_sizes) {
27 std::vector<ioda::ObsStore::SelectSpecs> dim_selects;
28 std::size_t start = 0;
29 std::size_t npoints = 0;
45 for (std::size_t idim = 0; idim < dim_sizes.size(); ++idim) {
46 npoints *= dim_sizes[idim];
49 auto first_action = selection.
getActions().begin();
50 if (!first_action->start_.empty()) {
53 genDimSelects(first_action->start_, first_action->count_, first_action->stride_,
54 first_action->block_, dim_selects);
55 }
else if (!first_action->points_.empty()) {
59 }
else if (!first_action->dimension_indices_starts_.empty()) {
75 std::vector<ioda::ObsStore::SelectSpecs>& selects) {
78 std::size_t numDims = start.size();
79 selects.resize(numDims);
80 for (std::size_t idim = 0; idim < numDims; ++idim) {
82 std::size_t dim_start = start[idim];
83 std::size_t dim_count = count[idim];
84 std::size_t dim_stride = 1;
85 if (!stride.empty()) {
86 dim_stride = stride[idim];
88 std::size_t dim_block = 1;
90 dim_block = block[idim];
94 for (std::size_t i = 0; i < dim_count; ++i) {
95 std::size_t block_start = dim_start + (i * dim_stride);
96 for (std::size_t j = 0; j < dim_block; ++j) {
97 selects[idim].push_back(block_start + j);
104 std::vector<ioda::ObsStore::SelectSpecs>& selects) {
108 std::size_t numPoints = points.size();
109 std::size_t numDims = points[0].size();
110 selects.resize(numDims);
111 for (std::size_t idim = 0; idim < numDims; ++idim) {
112 selects[idim].resize(numPoints);
115 for (std::size_t ipnt = 0; ipnt < numPoints; ++ipnt) {
116 for (std::size_t idim = 0; idim < numDims; ++idim) {
117 selects[idim][ipnt] = points[ipnt][idim];
123 const std::vector<Dimensions_t>& dim_sizes,
124 std::vector<ioda::ObsStore::SelectSpecs>& selects) {
129 selects.resize(dim_sizes.size());
132 for (std::size_t iact = 0; iact < actions.size(); ++iact) {
135 std::set<std::size_t> dim_indices;
136 bool haveCounts = (!actions[iact].dimension_indices_counts_.empty());
137 for (std::size_t i = 0; i < actions[iact].dimension_indices_starts_.size(); ++i) {
138 std::size_t idx = actions[iact].dimension_indices_starts_[i];
140 for (std::size_t j = 0; j < actions[iact].dimension_indices_counts_.size(); ++j) {
141 dim_indices.insert(idx + j);
144 dim_indices.insert(idx);
149 std::size_t idim = actions[iact].dimension_;
150 selects[idim].resize(dim_indices.size());
151 std::size_t iidx = 0;
152 for (
auto iset = dim_indices.begin(); iset != dim_indices.end(); ++iset) {
153 selects[idim][iidx] = *iset;
159 for (std::size_t idim = 0; idim < selects.size(); ++idim) {
160 if (selects[idim].empty()) {
161 selects[idim].resize(dim_sizes[idim]);
162 std::iota(selects[idim].begin(), selects[idim].end(), 0);
Functions for transfering ioda::Selection to ObsStore.
The ioda exception class.
A Selection represents the bounds of the data, in ioda or in userspace, that you are reading or writi...
Common preprocessor definitions used throughout IODA.
@ ObsStore
ObsStore in-memory.
const std::vector< SingleSelection > & getActions() const
std::vector< Dimensions_t > VecDimensions_t
SelectionState getDefault() const
void genDimSelects(const Selection::VecDimensions_t &start, const Selection::VecDimensions_t &count, const Selection::VecDimensions_t &stride, const Selection::VecDimensions_t &block, std::vector< ioda::ObsStore::SelectSpecs > &selects)
generate the dimension selection structure from hyperslab specs
SelectionModes
ObsStore selection modes.
ioda::ObsStore::Selection createObsStoreSelection(const ioda::Selection &selection, const std::vector< Dimensions_t > &dim_sizes)
translate a ioda::Selection to and ObsStore Selection