UFO
ufo::SpatialBinSelector Class Reference

Represents a partition of a sphere into a number of subsets (bins). More...

#include <SpatialBinSelector.h>

Collaboration diagram for ufo::SpatialBinSelector:

Public Types

typedef float ValueType
 
typedef int IndexType
 

Public Member Functions

 SpatialBinSelector (IndexType numLatitudeBins, SpatialBinCountRoundingMode roundingMode, bool metOfficeOpsCompatibilityMode=false)
 Partition a sphere into bins whose centers lie on a reduced Gaussian grid. More...
 
 SpatialBinSelector (IndexType numLatitudeBins, IndexType numLongitudeBins, bool metOfficeOpsCompatibilityMode=false)
 Partition a sphere into bins whose centers lie on a regular Gaussian grid. More...
 
IndexType latitudeBin (ValueType latitude) const
 Return the index of the zonal band of bins containing points with a given latitude (in degrees, assumed to lie in the interval [-90, 90]). More...
 
IndexType longitudeBin (IndexType latitudeBin, ValueType longitude) const
 Return the index of the bin within the zonal band of index latitudeBin containing points with a given longitude (in degrees). More...
 
ValueType latitudeBinCenter (IndexType latitudeBin) const
 Return the latitude at the center of the zonal band of bins with index latitudeBin. More...
 
ValueType longitudeBinCenter (IndexType latitudeBin, IndexType longitudeBin) const
 Return the longitude at the center of the bin with index latitudeBin lying in the zonal band of bins with index latitudeBin. More...
 
IndexType totalNumBins () const
 Return the number of bins into which the sphere is split. More...
 
ValueType latitudeBinWidth () const
 Return the width of each zonal band of bins. More...
 
ValueType longitudeBinWidth (IndexType latitudeBin) const
 Return the zonal width of each bin in the band of bins with index latitudeBin. More...
 
ValueType inverseLatitudeBinWidth () const
 Return the inverse of the width of each zonal band of bins. More...
 
ValueType inverseLongitudeBinWidth (IndexType latitudeBin) const
 Return the inverse of the zonal width of each bin in the band of bins with index latitudeBin. More...
 

Static Public Member Functions

static IndexType roundNumBins (float idealNumBins, SpatialBinCountRoundingMode roundingMode)
 Return idealNumBins rounded to a positive integer according to the rounding strategy roundingMode. More...
 

Private Attributes

bool metOfficeOpsCompatibilityMode_
 
TruncatingEquispacedBinSelector latitudeBinSelector_
 
std::vector< TruncatingEquispacedBinSelectorlongitudeBinSelectors_
 

Static Private Attributes

static constexpr ValueType latitudeLowerBound_ = -90
 
static constexpr ValueType latitudeUpperBound_ = 90
 
static constexpr ValueType longitudeLowerBound_ = 0
 
static constexpr ValueType longitudeUpperBound_ = 360
 
static constexpr ValueType opsCompatibilityModeLongitudeLowerBound_ = -360
 
static constexpr ValueType opsCompatibilityModeLongitudeUpperBound_ = 720
 
static constexpr int opsCompatibilityModeRelativeLongitudeRange_ = 3
 

Detailed Description

Represents a partition of a sphere into a number of subsets (bins).

Definition at line 25 of file SpatialBinSelector.h.

Member Typedef Documentation

◆ IndexType

Definition at line 29 of file SpatialBinSelector.h.

◆ ValueType

Definition at line 28 of file SpatialBinSelector.h.

Constructor & Destructor Documentation

◆ SpatialBinSelector() [1/2]

ufo::SpatialBinSelector::SpatialBinSelector ( IndexType  numLatitudeBins,
SpatialBinCountRoundingMode  roundingMode,
bool  metOfficeOpsCompatibilityMode = false 
)

Partition a sphere into bins whose centers lie on a reduced Gaussian grid.

Parameters
numLatitudeBinsThe number of zonal bands of bins into which the sphere is split.
roundingMode
  • If set to NEAREST, the number of bins in each zonal band is chosen so that the bin width in the zonal direction is as close as possible to that in the meridional direction.
  • If set to DOWN, the number of bins is chosen so that the bin width in the zonal direction is as small as possible, but no smaller than in the meridional direction.
metOfficeOpsCompatibilityModeIf true, the compatibility mode with the Met Office OPS system will be activated. This will stop longitudeBin() from clamping longitudes to the interval [0, 360] deg.

Activation of this mode in new code is discouraged; even if input longitudes are e.g. in the range [-180, 180] deg, it is normally better to wrap them to the [0, 360] deg range before passing them to longitudeBin(). Otherwise there's a risk that points lying exactly at -180 or 180 deg will be put into a bin of their own.

Definition at line 18 of file SpatialBinSelector.cc.

Here is the call graph for this function:

◆ SpatialBinSelector() [2/2]

ufo::SpatialBinSelector::SpatialBinSelector ( IndexType  numLatitudeBins,
IndexType  numLongitudeBins,
bool  metOfficeOpsCompatibilityMode = false 
)

Partition a sphere into bins whose centers lie on a regular Gaussian grid.

Parameters
numLatitudeBinsThe number of zonal bands of bins into which the sphere is split.
numLongitudeBinsThe number of meridional bands of bins into which the sphere is split.

Definition at line 45 of file SpatialBinSelector.cc.

Member Function Documentation

◆ inverseLatitudeBinWidth()

ValueType ufo::SpatialBinSelector::inverseLatitudeBinWidth ( ) const
inline

Return the inverse of the width of each zonal band of bins.

Definition at line 110 of file SpatialBinSelector.h.

Here is the call graph for this function:

◆ inverseLongitudeBinWidth()

ValueType ufo::SpatialBinSelector::inverseLongitudeBinWidth ( IndexType  latitudeBin) const
inline

Return the inverse of the zonal width of each bin in the band of bins with index latitudeBin.

Definition at line 116 of file SpatialBinSelector.h.

Here is the call graph for this function:

◆ latitudeBin()

IndexType ufo::SpatialBinSelector::latitudeBin ( ValueType  latitude) const
inline

Return the index of the zonal band of bins containing points with a given latitude (in degrees, assumed to lie in the interval [-90, 90]).

Definition at line 72 of file SpatialBinSelector.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ latitudeBinCenter()

ValueType ufo::SpatialBinSelector::latitudeBinCenter ( IndexType  latitudeBin) const
inline

Return the latitude at the center of the zonal band of bins with index latitudeBin.

Definition at line 86 of file SpatialBinSelector.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ latitudeBinWidth()

ValueType ufo::SpatialBinSelector::latitudeBinWidth ( ) const
inline

Return the width of each zonal band of bins.

Definition at line 100 of file SpatialBinSelector.h.

Here is the call graph for this function:

◆ longitudeBin()

IndexType ufo::SpatialBinSelector::longitudeBin ( IndexType  latitudeBin,
ValueType  longitude 
) const
inline

Return the index of the bin within the zonal band of index latitudeBin containing points with a given longitude (in degrees).

The longitude is assumed to lie in the interval [0, 360] unless the compatibility mode with the Met Office OPS system is in effect.

Definition at line 81 of file SpatialBinSelector.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ longitudeBinCenter()

ValueType ufo::SpatialBinSelector::longitudeBinCenter ( IndexType  latitudeBin,
IndexType  longitudeBin 
) const
inline

Return the longitude at the center of the bin with index latitudeBin lying in the zonal band of bins with index latitudeBin.

Definition at line 92 of file SpatialBinSelector.h.

Here is the call graph for this function:

◆ longitudeBinWidth()

ValueType ufo::SpatialBinSelector::longitudeBinWidth ( IndexType  latitudeBin) const
inline

Return the zonal width of each bin in the band of bins with index latitudeBin.

Definition at line 105 of file SpatialBinSelector.h.

Here is the call graph for this function:

◆ roundNumBins()

SpatialBinSelector::IndexType ufo::SpatialBinSelector::roundNumBins ( float  idealNumBins,
SpatialBinCountRoundingMode  roundingMode 
)
static

Return idealNumBins rounded to a positive integer according to the rounding strategy roundingMode.

Definition at line 70 of file SpatialBinSelector.cc.

Here is the caller graph for this function:

◆ totalNumBins()

SpatialBinSelector::IndexType ufo::SpatialBinSelector::totalNumBins ( ) const

Return the number of bins into which the sphere is split.

Definition at line 61 of file SpatialBinSelector.cc.

Member Data Documentation

◆ latitudeBinSelector_

TruncatingEquispacedBinSelector ufo::SpatialBinSelector::latitudeBinSelector_
private

Definition at line 126 of file SpatialBinSelector.h.

◆ latitudeLowerBound_

constexpr ValueType ufo::SpatialBinSelector::latitudeLowerBound_ = -90
staticconstexprprivate

Definition at line 32 of file SpatialBinSelector.h.

◆ latitudeUpperBound_

constexpr ValueType ufo::SpatialBinSelector::latitudeUpperBound_ = 90
staticconstexprprivate

Definition at line 33 of file SpatialBinSelector.h.

◆ longitudeBinSelectors_

std::vector<TruncatingEquispacedBinSelector> ufo::SpatialBinSelector::longitudeBinSelectors_
private

Definition at line 127 of file SpatialBinSelector.h.

◆ longitudeLowerBound_

constexpr ValueType ufo::SpatialBinSelector::longitudeLowerBound_ = 0
staticconstexprprivate

Definition at line 34 of file SpatialBinSelector.h.

◆ longitudeUpperBound_

constexpr ValueType ufo::SpatialBinSelector::longitudeUpperBound_ = 360
staticconstexprprivate

Definition at line 35 of file SpatialBinSelector.h.

◆ metOfficeOpsCompatibilityMode_

bool ufo::SpatialBinSelector::metOfficeOpsCompatibilityMode_
private

Definition at line 125 of file SpatialBinSelector.h.

◆ opsCompatibilityModeLongitudeLowerBound_

constexpr ValueType ufo::SpatialBinSelector::opsCompatibilityModeLongitudeLowerBound_ = -360
staticconstexprprivate

Definition at line 36 of file SpatialBinSelector.h.

◆ opsCompatibilityModeLongitudeUpperBound_

constexpr ValueType ufo::SpatialBinSelector::opsCompatibilityModeLongitudeUpperBound_ = 720
staticconstexprprivate

Definition at line 37 of file SpatialBinSelector.h.

◆ opsCompatibilityModeRelativeLongitudeRange_

constexpr int ufo::SpatialBinSelector::opsCompatibilityModeRelativeLongitudeRange_ = 3
staticconstexprprivate

Definition at line 38 of file SpatialBinSelector.h.


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