Classes | Public Member Functions | Private Attributes | Friends | List of all members
gnsstk::FDiffFilter< T > Class Template Reference

Detailed Description

template<class T>
class gnsstk::FDiffFilter< T >

This class computes the first difference of the input data array at each point, as well as stats on both the first difference and the data for the Nwind points ending at the current point. The difference, sigmaYX of the difference statistics, and the slope from the data statistics, are stored in an "analysis vector" Avec. The Avec is used to find outliers, gaps and slips in the data; the analysis() method returns a vector of "result" objects FilterHit<T>. The caller should filter and analyze iteratively, since a single call is often not sufficient to find and fix all the problems.

Note
Flags and xdata are required and critical. Outliers must be flagged or removed between iterations, and xdata is needed for gaps and to correct slip magnitudes for the slope of the data. Probably the major weakness of this filter is it tends to find false slips after large gaps.

Definition at line 131 of file FDiffFilter.hpp.

#include <FDiffFilter.hpp>

Classes

class  Analysis
 

Public Member Functions

int analysis ()
 
void computeRobustSigmaLimit (int &N, T &new_siglim)
 
bool doSmallSlips ()
 get the 'small slips' limit More...
 
bool doSmallSlips (bool doit)
 set the 'small slips' limit More...
 
void dump (std::ostream &s, std::string tag=std::string())
 
 FDiffFilter (const std::vector< T > &x, const std::vector< T > &d, const std::vector< int > &f)
 
int filter (const size_t index=0, int npts=-1)
 
std::vector< unsigned int > getHighSigmaIndex ()
 get the indexes of high-sigma points (only if indexHighSigmas(true)) More...
 
getLimit ()
 get the limit More...
 
unsigned int getNhighSigma ()
 
std::vector< FilterHit< T > > getResults ()
 get results vector of FilterHit More...
 
getSigma ()
 get the sigma More...
 
unsigned int getWidth ()
 get the width of the window More...
 
bool indexHighSigmas (bool doit)
 set the indexing flag More...
 
bool indexingHighSigmas ()
 get the indexing flag More...
 
void setLimit (T val)
 set the limit More...
 
void setprecision (int p)
 set precision for output More...
 
void setSigma (T val)
 set the sigma More...
 
void setw (int w)
 set width for output More...
 
void setWidth (unsigned int w)
 set the width of the window More...
 

Private Attributes

std::vector< AnalysisAvec
 
const std::vector< T > & data
 reference to data to be filtered More...
 
bool doSmall
 if true, include small slips (<fdlim) in results More...
 
Esiglim
 compute siglim (= robust outlier limit) More...
 
fdlim
 |first diff| must be > this to be outlier/slip More...
 
const std::vector< int > & flags
 reference to flags, parallel to data, 0 == good More...
 
int ilimit
 largest allowed index in data[] is ilimit-1 More...
 
bool keepSigIndex
 if true, keep vector of HighSigmaIndex More...
 
madSlope
 robust stats on slope More...
 
medSlope
 
bool noflags
 true when flags array is not given More...
 
bool noxdata
 true when xdata is not given More...
 
unsigned int Nsig
 filter()'s count of high sigma - analysis needed More...
 
unsigned int Nwind
 size of sliding window More...
 
int osp
 width and precision for dump(), (default 8,3) More...
 
int osw
 
std::vector< FilterHit< T > > results
 vector of results of analysis() More...
 
std::vector< unsigned int > sigIndexes
 saved indexes of Nsig high sigma pts More...
 
siglim
 sigma > this indicates possible outlier/slip More...
 
const std::vector< T > & xdata
 reference to xdata - 'time'; if empty use count More...
 

Friends

class IterativeFDiffFilter< T >
 

Constructor & Destructor Documentation

◆ FDiffFilter()

template<class T >
gnsstk::FDiffFilter< T >::FDiffFilter ( const std::vector< T > &  x,
const std::vector< T > &  d,
const std::vector< int > &  f 
)
inline

constructor with two arrays - x is used only in dump(); x and f must exist but may be empty

Parameters
xconst vector<T> of 'times' values,
Note
(x,d,f) all parallel
Parameters
dconst vector<T> of data values
fconst vector<int> of flags, 0 means good. this array may be empty.

Definition at line 205 of file FDiffFilter.hpp.

Member Function Documentation

◆ analysis()

template<class T >
int gnsstk::FDiffFilter< T >::analysis

analyze the output of the filter(), filling the results array with outliers

Returns
the number of outliers

Definition at line 494 of file FDiffFilter.hpp.

◆ computeRobustSigmaLimit()

template<class T >
void gnsstk::FDiffFilter< T >::computeRobustSigmaLimit ( int &  N,
T &  new_siglim 
)

after filter(), and before analyze(), compute robust stats on the sigma of first differences, to get a suggested siglim

Parameters
Nint output: computed number of sigmas > new limit, -1 not enough data
new_siglimT output: computed limit (high outlier) on sigma for analyze

Definition at line 457 of file FDiffFilter.hpp.

◆ doSmallSlips() [1/2]

template<class T >
bool gnsstk::FDiffFilter< T >::doSmallSlips ( )
inline

get the 'small slips' limit

Definition at line 247 of file FDiffFilter.hpp.

◆ doSmallSlips() [2/2]

template<class T >
bool gnsstk::FDiffFilter< T >::doSmallSlips ( bool  doit)
inline

set the 'small slips' limit

Definition at line 240 of file FDiffFilter.hpp.

◆ dump()

template<class T >
void gnsstk::FDiffFilter< T >::dump ( std::ostream &  s,
std::string  tag = std::string() 
)

dump the data and analysis; optionally include a tag at the start of each line, and configure width and precision.

Definition at line 647 of file FDiffFilter.hpp.

◆ filter()

template<class T >
int gnsstk::FDiffFilter< T >::filter ( const size_t  index = 0,
int  npts = -1 
)

filter routine that computes the first difference, and uses siglim to mark areas of possible outlier/slips.

Parameters
indexin data arrays at which to start, defaults to 0
nptsnumber of data to process, defaults to -1, meaning to end of data.
Returns
> 0 number of points in the analysis vector == number good data -1 the data array is too short (< 2) -3 if the flags array is given but shorter than data array This routine clears the analysis vector.

Definition at line 317 of file FDiffFilter.hpp.

◆ getHighSigmaIndex()

template<class T >
std::vector<unsigned int> gnsstk::FDiffFilter< T >::getHighSigmaIndex ( )
inline

get the indexes of high-sigma points (only if indexHighSigmas(true))

Definition at line 273 of file FDiffFilter.hpp.

◆ getLimit()

template<class T >
T gnsstk::FDiffFilter< T >::getLimit ( )
inline

get the limit

Definition at line 231 of file FDiffFilter.hpp.

◆ getNhighSigma()

template<class T >
unsigned int gnsstk::FDiffFilter< T >::getNhighSigma ( )
inline

get the number of high-sigma points : after filter() can tell if possible outliers/slips present

Definition at line 270 of file FDiffFilter.hpp.

◆ getResults()

template<class T >
std::vector<FilterHit<T> > gnsstk::FDiffFilter< T >::getResults ( )
inline

get results vector of FilterHit

Definition at line 266 of file FDiffFilter.hpp.

◆ getSigma()

template<class T >
T gnsstk::FDiffFilter< T >::getSigma ( )
inline

get the sigma

Definition at line 237 of file FDiffFilter.hpp.

◆ getWidth()

template<class T >
unsigned int gnsstk::FDiffFilter< T >::getWidth ( )
inline

get the width of the window

Definition at line 225 of file FDiffFilter.hpp.

◆ indexHighSigmas()

template<class T >
bool gnsstk::FDiffFilter< T >::indexHighSigmas ( bool  doit)
inline

set the indexing flag

Definition at line 250 of file FDiffFilter.hpp.

◆ indexingHighSigmas()

template<class T >
bool gnsstk::FDiffFilter< T >::indexingHighSigmas ( )
inline

get the indexing flag

Definition at line 257 of file FDiffFilter.hpp.

◆ setLimit()

template<class T >
void gnsstk::FDiffFilter< T >::setLimit ( val)
inline

set the limit

Definition at line 228 of file FDiffFilter.hpp.

◆ setprecision()

template<class T >
void gnsstk::FDiffFilter< T >::setprecision ( int  p)
inline

set precision for output

Definition at line 263 of file FDiffFilter.hpp.

◆ setSigma()

template<class T >
void gnsstk::FDiffFilter< T >::setSigma ( val)
inline

set the sigma

Definition at line 234 of file FDiffFilter.hpp.

◆ setw()

template<class T >
void gnsstk::FDiffFilter< T >::setw ( int  w)
inline

set width for output

Definition at line 260 of file FDiffFilter.hpp.

◆ setWidth()

template<class T >
void gnsstk::FDiffFilter< T >::setWidth ( unsigned int  w)
inline

set the width of the window

Definition at line 222 of file FDiffFilter.hpp.

Friends And Related Function Documentation

◆ IterativeFDiffFilter< T >

template<class T >
friend class IterativeFDiffFilter< T >
friend

Definition at line 134 of file FDiffFilter.hpp.

Member Data Documentation

◆ Avec

template<class T >
std::vector<Analysis> gnsstk::FDiffFilter< T >::Avec
private

vector of Analysis objects, holding first differences and indexes, generated by filter(), used by analyze() and included in dump() output.

Definition at line 165 of file FDiffFilter.hpp.

◆ data

template<class T >
const std::vector<T>& gnsstk::FDiffFilter< T >::data
private

reference to data to be filtered

Definition at line 177 of file FDiffFilter.hpp.

◆ doSmall

template<class T >
bool gnsstk::FDiffFilter< T >::doSmall
private

if true, include small slips (<fdlim) in results

Definition at line 187 of file FDiffFilter.hpp.

◆ Esiglim

template<class T >
T gnsstk::FDiffFilter< T >::Esiglim
private

compute siglim (= robust outlier limit)

Definition at line 184 of file FDiffFilter.hpp.

◆ fdlim

template<class T >
T gnsstk::FDiffFilter< T >::fdlim
private

|first diff| must be > this to be outlier/slip

Definition at line 182 of file FDiffFilter.hpp.

◆ flags

template<class T >
const std::vector<int>& gnsstk::FDiffFilter< T >::flags
private

reference to flags, parallel to data, 0 == good

Definition at line 179 of file FDiffFilter.hpp.

◆ ilimit

template<class T >
int gnsstk::FDiffFilter< T >::ilimit
private

largest allowed index in data[] is ilimit-1

Definition at line 180 of file FDiffFilter.hpp.

◆ keepSigIndex

template<class T >
bool gnsstk::FDiffFilter< T >::keepSigIndex
private

if true, keep vector of HighSigmaIndex

Definition at line 188 of file FDiffFilter.hpp.

◆ madSlope

template<class T >
T gnsstk::FDiffFilter< T >::madSlope
private

robust stats on slope

Definition at line 192 of file FDiffFilter.hpp.

◆ medSlope

template<class T >
T gnsstk::FDiffFilter< T >::medSlope
private

Definition at line 192 of file FDiffFilter.hpp.

◆ noflags

template<class T >
bool gnsstk::FDiffFilter< T >::noflags
private

true when flags array is not given

Definition at line 173 of file FDiffFilter.hpp.

◆ noxdata

template<class T >
bool gnsstk::FDiffFilter< T >::noxdata
private

true when xdata is not given

Definition at line 172 of file FDiffFilter.hpp.

◆ Nsig

template<class T >
unsigned int gnsstk::FDiffFilter< T >::Nsig
private

filter()'s count of high sigma - analysis needed

Definition at line 186 of file FDiffFilter.hpp.

◆ Nwind

template<class T >
unsigned int gnsstk::FDiffFilter< T >::Nwind
private

size of sliding window

Definition at line 185 of file FDiffFilter.hpp.

◆ osp

template<class T >
int gnsstk::FDiffFilter< T >::osp
private

width and precision for dump(), (default 8,3)

Definition at line 171 of file FDiffFilter.hpp.

◆ osw

template<class T >
int gnsstk::FDiffFilter< T >::osw
private

Definition at line 171 of file FDiffFilter.hpp.

◆ results

template<class T >
std::vector<FilterHit<T> > gnsstk::FDiffFilter< T >::results
private

vector of results of analysis()

Definition at line 168 of file FDiffFilter.hpp.

◆ sigIndexes

template<class T >
std::vector<unsigned int> gnsstk::FDiffFilter< T >::sigIndexes
private

saved indexes of Nsig high sigma pts

Definition at line 190 of file FDiffFilter.hpp.

◆ siglim

template<class T >
T gnsstk::FDiffFilter< T >::siglim
private

sigma > this indicates possible outlier/slip

Definition at line 183 of file FDiffFilter.hpp.

◆ xdata

template<class T >
const std::vector<T>& gnsstk::FDiffFilter< T >::xdata
private

reference to xdata - 'time'; if empty use count

Definition at line 176 of file FDiffFilter.hpp.


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


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:44