|
mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
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. | |
| mx::improc::eigenCube< dataT >::eigenCube | ( | Index | nrows, |
| Index | ncols, | ||
| Index | nplanes ) |
C'tor which will allocate space..
| [in] | nrows | Number of rows in the cube |
| [in] | ncols | Number of columns the cube |
| [in] | nplanes | Number of planes in the cube |
Definition at line 334 of file eigenCube.hpp.
| 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.
| [in] | ndata | Allocated array with a cube of nrows x ncols x nplanes |
| [in] | nrows | Number of rows in the cube |
| [in] | ncols | Number of columns the cube |
| [in] | nplanes | Number of planes in the cube |
Definition at line 345 of file eigenCube.hpp.
| mx::improc::eigenCube< dataT >::eigenCube | ( | const eigenCube< dataT > & | ec | ) |
Copy a cube into independently owned storage.
| [in] | ec | cube to copy. |
Definition at line 356 of file eigenCube.hpp.
|
noexcept |
Move a cube, transferring any owned storage.
| [in,out] | ec | cube to move from. |
Definition at line 362 of file eigenCube.hpp.
| 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().
| 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().
| 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().
| 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().
|
protected |
Test whether a nonempty set of good pixels meets the requested fraction.
| [in] | goodPixels | number of unmasked pixels. |
| [in] | minGoodFract | inclusive minimum fraction of good pixels. |
Definition at line 319 of file eigenCube.hpp.
Referenced by mean(), mean(), median(), sigmaMean(), and sigmaMean().
| Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > mx::improc::eigenCube< dataT >::image | ( | Index | n | ) |
Returns a 2D Eigen::Eigen::Map pointed at the specified image.
| [in] | n | the image number |
Definition at line 534 of file eigenCube.hpp.
Referenced by mx::AO::influenceFunctionsGaussian(), mx::AO::analysis::fourierTemporalPSD< _realT, aosysT >::intensityPSD(), mx::wfp::lyotCoronagraph< _realT, _fpmaskFloatT >::loadFocalMask(), mx::AO::makeModfBasis(), mx::AO::makeZernikeBasis(), mx::AO::modesOnDM(), mx::AO::orthogonalizeBasis(), mx::unitTest::fitsTest::fitsFileTest::TEST_CASE(), TEST_CASE(), TEST_CASE(), unitTest::improcTest::eigenCubeTest::TEST_CASE(), unitTest::improcTest::eigenCubeTest::TEST_CASE(), unitTest::improcTest::eigenCubeTest::TEST_CASE(), unitTest::improcTest::eigenCubeTest::TEST_CASE(), unitTest::improcTest::eigenCubeTest::TEST_CASE(), unitTest::improcTest::eigenCubeTest::TEST_CASE(), and unitTest::improcTest::eigenCubeTest::TEST_CASE().
| 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.
| [in] | n | the image number |
Definition at line 540 of file eigenCube.hpp.
| void mx::improc::eigenCube< dataT >::mean | ( | eigenT & | mim | ) |
Calculate the mean image of the cube.
| eigenT | an Eigen-like type. |
| [out] | mim | the 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().
| 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>().
| eigenT | an Eigen-like type. |
| eigenCubeT | an eigenCube type. |
| mx::exception | with error_t::sizeerr if the mask dimensions do not match the cube. |
| mx::exception | with error_t::invalidarg if minGoodFract is not finite or is outside [0, 1]. |
| [out] | mim | the resultant mean image. Is resized. |
| [in] | mask | a mask cube. Only pixels with value 1 are included in the mean calculation. |
| [in] | minGoodFract | inclusive 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().
| void mx::improc::eigenCube< dataT >::mean | ( | eigenT & | mim, |
| std::vector< dataT > & | weights ) |
Calculate the weighted mean image of the cube.
| eigenT | an Eigen-like type. |
| mx::exception | with error_t::sizeerr if the weight count does not match the cube planes. |
| [out] | mim | the resultant mean image. Is resized. |
| [in] | weights | a vector of weights to use for calculating the mean |
Definition at line 647 of file eigenCube.hpp.
References pixel(), validateWeights(), and mx::math::vectorMean().
| 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>().
| eigenT | an Eigen-like type. |
| eigenCubeT | an eigenCube type. |
| mx::exception | with error_t::sizeerr if the mask dimensions or weight count do not match the cube. |
| mx::exception | with error_t::invalidarg if minGoodFract is not finite or is outside [0, 1]. |
| [out] | mim | the resultant mean image. Is resized. |
| [in] | weights | a vector of weights to use for calculating the mean |
| [in] | mask | a mask cube. Only pixels with value 1 are included in the mean calculation. |
| [in] | minGoodFract | inclusive 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().
| void mx::improc::eigenCube< dataT >::median | ( | eigenT & | mim | ) |
Calculate the median image of the cube.
| eigenT | an Eigen-like type. |
| [out] | mim | the 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().
| 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>().
| eigenT | an Eigen-like type. |
| eigenCubeT | an eigenCube type. |
| mx::exception | with error_t::sizeerr if the mask dimensions do not match the cube. |
| mx::exception | with error_t::invalidarg if minGoodFract is not finite or is outside [0, 1]. |
| [out] | mim | the resultant median image. Is resized. |
| [in] | mask | a mask cube. Only pixels with value 1 are included. |
| [in] | minGoodFract | the 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().
| eigenCube< dataT > & mx::improc::eigenCube< dataT >::operator= | ( | const eigenCube< dataT > & | ec | ) |
Copy a cube into independently owned storage.
| [in] | ec | cube to copy. |
Definition at line 391 of file eigenCube.hpp.
|
noexcept |
Move a cube, transferring any owned storage.
| [in,out] | ec | cube to move from. |
Definition at line 409 of file eigenCube.hpp.
References clear().
| 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().
| 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>().
| eigenT | an Eigen-like type. |
| eigenCubeT | an eigenCube type. |
| mx::exception | with error_t::sizeerr if the mask dimensions do not match the cube. |
| mx::exception | with error_t::invalidarg if minGoodFract is not finite or is outside [0, 1]. |
| [out] | mim | the resultant mean image. Is resized. |
| [in] | mask | a mask cube. Only pixels with value 1 are included in the mean calculation. |
| [in] | sigma | the sigma value at which to clip. |
| [in] | minGoodFract | inclusive 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().
| void mx::improc::eigenCube< dataT >::sigmaMean | ( | eigenT & | mim, |
| Scalar | sigma ) |
Calculate the sigma clipped mean image of the cube.
| eigenT | an Eigen-like type. |
| [out] | mim | the resultant mean image |
| [in] | sigma | the 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().
| 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>().
| eigenT | an Eigen-like type. |
| eigenCubeT | an eigenCube type. |
| mx::exception | with error_t::sizeerr if the mask dimensions or weight count do not match the cube. |
| mx::exception | with error_t::invalidarg if minGoodFract is not finite or is outside [0, 1]. |
| [out] | mim | the resultant mean image. Is resized. |
| [in] | weights | a vector of weights to use for calculating the mean |
| [in] | mask | a mask cube. Only pixels with value 1 are included in the mean calculation. |
| [in] | sigma | the sigma value at which to clip. |
| [in] | minGoodFract | inclusive 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().
| void mx::improc::eigenCube< dataT >::sigmaMean | ( | eigenT & | mim, |
| std::vector< dataT > & | weights, | ||
| Scalar | sigma ) |
Calculate the sigma clipped weighted mean image of the cube.
| eigenT | an Eigen-like type. |
| mx::exception | with error_t::sizeerr if the weight count does not match the cube planes. |
| [out] | mim | the resultant mean image. Is resized. |
| [in] | weights | a vector of weights to use for calculating the mean |
| [in] | sigma | the sigma value at which to clip. |
Definition at line 843 of file eigenCube.hpp.
References pixel(), validateWeights(), and mx::math::vectorSigmaMean().
| void mx::improc::eigenCube< dataT >::sum | ( | eigenT & | mim | ) |
Calculate the sum image of the cube.
| eigenT | an Eigen-like type. |
| [out] | mim | the resultant sum image. Is resized. |
Definition at line 574 of file eigenCube.hpp.
References pixel().
|
protected |
Validate a mask and good-pixel threshold for a masked combination.
| [in] | mask | mask cube whose dimensions must match this cube. |
| [in] | minGoodFract | inclusive 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().
|
protected |
Validate the number of weights for a weighted combination.
| [in] | weights | weights 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().