template<class T>
class casacore::LatticeFractile< T >
Static functions to get median and fractiles of a lattice.
Intended use:
Internal
Review Status
- Date Reviewed:
- yyyy/mm/dd
- Test programs:
- tLatticeFractile tLELMedian
Prerequisite
Synopsis
This class contains a few static functions to find 1 or 2 fractiles in a lattice. They are primarily used by the LEL classes, but can also be used standalone.
A fractile is the same as a percentile be it that it is given as a fraction instead of a percentage. A fraction of 0.5 yields the median.
When the lattice has a mask, only the masked-on elements are taken into account. If all elements are masked_off, an empty Vector is returned indicating that no fractiles were found.
The algorithm used depends on the size of the lattice. Smallish lattices (i.e. not exceeding the argument smallSize) are handled in one pass im memory. For bigger lattices a multi-pass algorithm is used. First the lattices is binned. Thereafter the algorithm continues with the elements of the bins containing the fractiles. This continues until the number of elements left is less than smallSize
. Typically only 2 passes are needed for a big image.
The algorithm is robust and takes possible rounding errors into account. It also takes into account that the lattice can contain many equal values.
Motivation
Separated from file LELFunction.h to make it more commonly usable and to make the source files more readable.
Definition at line 91 of file LatticeFractile.h.
Determine the fractile of the given lattice.
It returns the value of the lattice at the given fraction. A fraction of 0.5 returns the median. If the lattice has an even number of elements and if the lattice is small enough (< 100 elements), the median is the mean of the 2 middle elements.
If the lattice is masked, only masked-on elements are taken into account.
If the lattice is large, successive histograms are made until smallSize
elements are left. Thereafter an in-memory algorithm will be used to finish. The number of passes made over the data is undetermined, but a typical number is 2 passes.
Normally a vector with 1 element is returned. If the lattice has no masked-on elements, an empty vector is returned.
Determine the values of the 2 elements at the given fractiles.
Thus left=0.25; right=0.75
gives the quartiles of the lattice.
If the lattice is masked, onlu masked-on elements are taken into account.
If the lattice is large, successive histograms are made until smallSize
elements are left. Thereafter an in-memory algorithm will be used to finish. The number of passes made over the data is undetermined, but a typical number is 2 passes.
Normally a vector with 2 elements is returned. If the lattice has no masked-on elements, an empty vector is returned.