casacore
|
Mathematical and logical operations for Array parts. More...
#include <ArrayPartMath.h>
Classes | |
class | AvdevFunc |
class | FractileFunc |
class | InterFractileRangeFunc |
class | InterHexileRangeFunc |
class | InterQuartileRangeFunc |
class | MadfmFunc |
class | MaxFunc |
class | MeanFunc |
class | MedianFunc |
class | MinFunc |
class | ProductFunc |
class | RmsFunc |
class | StddevFunc |
class | SumFunc |
Define functors to perform a reduction function on an Array object. More... | |
class | SumSqrFunc |
class | VarianceFunc |
Public Member Functions | |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialSums (const Array< T, Alloc > &array, const IPosition &collapseAxes) |
Determine the sum, product, etc. More... | |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialSumSqrs (const Array< T, Alloc > &array, const IPosition &collapseAxes) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialProducts (const Array< T, Alloc > &array, const IPosition &collapseAxes) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialMins (const Array< T, Alloc > &array, const IPosition &collapseAxes) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialMaxs (const Array< T, Alloc > &array, const IPosition &collapseAxes) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialMeans (const Array< T, Alloc > &array, const IPosition &collapseAxes) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialVariances (const Array< T, Alloc > &array, const IPosition &collapseAxes, size_t ddof=1) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialVariances (const Array< T, Alloc > &array, const IPosition &collapseAxes, const Array< T, Alloc > &means) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialVariances (const Array< T, Alloc > &array, const IPosition &collapseAxes, const Array< T, Alloc > &means, size_t ddof) |
template<typename T , typename Alloc > | |
Array< std::complex< T > > | partialVariances (const Array< std::complex< T >> &array, const IPosition &collapseAxes, const Array< std::complex< T >> &means, size_t ddof) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialStddevs (const Array< T, Alloc > &array, const IPosition &collapseAxes, size_t ddof=1) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialStddevs (const Array< T, Alloc > &array, const IPosition &collapseAxes, const Array< T, Alloc > &means, size_t ddof=1) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialAvdevs (const Array< T, Alloc > &array, const IPosition &collapseAxes) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialAvdevs (const Array< T, Alloc > &array, const IPosition &collapseAxes, const Array< T, Alloc > &means) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialRmss (const Array< T, Alloc > &array, const IPosition &collapseAxes) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialMedians (const Array< T, Alloc > &array, const IPosition &collapseAxes, bool takeEvenMean=false, bool inPlace=false) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialMadfms (const Array< T, Alloc > &array, const IPosition &collapseAxes, bool takeEvenMean=false, bool inPlace=false) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialFractiles (const Array< T, Alloc > &array, const IPosition &collapseAxes, float fraction, bool inPlace=false) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialInterFractileRanges (const Array< T, Alloc > &array, const IPosition &collapseAxes, float fraction, bool inPlace=false) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialInterHexileRanges (const Array< T, Alloc > &array, const IPosition &collapseAxes, bool inPlace=false) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | partialInterQuartileRanges (const Array< T, Alloc > &array, const IPosition &collapseAxes, bool inPlace=false) |
template<typename T , typename Alloc = std::allocator<T>> | |
Array< T, Alloc > | partialArrayMath (const Array< T, Alloc > &a, const IPosition &collapseAxes, const ArrayFunctorBase< T > &funcObj) |
Do partial reduction of an Array object. More... | |
template<typename T , typename Alloc , typename RES , typename RESAlloc > | |
void | partialArrayMath (Array< RES, RESAlloc > &res, const Array< T, Alloc > &a, const IPosition &collapseAxes, const ArrayFunctorBase< T, RES > &funcObj) |
template<typename T , typename Alloc > | |
Array< T, Alloc > | boxedArrayMath (const Array< T, Alloc > &a, const IPosition &boxSize, const ArrayFunctorBase< T > &funcObj) |
Apply the given ArrayMath reduction function objects to each box in the array. More... | |
template<typename T , typename Alloc , typename RES , typename RESAlloc > | |
void | boxedArrayMath (Array< RES, RESAlloc > &, const Array< T, Alloc > &array, const IPosition &boxSize, const ArrayFunctorBase< T, RES > &funcObj) |
template<typename T , typename Alloc = std::allocator<T>> | |
Array< T, Alloc > | slidingArrayMath (const Array< T, Alloc > &a, const IPosition &halfBoxSize, const ArrayFunctorBase< T > &funcObj, bool fillEdge=true) |
Apply for each element in the array the given ArrayMath reduction function object to the box around that element. More... | |
template<typename T , typename Alloc , typename RES , typename RESAlloc > | |
void | slidingArrayMath (Array< RES, RESAlloc > &res, const Array< T, Alloc > &array, const IPosition &halfBoxSize, const ArrayFunctorBase< T, RES > &funcObj, bool fillEdge=true) |
Mathematical and logical operations for Array parts.
This file contains global functions which perform part by part mathematical or logical operations on arrays.
These functions perform chunk by chunk mathematical operations on arrays. In particular boxed and sliding operations are possible. E.g. to calculate the median in sliding windows making it possible to subtract the background in an image.
The operations to be performed are defined by means of functors that reduce an array subset to a scalar. Those functors are wrappers for ArrayMath and ArrayLogical functions like sum, median, and ntrue.
The partialXX
functions are a special case of the BoxedArrayMath
function. They reduce one or more entire axes which can be done in a faster way than the more general boxedArrayMath
function.
This example calculates the mean of each plane in the data array.
does the same as the first example. Note that in this example the box is formed by the entire axes, but it could also be a subset of it to average, say, boxes of 5*5 elements.
Definition at line 94 of file ArrayPartMath.h.
|
inline |
Apply the given ArrayMath reduction function objects to each box in the array.
Downsample an array by taking the median of every [25,25] elements.
The dimensionality of the array can be larger than the box; in that case the missing axes of the box are assumed to have length 1. A box axis length <= 0 means the full array axis.
Definition at line 354 of file ArrayPartMath.h.
References casacore::boxedArrayMath().
void casacore::ArrayPartMath_global_functions_Array_partial_operations::boxedArrayMath | ( | Array< RES, RESAlloc > & | , |
const Array< T, Alloc > & | array, | ||
const IPosition & | boxSize, | ||
const ArrayFunctorBase< T, RES > & | funcObj | ||
) |
|
inline |
Do partial reduction of an Array object.
I.e., perform the operation on a subset of the array axes (the collapse axes).
Definition at line 326 of file ArrayPartMath.h.
void casacore::ArrayPartMath_global_functions_Array_partial_operations::partialArrayMath | ( | Array< RES, RESAlloc > & | res, |
const Array< T, Alloc > & | a, | ||
const IPosition & | collapseAxes, | ||
const ArrayFunctorBase< T, RES > & | funcObj | ||
) |
|
inline |
Definition at line 149 of file ArrayPartMath.h.
Array<T, Alloc> casacore::ArrayPartMath_global_functions_Array_partial_operations::partialAvdevs | ( | const Array< T, Alloc > & | array, |
const IPosition & | collapseAxes, | ||
const Array< T, Alloc > & | means | ||
) |
Array<T, Alloc> casacore::ArrayPartMath_global_functions_Array_partial_operations::partialFractiles | ( | const Array< T, Alloc > & | array, |
const IPosition & | collapseAxes, | ||
float | fraction, | ||
bool | inPlace = false |
||
) |
Array<T, Alloc> casacore::ArrayPartMath_global_functions_Array_partial_operations::partialInterFractileRanges | ( | const Array< T, Alloc > & | array, |
const IPosition & | collapseAxes, | ||
float | fraction, | ||
bool | inPlace = false |
||
) |
|
inline |
Definition at line 176 of file ArrayPartMath.h.
|
inline |
Definition at line 180 of file ArrayPartMath.h.
Array<T, Alloc> casacore::ArrayPartMath_global_functions_Array_partial_operations::partialMadfms | ( | const Array< T, Alloc > & | array, |
const IPosition & | collapseAxes, | ||
bool | takeEvenMean = false , |
||
bool | inPlace = false |
||
) |
Array<T, Alloc> casacore::ArrayPartMath_global_functions_Array_partial_operations::partialMaxs | ( | const Array< T, Alloc > & | array, |
const IPosition & | collapseAxes | ||
) |
Array<T, Alloc> casacore::ArrayPartMath_global_functions_Array_partial_operations::partialMeans | ( | const Array< T, Alloc > & | array, |
const IPosition & | collapseAxes | ||
) |
Array<T, Alloc> casacore::ArrayPartMath_global_functions_Array_partial_operations::partialMedians | ( | const Array< T, Alloc > & | array, |
const IPosition & | collapseAxes, | ||
bool | takeEvenMean = false , |
||
bool | inPlace = false |
||
) |
Array<T, Alloc> casacore::ArrayPartMath_global_functions_Array_partial_operations::partialMins | ( | const Array< T, Alloc > & | array, |
const IPosition & | collapseAxes | ||
) |
Array<T, Alloc> casacore::ArrayPartMath_global_functions_Array_partial_operations::partialProducts | ( | const Array< T, Alloc > & | array, |
const IPosition & | collapseAxes | ||
) |
Array<T, Alloc> casacore::ArrayPartMath_global_functions_Array_partial_operations::partialRmss | ( | const Array< T, Alloc > & | array, |
const IPosition & | collapseAxes | ||
) |
|
inline |
Definition at line 135 of file ArrayPartMath.h.
References casacore::sqrt().
|
inline |
Definition at line 142 of file ArrayPartMath.h.
References casacore::sqrt().
Array<T, Alloc> casacore::ArrayPartMath_global_functions_Array_partial_operations::partialSums | ( | const Array< T, Alloc > & | array, |
const IPosition & | collapseAxes | ||
) |
Determine the sum, product, etc.
for the given axes only. The result is an array with a shape formed by the remaining axes. For example, for an array with shape [3,4,5], collapsing axis 0 results in an array with shape [4,5] containing, say, the sum for each X line. Summing for axes 0 and 2 results in an array with shape [4] containing, say, the sum for each XZ plane.
Note: ArrayLogical;h contains the functions ntrue, nfalse, partialNTrue and partialNFalse to count the number of true or false elements in an array;
Array<T, Alloc> casacore::ArrayPartMath_global_functions_Array_partial_operations::partialSumSqrs | ( | const Array< T, Alloc > & | array, |
const IPosition & | collapseAxes | ||
) |
|
inline |
Definition at line 121 of file ArrayPartMath.h.
Array<T, Alloc> casacore::ArrayPartMath_global_functions_Array_partial_operations::partialVariances | ( | const Array< T, Alloc > & | array, |
const IPosition & | collapseAxes, | ||
const Array< T, Alloc > & | means | ||
) |
Array<T, Alloc> casacore::ArrayPartMath_global_functions_Array_partial_operations::partialVariances | ( | const Array< T, Alloc > & | array, |
const IPosition & | collapseAxes, | ||
const Array< T, Alloc > & | means, | ||
size_t | ddof | ||
) |
Array<std::complex<T> > casacore::ArrayPartMath_global_functions_Array_partial_operations::partialVariances | ( | const Array< std::complex< T >> & | array, |
const IPosition & | collapseAxes, | ||
const Array< std::complex< T >> & | means, | ||
size_t | ddof | ||
) |
|
inline |
Apply for each element in the array the given ArrayMath reduction function object to the box around that element.
The full box is 2*halfBoxSize + 1. It can be used for arrays and boxes of any dimensionality; missing halfBoxSize values are set to 0.
Determine for each element in the array the median of a box with size [51,51] around that element:
This is a potentially expensive operation. On a high-end PC it took appr. 27 seconds to get the medians for an array of [1000,1000] using a halfBoxSize of [50,50].
The fillEdge argument determines how the edge is filled where no full boxes can be made. true means it is set to zero; false means that the edge is removed, thus the output array is smaller than the input array.
Note: This brute-force method of determining the medians outperforms all kinds of smart implementations; For a vector it is about as fast as casacore class MedianSlider, for a 2D array it is much, much faster;
Definition at line 393 of file ArrayPartMath.h.
References casacore::slidingArrayMath().
void casacore::ArrayPartMath_global_functions_Array_partial_operations::slidingArrayMath | ( | Array< RES, RESAlloc > & | res, |
const Array< T, Alloc > & | array, | ||
const IPosition & | halfBoxSize, | ||
const ArrayFunctorBase< T, RES > & | funcObj, | ||
bool | fillEdge = true |
||
) |