sgsPy
structurally guided sampling
Loading...
Searching...
No Matches
sgs::strat::IndexStorageVectors

#include <strat.h>

Public Member Functions

 IndexStorageVectors (int64_t numStrata, int64_t x)
void updateStrataCounts (int strata)
void updateIndexesVector (int strata, helper::Index &index)
void updateFirstXIndexesVector (int strata, helper::Index &index)
std::vector< std::vector< helper::Index > * > getStrataIndexVectors (std::vector< int64_t > existing, std::vector< int64_t > strataSampleCounts, xso::xoshiro_4x64_plus &rng)
std::vector< int64_t > getStrataCounts (void)
int64_t getNumDataPixels (void)

Detailed Description

This struct is responsible for storing the indices saved while iterating through the raster.

The strataCounts vector strores the total count of each strata within the stratified raster. The indexCountPerStrata vector stores the total number of indices saved for each strata. The indexesPerStrata vector stores the indices saved of each strata.

Since the pixels are probabilistically added, and this probability is calculated before knowing the total proportion of strata within the strat raster, there is a potential problem if one strata does not appear as much as the others, as this could mean less than the total number of required pixels for that strata are actually saved. This is where the 'first x' vectors come in. They always store the first x number of pixels in a particular strata, meaning that if there are less than x (10,000) pixels of a particular strata, all pixels within that strata will be saved and there is not a worry of missing out on a particular strata due to having a lower proportion.

Constructor & Destructor Documentation

◆ IndexStorageVectors()

sgs::strat::IndexStorageVectors::IndexStorageVectors ( int64_t numStrata,
int64_t x )
inline

Constructor. Set the numStrata and x variables. Also, resize the vectors so that their size is numStrata.

Parameters
int64_tnumStrata
int64_tx

Member Function Documentation

◆ getNumDataPixels()

int64_t sgs::strat::IndexStorageVectors::getNumDataPixels ( void )
inline

get the total number of data (not nan) pixels.

Returns
int64_t

◆ getStrataCounts()

std::vector< int64_t > sgs::strat::IndexStorageVectors::getStrataCounts ( void )
inline

get the pixel counts per strata.

Returns
std::vector<int64_t>

◆ getStrataIndexVectors()

std::vector< std::vector< helper::Index > * > sgs::strat::IndexStorageVectors::getStrataIndexVectors ( std::vector< int64_t > existing,
std::vector< int64_t > strataSampleCounts,
xso::xoshiro_4x64_plus & rng )
inline

get references to shuffled strata index vectors. This method is called after the whole raster has been iterated through, and potential sample pixels are saved.

If there are not enough values in the normal saved strata, but the first X samples have been saved (and there hasn't been too many pixels), then the first X samples are used. Otherwise, the normal saved samples are used.

A reference is saved for a shuffled version of the vector chosen. The reason a shuffled version is returned is because the raster is iterated through in an ordered manor (by blocks). If it wasn't shuffled, the samples selected would be the ones closes to the beginning.

Parameters
std::vector<int64_t>existing
std::vector<int64_t>strataSampleCounts
xso::xoshiro_4x64_plus&rng
Returns
std::vector<std::vector<Index> *>

◆ updateFirstXIndexesVector()

void sgs::strat::IndexStorageVectors::updateFirstXIndexesVector ( int strata,
helper::Index & index )
inline

update the first x indexes vector with a new index of a particular strata.

Parameters
intstrata
Index&index

◆ updateIndexesVector()

void sgs::strat::IndexStorageVectors::updateIndexesVector ( int strata,
helper::Index & index )
inline

update the indexes vector with a new index of a particular strata.

Parameters
intstrata
Index&index

◆ updateStrataCounts()

void sgs::strat::IndexStorageVectors::updateStrataCounts ( int strata)
inline

update the total count by 1 of a particular strata.

Parameters
intstrata

The documentation for this class was generated from the following file: