casacore
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
casacore::MedianSlider Class Reference

More...

#include <MedianSlider.h>

Public Member Functions

 MedianSlider ()
 
 MedianSlider (int halfwin)
 
 MedianSlider (const MedianSlider &other)
 
 ~MedianSlider ()
 
MedianSlideroperator= (const MedianSlider &other)
 
void cleanup ()
 
Float add (Float d, Bool flag=False)
 Adds a datum to the slider. More...
 
Float add ()
 Adds a flagged datum. More...
 
Float next (uInt n=1)
 Adds N flagged datums. More...
 
Float add (const Vector< Float > &d, const Vector< Bool > &flag)
 Adds several datums at once (with corresponding flags) More...
 
Float add (const Vector< Float > &d)
 Adds several non-flagged datums at once. More...
 
Int nval ()
 Returns the number of values currently in the window. More...
 
Float median ()
 Returns the current median value
More...
 
Float prevVal (uInt n, Bool &flag)
 Returns a previous value (from n steps ago) from the sliding window. More...
 
Float midpoint (Bool &flag)
 Returns value from midpoint (center) of window, possibly with flag. More...
 
Float midpoint ()
 
Float diff (Bool &flag)
 Returns the difference between the current median and the value at window center. More...
 
Float diff ()
 
Bool assure ()
 For testing purposes only: verifies current value of median. More...
 

Static Public Member Functions

static size_t objsize (int halfwin)
 returns total memory usage (in bytes) for a given halfwin size
More...
 

Private Attributes

uInt halfwin
 
uInt fullwin
 
Floatbuf
 
uIntindex
 
Boolvalid
 
uInt ibuf
 
uInt nind
 

Detailed Description

Class to compute sliding median

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

Synopsis

MedianSlider is a class for efficient computing of sliding medians.

Example

Motivation

Flagging Agents make extended use of sliding medians.

To Do

Definition at line 64 of file MedianSlider.h.

Constructor & Destructor Documentation

◆ MedianSlider() [1/3]

casacore::MedianSlider::MedianSlider ( )

Referenced by objsize().

◆ MedianSlider() [2/3]

casacore::MedianSlider::MedianSlider ( int  halfwin)

◆ MedianSlider() [3/3]

casacore::MedianSlider::MedianSlider ( const MedianSlider other)

◆ ~MedianSlider()

casacore::MedianSlider::~MedianSlider ( )

Member Function Documentation

◆ add() [1/4]

Float casacore::MedianSlider::add ( )
inline

Adds a flagged datum.

Definition at line 82 of file MedianSlider.h.

References add(), and casacore::True.

Referenced by add().

◆ add() [2/4]

Float casacore::MedianSlider::add ( const Vector< Float > &  d)

Adds several non-flagged datums at once.

◆ add() [3/4]

Float casacore::MedianSlider::add ( const Vector< Float > &  d,
const Vector< Bool > &  flag 
)

Adds several datums at once (with corresponding flags)

◆ add() [4/4]

Float casacore::MedianSlider::add ( Float  d,
Bool  flag = False 
)

Adds a datum to the slider.

Once the window is full, newer values will push out older values. Returns the new median value. If flag is set to true, adds a "flagged" datum, one which takes up space in the window but is skipped during median computations.

◆ assure()

Bool casacore::MedianSlider::assure ( )

For testing purposes only: verifies current value of median.

Throws an exception if it fails.

◆ cleanup()

void casacore::MedianSlider::cleanup ( )

◆ diff() [1/2]

Float casacore::MedianSlider::diff ( )
inline

Definition at line 111 of file MedianSlider.h.

◆ diff() [2/2]

Float casacore::MedianSlider::diff ( Bool flag)
inline

Returns the difference between the current median and the value at window center.

Optionally, also returns flag of median center

Definition at line 110 of file MedianSlider.h.

References median(), and midpoint().

◆ median()

Float casacore::MedianSlider::median ( )
inline

Returns the current median value

return nind%2 ? buf[ index[nind/2] ] : buf[ index[nind/2-1] ];

Definition at line 138 of file MedianSlider.h.

References buf, index, and nind.

Referenced by diff().

◆ midpoint() [1/2]

Float casacore::MedianSlider::midpoint ( )
inline

Definition at line 105 of file MedianSlider.h.

Referenced by diff().

◆ midpoint() [2/2]

Float casacore::MedianSlider::midpoint ( Bool flag)
inline

Returns value from midpoint (center) of window, possibly with flag.

Definition at line 148 of file MedianSlider.h.

References halfwin, and prevVal().

◆ next()

Float casacore::MedianSlider::next ( uInt  n = 1)

Adds N flagged datums.

◆ nval()

Int casacore::MedianSlider::nval ( )
inline

Returns the number of values currently in the window.

This is less than the window width initially. Int size ();

Returns the number of non-flagged values in window

Definition at line 133 of file MedianSlider.h.

References nind.

◆ objsize()

static size_t casacore::MedianSlider::objsize ( int  halfwin)
inlinestatic

returns total memory usage (in bytes) for a given halfwin size

Definition at line 115 of file MedianSlider.h.

References halfwin, and MedianSlider().

◆ operator=()

MedianSlider& casacore::MedianSlider::operator= ( const MedianSlider other)

◆ prevVal()

Float casacore::MedianSlider::prevVal ( uInt  n,
Bool flag 
)

Returns a previous value (from n steps ago) from the sliding window.

Referenced by midpoint().

Member Data Documentation

◆ buf

Float* casacore::MedianSlider::buf
private

Definition at line 125 of file MedianSlider.h.

Referenced by median().

◆ fullwin

uInt casacore::MedianSlider::fullwin
private

Definition at line 124 of file MedianSlider.h.

◆ halfwin

uInt casacore::MedianSlider::halfwin
private

Definition at line 124 of file MedianSlider.h.

Referenced by midpoint(), and objsize().

◆ ibuf

uInt casacore::MedianSlider::ibuf
private

Definition at line 128 of file MedianSlider.h.

◆ index

uInt* casacore::MedianSlider::index
private

Definition at line 126 of file MedianSlider.h.

Referenced by median().

◆ nind

uInt casacore::MedianSlider::nind
private

Definition at line 128 of file MedianSlider.h.

Referenced by median(), and nval().

◆ valid

Bool* casacore::MedianSlider::valid
private

Definition at line 127 of file MedianSlider.h.


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