mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches

template<typename dataT>
class mx::improc::eigenCube< dataT >

An image cube with an Eigen-like API.

Definition at line 32 of file eigenCube.hpp.

#include <improc/eigenCube.hpp>

Public Member Functions

 eigenCube (Index nrows, Index ncols, Index nplanes)
 C'tor which will allocate space..
 eigenCube (dataT *ndata, size_t nrows, size_t ncols, size_t nplanes)
 C'tor taking an existing array as an argument.
 eigenCube (const eigenCube< dataT > &ec)
 Copy a cube into independently owned storage.
 eigenCube (eigenCube< dataT > &&ec) noexcept
 Move a cube, transferring any owned storage.
eigenCube< dataT > & operator= (const eigenCube< dataT > &ec)
 Copy a cube into independently owned storage.
eigenCube< dataT > & operator= (eigenCube< dataT > &&ec) noexcept
 Move a cube, transferring any owned storage.
void clear ()
 De-allocate and set all sizes to 0.
Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > cube ()
 Returns a 2D Eigen::Eigen::Map pointed at the entire cube.
Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > image (Index n)
 Returns a 2D Eigen::Eigen::Map pointed at the specified image.
const Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > image (Index n) const
 Returns a 2D Eigen::Eigen::Map pointed at the specified image.
Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic >, Eigen::Unaligned, Eigen::Stride< Eigen::Dynamic, Eigen::Dynamic > > pixel (Index i, Index j)
 Returns an Eigen::Eigen::Map-ed vector of the pixels at the given coordinate.
Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > asVectors ()
 Return an Eigen::Eigen::Map of the cube where each image is a vector.
void Covar (Eigen::Matrix< dataT, Eigen::Dynamic, Eigen::Dynamic > &cv)
 Calculate the covariance matrix of the images in the cube.
template<typename eigenT>
void sum (eigenT &mim)
 Calculate the sum image of the cube.
template<typename eigenT>
void mean (eigenT &mim)
 Calculate the mean image of the cube.
template<typename eigenT, typename eigenCubeT>
void mean (eigenT &mim, eigenCubeT &mask, double minGoodFract=0.0)
 Calculate the mean image of the cube with a mask.
template<typename eigenT>
void mean (eigenT &mim, std::vector< dataT > &weights)
 Calculate the weighted mean image of the cube.
template<typename eigenT, typename eigenCubeT>
void mean (eigenT &mim, std::vector< dataT > &weights, eigenCubeT &mask, double minGoodFract=0.0)
 Calculate the weighted mean image of the cube, with a mask cube.
template<typename eigenT>
void median (eigenT &mim)
 Calculate the median image of the cube.
template<typename eigenT, typename eigenCubeT>
void median (eigenT &mim, eigenCubeT &mask, double minGoodFract=0.0)
 Calculate the median image of the cube with a mask.
template<typename eigenT>
void sigmaMean (eigenT &mim, Scalar sigma)
 Calculate the sigma clipped mean image of the cube.
template<typename eigenT, typename eigenCubeT>
void sigmaMean (eigenT &mim, eigenCubeT &mask, Scalar sigma, double minGoodFract=0.0)
 Calculate the sigma clipped mean image of the cube, with a mask cube.
template<typename eigenT>
void sigmaMean (eigenT &mim, std::vector< dataT > &weights, Scalar sigma)
 Calculate the sigma clipped weighted mean image of the cube.
template<typename eigenT, typename eigenCubeT>
void sigmaMean (eigenT &mim, std::vector< dataT > &weights, eigenCubeT &mask, Scalar sigma, double minGoodFract=0.0)
 Calculate the sigma clipped weighted mean image of the cube, with a mask cube.

Protected Member Functions

template<typename eigenCubeT>
void validateMaskedCombination (const eigenCubeT &mask, double minGoodFract) const
 Validate a mask and good-pixel threshold for a masked combination.
void validateWeights (const std::vector< dataT > &weights) const
 Validate the number of weights for a weighted combination.
bool hasEnoughGoodPixels (size_t goodPixels, double minGoodFract) const
 Test whether a nonempty set of good pixels meets the requested fraction.

Constructor & Destructor Documentation

◆ eigenCube() [1/4]

template<typename dataT>
mx::improc::eigenCube< dataT >::eigenCube ( Index nrows,
Index ncols,
Index nplanes )

C'tor which will allocate space..

Parameters
[in]nrowsNumber of rows in the cube
[in]ncolsNumber of columns the cube
[in]nplanesNumber of planes in the cube

Definition at line 334 of file eigenCube.hpp.

◆ eigenCube() [2/4]

template<typename dataT>
mx::improc::eigenCube< dataT >::eigenCube ( dataT * ndata,
size_t nrows,
size_t ncols,
size_t nplanes )

C'tor taking an existing array as an argument.

The existing array is used as is, as in a map, and ownership is not taken. You are responsible for memory management, e.g. free-ing this array.

Parameters
[in]ndataAllocated array with a cube of nrows x ncols x nplanes
[in]nrowsNumber of rows in the cube
[in]ncolsNumber of columns the cube
[in]nplanesNumber of planes in the cube

Definition at line 345 of file eigenCube.hpp.

◆ eigenCube() [3/4]

template<typename dataT>
mx::improc::eigenCube< dataT >::eigenCube ( const eigenCube< dataT > & ec)

Copy a cube into independently owned storage.

Parameters
[in]eccube to copy.

Definition at line 356 of file eigenCube.hpp.

◆ eigenCube() [4/4]

template<typename dataT>
mx::improc::eigenCube< dataT >::eigenCube ( eigenCube< dataT > && ec)
noexcept

Move a cube, transferring any owned storage.

Parameters
[in,out]eccube to move from.

Definition at line 362 of file eigenCube.hpp.

Member Function Documentation

◆ asVectors()

template<typename dataT>
Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > mx::improc::eigenCube< dataT >::asVectors ( )

Return an Eigen::Eigen::Map of the cube where each image is a vector.

Definition at line 561 of file eigenCube.hpp.

Referenced by Covar(), mx::AO::ifPInv(), mx::AO::m2cMatrix(), and unitTest::improcTest::eigenCubeTest::TEST_CASE().

◆ clear()

template<typename dataT>
void mx::improc::eigenCube< dataT >::clear ( )

De-allocate and set all sizes to 0.

Definition at line 464 of file eigenCube.hpp.

Referenced by operator=(), and unitTest::improcTest::eigenCubeTest::TEST_CASE().

◆ Covar()

template<typename dataT>
void mx::improc::eigenCube< dataT >::Covar ( Eigen::Matrix< dataT, Eigen::Dynamic, Eigen::Dynamic > & cv)

Calculate the covariance matrix of the images in the cube.

Definition at line 567 of file eigenCube.hpp.

References asVectors().

Referenced by unitTest::improcTest::eigenCubeTest::TEST_CASE().

◆ cube()

template<typename dataT>
Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > mx::improc::eigenCube< dataT >::cube ( )

Returns a 2D Eigen::Eigen::Map pointed at the entire cube.

Definition at line 528 of file eigenCube.hpp.

Referenced by TEST_CASE(), and unitTest::improcTest::eigenCubeTest::TEST_CASE().

◆ hasEnoughGoodPixels()

template<typename dataT>
bool mx::improc::eigenCube< dataT >::hasEnoughGoodPixels ( size_t goodPixels,
double minGoodFract ) const
protected

Test whether a nonempty set of good pixels meets the requested fraction.

Parameters
[in]goodPixelsnumber of unmasked pixels.
[in]minGoodFractinclusive minimum fraction of good pixels.

Definition at line 319 of file eigenCube.hpp.

Referenced by mean(), mean(), median(), sigmaMean(), and sigmaMean().

◆ image() [1/2]

◆ image() [2/2]

template<typename dataT>
const Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > mx::improc::eigenCube< dataT >::image ( Index n) const

Returns a 2D Eigen::Eigen::Map pointed at the specified image.

Parameters
[in]nthe image number

Definition at line 540 of file eigenCube.hpp.

◆ mean() [1/4]

template<typename dataT>
template<typename eigenT>
void mx::improc::eigenCube< dataT >::mean ( eigenT & mim)

Calculate the mean image of the cube.

Template Parameters
eigenTan Eigen-like type.
Parameters
[out]mimthe resultant mean image. Is resized.

Definition at line 590 of file eigenCube.hpp.

References pixel().

Referenced by unitTest::improcTest::eigenCubeTest::TEST_CASE(), unitTest::improcTest::eigenCubeTest::TEST_CASE(), unitTest::improcTest::eigenCubeTest::TEST_CASE(), and unitTest::improcTest::eigenCubeTest::TEST_CASE().

◆ mean() [2/4]

template<typename dataT>
template<typename eigenT, typename eigenCubeT>
void mx::improc::eigenCube< dataT >::mean ( eigenT & mim,
eigenCubeT & mask,
double minGoodFract = 0.0 )

Calculate the mean image of the cube with a mask.

A nonempty pixel sample is accepted when its good-pixel fraction is greater than or equal to minGoodFract. Rejected pixels are set to invalidNumber<Scalar>().

Template Parameters
eigenTan Eigen-like type.
eigenCubeTan eigenCube type.
Exceptions
mx::exceptionwith error_t::sizeerr if the mask dimensions do not match the cube.
mx::exceptionwith error_t::invalidarg if minGoodFract is not finite or is outside [0, 1].
Parameters
[out]mimthe resultant mean image. Is resized.
[in]maska mask cube. Only pixels with value 1 are included in the mean calculation.
[in]minGoodFractinclusive minimum fraction of good pixels in [0, 1].

Definition at line 606 of file eigenCube.hpp.

References hasEnoughGoodPixels(), mx::improc::invalidNumber(), pixel(), validateMaskedCombination(), and mx::math::vectorMean().

◆ mean() [3/4]

template<typename dataT>
template<typename eigenT>
void mx::improc::eigenCube< dataT >::mean ( eigenT & mim,
std::vector< dataT > & weights )

Calculate the weighted mean image of the cube.

Template Parameters
eigenTan Eigen-like type.
Exceptions
mx::exceptionwith error_t::sizeerr if the weight count does not match the cube planes.
Parameters
[out]mimthe resultant mean image. Is resized.
[in]weightsa vector of weights to use for calculating the mean

Definition at line 647 of file eigenCube.hpp.

References pixel(), validateWeights(), and mx::math::vectorMean().

◆ mean() [4/4]

template<typename dataT>
template<typename eigenT, typename eigenCubeT>
void mx::improc::eigenCube< dataT >::mean ( eigenT & mim,
std::vector< dataT > & weights,
eigenCubeT & mask,
double minGoodFract = 0.0 )

Calculate the weighted mean image of the cube, with a mask cube.

A nonempty pixel sample is accepted when its good-pixel fraction is greater than or equal to minGoodFract. Rejected pixels are set to invalidNumber<Scalar>().

Template Parameters
eigenTan Eigen-like type.
eigenCubeTan eigenCube type.
Exceptions
mx::exceptionwith error_t::sizeerr if the mask dimensions or weight count do not match the cube.
mx::exceptionwith error_t::invalidarg if minGoodFract is not finite or is outside [0, 1].
Parameters
[out]mimthe resultant mean image. Is resized.
[in]weightsa vector of weights to use for calculating the mean
[in]maska mask cube. Only pixels with value 1 are included in the mean calculation.
[in]minGoodFractinclusive minimum fraction of good pixels in [0, 1].

Definition at line 675 of file eigenCube.hpp.

References hasEnoughGoodPixels(), mx::improc::invalidNumber(), pixel(), validateMaskedCombination(), validateWeights(), and mx::math::vectorMean().

◆ median() [1/2]

template<typename dataT>
template<typename eigenT>
void mx::improc::eigenCube< dataT >::median ( eigenT & mim)

Calculate the median image of the cube.

Template Parameters
eigenTan Eigen-like type.
Parameters
[out]mimthe resultant median image. Is resized.

Definition at line 717 of file eigenCube.hpp.

References mx::improc::imageMedian(), and pixel().

Referenced by unitTest::improcTest::eigenCubeTest::TEST_CASE(), unitTest::improcTest::eigenCubeTest::TEST_CASE(), unitTest::improcTest::eigenCubeTest::TEST_CASE(), and unitTest::improcTest::eigenCubeTest::TEST_CASE().

◆ median() [2/2]

template<typename dataT>
template<typename eigenT, typename eigenCubeT>
void mx::improc::eigenCube< dataT >::median ( eigenT & mim,
eigenCubeT & mask,
double minGoodFract = 0.0 )

Calculate the median image of the cube with a mask.

A nonempty pixel sample is accepted when its good-pixel fraction is greater than or equal to minGoodFract. Rejected pixels are set to invalidNumber<Scalar>().

Template Parameters
eigenTan Eigen-like type.
eigenCubeTan eigenCube type.
Exceptions
mx::exceptionwith error_t::sizeerr if the mask dimensions do not match the cube.
mx::exceptionwith error_t::invalidarg if minGoodFract is not finite or is outside [0, 1].
Parameters
[out]mimthe resultant median image. Is resized.
[in]maska mask cube. Only pixels with value 1 are included.
[in]minGoodFractthe inclusive minimum fraction of good pixels.

Definition at line 735 of file eigenCube.hpp.

References hasEnoughGoodPixels(), mx::improc::invalidNumber(), pixel(), validateMaskedCombination(), and mx::math::vectorMedianInPlace().

◆ operator=() [1/2]

template<typename dataT>
eigenCube< dataT > & mx::improc::eigenCube< dataT >::operator= ( const eigenCube< dataT > & ec)

Copy a cube into independently owned storage.

Parameters
[in]eccube to copy.

Definition at line 391 of file eigenCube.hpp.

◆ operator=() [2/2]

template<typename dataT>
eigenCube< dataT > & mx::improc::eigenCube< dataT >::operator= ( eigenCube< dataT > && ec)
noexcept

Move a cube, transferring any owned storage.

Parameters
[in,out]eccube to move from.

Definition at line 409 of file eigenCube.hpp.

References clear().

◆ pixel()

template<typename dataT>
Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic >, Eigen::Unaligned, Eigen::Stride< Eigen::Dynamic, Eigen::Dynamic > > mx::improc::eigenCube< dataT >::pixel ( Index i,
Index j )

Returns an Eigen::Eigen::Map-ed vector of the pixels at the given coordinate.

Definition at line 549 of file eigenCube.hpp.

Referenced by mean(), mean(), mean(), mean(), median(), median(), sigmaMean(), sigmaMean(), sigmaMean(), sigmaMean(), sum(), TEST_CASE(), and unitTest::improcTest::eigenCubeTest::TEST_CASE().

◆ sigmaMean() [1/4]

template<typename dataT>
template<typename eigenT, typename eigenCubeT>
void mx::improc::eigenCube< dataT >::sigmaMean ( eigenT & mim,
eigenCubeT & mask,
Scalar sigma,
double minGoodFract = 0.0 )

Calculate the sigma clipped mean image of the cube, with a mask cube.

A nonempty pixel sample is accepted when its good-pixel fraction is greater than or equal to minGoodFract. Rejected pixels are set to invalidNumber<Scalar>().

Template Parameters
eigenTan Eigen-like type.
eigenCubeTan eigenCube type.
Exceptions
mx::exceptionwith error_t::sizeerr if the mask dimensions do not match the cube.
mx::exceptionwith error_t::invalidarg if minGoodFract is not finite or is outside [0, 1].
Parameters
[out]mimthe resultant mean image. Is resized.
[in]maska mask cube. Only pixels with value 1 are included in the mean calculation.
[in]sigmathe sigma value at which to clip.
[in]minGoodFractinclusive minimum fraction of good pixels in [0, 1].

Definition at line 804 of file eigenCube.hpp.

References hasEnoughGoodPixels(), mx::improc::invalidNumber(), pixel(), validateMaskedCombination(), and mx::math::vectorSigmaMean().

◆ sigmaMean() [2/4]

template<typename dataT>
template<typename eigenT>
void mx::improc::eigenCube< dataT >::sigmaMean ( eigenT & mim,
Scalar sigma )

Calculate the sigma clipped mean image of the cube.

Template Parameters
eigenTan Eigen-like type.
Parameters
[out]mimthe resultant mean image
[in]sigmathe sigma value at which to clip.

Definition at line 775 of file eigenCube.hpp.

References pixel(), and mx::math::vectorSigmaMean().

Referenced by unitTest::improcTest::eigenCubeTest::TEST_CASE(), unitTest::improcTest::eigenCubeTest::TEST_CASE(), and unitTest::improcTest::eigenCubeTest::TEST_CASE().

◆ sigmaMean() [3/4]

template<typename dataT>
template<typename eigenT, typename eigenCubeT>
void mx::improc::eigenCube< dataT >::sigmaMean ( eigenT & mim,
std::vector< dataT > & weights,
eigenCubeT & mask,
Scalar sigma,
double minGoodFract = 0.0 )

Calculate the sigma clipped weighted mean image of the cube, with a mask cube.

A nonempty pixel sample is accepted when its good-pixel fraction is greater than or equal to minGoodFract. Rejected pixels are set to invalidNumber<Scalar>().

Template Parameters
eigenTan Eigen-like type.
eigenCubeTan eigenCube type.
Exceptions
mx::exceptionwith error_t::sizeerr if the mask dimensions or weight count do not match the cube.
mx::exceptionwith error_t::invalidarg if minGoodFract is not finite or is outside [0, 1].
Parameters
[out]mimthe resultant mean image. Is resized.
[in]weightsa vector of weights to use for calculating the mean
[in]maska mask cube. Only pixels with value 1 are included in the mean calculation.
[in]sigmathe sigma value at which to clip.
[in]minGoodFractinclusive minimum fraction of good pixels in [0, 1].

Definition at line 870 of file eigenCube.hpp.

References hasEnoughGoodPixels(), mx::improc::invalidNumber(), pixel(), validateMaskedCombination(), validateWeights(), and mx::math::vectorSigmaMean().

◆ sigmaMean() [4/4]

template<typename dataT>
template<typename eigenT>
void mx::improc::eigenCube< dataT >::sigmaMean ( eigenT & mim,
std::vector< dataT > & weights,
Scalar sigma )

Calculate the sigma clipped weighted mean image of the cube.

Template Parameters
eigenTan Eigen-like type.
Exceptions
mx::exceptionwith error_t::sizeerr if the weight count does not match the cube planes.
Parameters
[out]mimthe resultant mean image. Is resized.
[in]weightsa vector of weights to use for calculating the mean
[in]sigmathe sigma value at which to clip.

Definition at line 843 of file eigenCube.hpp.

References pixel(), validateWeights(), and mx::math::vectorSigmaMean().

◆ sum()

template<typename dataT>
template<typename eigenT>
void mx::improc::eigenCube< dataT >::sum ( eigenT & mim)

Calculate the sum image of the cube.

Template Parameters
eigenTan Eigen-like type.
Parameters
[out]mimthe resultant sum image. Is resized.

Definition at line 574 of file eigenCube.hpp.

References pixel().

◆ validateMaskedCombination()

template<typename dataT>
template<typename eigenCubeT>
void mx::improc::eigenCube< dataT >::validateMaskedCombination ( const eigenCubeT & mask,
double minGoodFract ) const
protected

Validate a mask and good-pixel threshold for a masked combination.

Parameters
[in]maskmask cube whose dimensions must match this cube.
[in]minGoodFractinclusive minimum fraction of good pixels in [0, 1].

Definition at line 296 of file eigenCube.hpp.

References mx::exception, mx::invalidarg, mx::math::isFinite(), and mx::sizeerr.

Referenced by mean(), mean(), median(), sigmaMean(), and sigmaMean().

◆ validateWeights()

template<typename dataT>
void mx::improc::eigenCube< dataT >::validateWeights ( const std::vector< dataT > & weights) const
protected

Validate the number of weights for a weighted combination.

Parameters
[in]weightsweights whose count must match the number of planes.

Definition at line 310 of file eigenCube.hpp.

References mx::exception, and mx::sizeerr.

Referenced by mean(), mean(), sigmaMean(), and sigmaMean().


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