nidas v1.2.3
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
nidas::dynld::StatisticsCruncher Class Reference

#include <StatisticsCruncher.h>

Inheritance diagram for nidas::dynld::StatisticsCruncher:
Inheritance graph
[legend]

Classes

struct  sampleInfo
 

Public Types

enum  statsEnumType {
  STATS_UNKNOWN , STATS_MINIMUM , STATS_MAXIMUM , STATS_MEAN ,
  STATS_VAR , STATS_COV , STATS_FLUX , STATS_RFLUX ,
  STATS_SFLUX , STATS_TRIVAR , STATS_PRUNEDTRIVAR , STATS_WINDDIR ,
  STATS_SUM
}
 Types of statistics I can generate. More...
 
typedef enum nidas::dynld::StatisticsCruncher::statsEnumType statisticsType
 Types of statistics I can generate.
 

Public Member Functions

 StatisticsCruncher (StatisticsProcessor *proc, const SampleTag *stag, statisticsType type, std::string countsName, bool higherMoments)
 Constructor.
 
 ~StatisticsCruncher ()
 
SampleSourcegetRawSampleSource ()
 Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
 
SampleSourcegetProcessedSampleSource ()
 Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
 
std::list< const SampleTag * > getSampleTags () const
 Get the output SampleTags.
 
SampleTagIterator getSampleTagIterator () const
 Implementation of SampleSource::getSampleTagIterator().
 
void addSampleClient (SampleClient *client) throw ()
 Implementation of SampleSource::addSampleClient().
 
void removeSampleClient (SampleClient *client) throw ()
 Remove a SampleClient from this SampleSource.
 
void addSampleClientForTag (SampleClient *client, const SampleTag *) throw ()
 Add a Client for a given SampleTag.
 
void removeSampleClientForTag (SampleClient *client, const SampleTag *) throw ()
 Remove a SampleClient for a given SampleTag from this SampleSource.
 
int getClientCount () const throw ()
 How many SampleClients are currently in my list.
 
void flush () throw ()
 Implementation of Resampler::flush().
 
const SampleStatsgetSampleStats () const
 
bool receive (const Sample *s) throw ()
 Method called to pass a sample to this client.
 
void connect (SampleSource *source)
 Connect a SamplePipeline to the cruncher.
 
void disconnect (SampleSource *source) throw ()
 
void connect (SampleOutput *output)
 Connect a SamplePipeline to the cruncher.
 
void disconnect (SampleOutput *output)
 
void setStartTime (const nidas::util::UTime &val)
 
nidas::util::UTime getStartTime () const
 
void setEndTime (const nidas::util::UTime &val)
 
nidas::util::UTime getEndTime () const
 
long long getPeriodUsecs () const
 
bool getFillGaps () const
 Whether to generate output samples over time gaps.
 
void setFillGaps (bool val)
 

Static Public Member Functions

static statisticsType getStatisticsType (const std::string &type)
 
static const std::string & getStatisticsString (statisticsType stype)
 Return string name for the given stype.
 

Protected Member Functions

void attach (SampleSource *source)
 
void splitNames ()
 Split input variable names at periods.
 
std::string makeName (int i, int j=-1, int k=-1, int l=-1)
 Create a derived variable name from input variables i,j,k,l.
 
std::string makeUnits (int i, int j=-1, int k=-1, int l=-1)
 Create a derived units field from input variables i,j,k,l.
 
std::string makeUnits (const std::vector< std::string > &)
 
void createCombinations ()
 
void setupMoments (unsigned int nvars, unsigned int moment)
 
void setupMinMax (const std::string &)
 
void setupWindDir ()
 
void setupCovariances ()
 
void setupTrivariances ()
 
void setupPrunedTrivariances ()
 
void setupFluxes ()
 
void setupReducedFluxes ()
 
void setupReducedScalarFluxes ()
 
void initStats ()
 
void zeroStats ()
 
void computeStats ()
 
void addVariable (const std::string &name, const std::string &longname, const std::string &units)
 

Private Member Functions

void addSampleTag (const SampleTag *tag) throw ()
 Add a SampleTag to this SampleSource.
 
void removeSampleTag (const SampleTag *tag) throw ()
 
 StatisticsCruncher (const StatisticsCruncher &)
 No copy.
 
StatisticsCruncheroperator= (const StatisticsCruncher &)
 No assignment.
 

Private Attributes

StatisticsProcessor_proc
 
SampleSourceSupport _source
 
SampleTag _reqTag
 
std::vector< const Variable * > _reqVariables
 
unsigned int _ninvars
 Number of input variables.
 
std::string _countsName
 Name of counts variable.
 
bool _numpoints
 Does the user want number-of-points output?
 
dsm_time_t _periodUsecs
 
bool _crossTerms
 Does this cruncher compute cross-terms?
 
NearestResampler_resampler
 
statisticsType _statsType
 Types of statistics I can generate.
 
std::vector< std::vector< std::string > > _splitVarNames
 Input variable names, split at dots.
 
std::string _leadCommon
 Portion after the first dot-separated word that is common to all variable names.
 
std::string _commonSuffix
 Trailing portion that is common to all variable names.
 
SampleTag _outSample
 
unsigned int _nOutVar
 
unsigned int _outlen
 
dsm_time_t _tout
 
std::map< dsm_sample_id_t, sampleInfo_sampleMap
 
float_xMin
 
float_xMax
 
double_xSum
 
double ** _xySum
 
double_xyzSum
 
double_x4Sum
 
unsigned int_nSamples
 
unsigned int ** _triComb
 
unsigned int _nsum
 Number of simple sums to maintain.
 
unsigned int _ncov
 Number of covariances to compute.
 
unsigned int _ntri
 Number of trivariances to compute.
 
unsigned int _n1mom
 Number of 1st,2nd,3rd,4th moments to compute.
 
unsigned int _n2mom
 
unsigned int _n3mom
 
unsigned int _n4mom
 
unsigned int _ntot
 Total number of products to compute.
 
bool _higherMoments
 
const Site_site
 
int _station
 
nidas::util::UTime _startTime
 
nidas::util::UTime _endTime
 
bool _fillGaps
 

Member Typedef Documentation

◆ statisticsType

Types of statistics I can generate.

Member Enumeration Documentation

◆ statsEnumType

Types of statistics I can generate.

Enumerator
STATS_UNKNOWN 
STATS_MINIMUM 
STATS_MAXIMUM 
STATS_MEAN 
STATS_VAR 
STATS_COV 
STATS_FLUX 
STATS_RFLUX 
STATS_SFLUX 
STATS_TRIVAR 
STATS_PRUNEDTRIVAR 
STATS_WINDDIR 
STATS_SUM 

Constructor & Destructor Documentation

◆ StatisticsCruncher() [1/2]

StatisticsCruncher::StatisticsCruncher ( StatisticsProcessor * proc,
const SampleTag * stag,
statisticsType type,
std::string countsName,
bool higherMoments )

◆ ~StatisticsCruncher()

StatisticsCruncher::~StatisticsCruncher ( )

◆ StatisticsCruncher() [2/2]

nidas::dynld::StatisticsCruncher::StatisticsCruncher ( const StatisticsCruncher & )
private

No copy.


Member Function Documentation

◆ addSampleClient()

void nidas::dynld::StatisticsCruncher::addSampleClient ( SampleClient * client)
throw ( )
inlinevirtual

◆ addSampleClientForTag()

void nidas::dynld::StatisticsCruncher::addSampleClientForTag ( SampleClient * client,
const SampleTag *  )
throw ( )
inlinevirtual

Add a Client for a given SampleTag.

Implementation of SampleSource::addSampleClient().

Implements nidas::core::SampleSource.

References _source, and nidas::core::SampleSourceSupport::addSampleClient().

◆ addSampleTag()

void nidas::dynld::StatisticsCruncher::addSampleTag ( const SampleTag * tag)
throw ( )
inlineprivatevirtual

Add a SampleTag to this SampleSource.

This SampleSource does not own the SampleTag.

Implements nidas::core::SampleSource.

References _source, and nidas::core::SampleSourceSupport::addSampleTag().

Referenced by StatisticsCruncher().

◆ addVariable()

void StatisticsCruncher::addVariable ( const std::string & name,
const std::string & longname,
const std::string & units )
protected

◆ attach()

void StatisticsCruncher::attach ( SampleSource * source)
protected

◆ computeStats()

void StatisticsCruncher::computeStats ( )
protected

◆ connect() [1/2]

void nidas::dynld::StatisticsCruncher::connect ( SampleOutput * output)

Connect a SamplePipeline to the cruncher.

◆ connect() [2/2]

void StatisticsCruncher::connect ( SampleSource * source)
virtual

◆ createCombinations()

void StatisticsCruncher::createCombinations ( )
protected

◆ disconnect() [1/2]

void nidas::dynld::StatisticsCruncher::disconnect ( SampleOutput * output)

◆ disconnect() [2/2]

void StatisticsCruncher::disconnect ( SampleSource * source)
throw ( )
virtual

◆ flush()

void StatisticsCruncher::flush ( )
throw ( )
virtual

Implementation of Resampler::flush().

Implements nidas::core::Resampler.

References _ninvars, _nSamples, _periodUsecs, _tout, and computeStats().

◆ getClientCount()

int nidas::dynld::StatisticsCruncher::getClientCount ( ) const
throw ( )
inlinevirtual

How many SampleClients are currently in my list.

Exceptions

)

Implements nidas::core::SampleSource.

References _source, and nidas::core::SampleSourceSupport::getClientCount().

◆ getEndTime()

nidas::util::UTime nidas::dynld::StatisticsCruncher::getEndTime ( ) const
inline

References _endTime.

◆ getFillGaps()

bool nidas::dynld::StatisticsCruncher::getFillGaps ( ) const
inline

Whether to generate output samples over time gaps.

In some circumstances one might be generating statistics for separate time periods, and one does not want to output samples of missing data for the gaps between the periods.

References _fillGaps.

◆ getPeriodUsecs()

long long nidas::dynld::StatisticsCruncher::getPeriodUsecs ( ) const
inline

References _periodUsecs.

◆ getProcessedSampleSource()

SampleSource * nidas::dynld::StatisticsCruncher::getProcessedSampleSource ( )
inlinevirtual

Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.

SampleClients use this method to get a pointer to whatever sample source they are interested in. Derived classes can return NULL if they are not a SampleSource of processed samples.

Implements nidas::core::SampleSource.

References _source.

◆ getRawSampleSource()

SampleSource * nidas::dynld::StatisticsCruncher::getRawSampleSource ( )
inlinevirtual

Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.

SampleClients use this method to get a pointer to whatever sample source they are interested in. Derived classes can return NULL if they are not a SampleSource of raw samples.

Implements nidas::core::SampleSource.

◆ getSampleStats()

const SampleStats & nidas::dynld::StatisticsCruncher::getSampleStats ( ) const
inlinevirtual

◆ getSampleTagIterator()

SampleTagIterator nidas::dynld::StatisticsCruncher::getSampleTagIterator ( ) const
inlinevirtual

◆ getSampleTags()

std::list< const SampleTag * > nidas::dynld::StatisticsCruncher::getSampleTags ( ) const
inlinevirtual

Get the output SampleTags.

Implements nidas::core::SampleSource.

References _source, and nidas::core::SampleSourceSupport::getSampleTags().

◆ getStartTime()

nidas::util::UTime nidas::dynld::StatisticsCruncher::getStartTime ( ) const
inline

References _startTime.

◆ getStatisticsString()

const std::string & StatisticsCruncher::getStatisticsString ( statisticsType stype)
static

Return string name for the given stype.

If stype does not match a known name, return "none".

References nidas::core::getSample(), and StatsStrings.

Referenced by nidas::dynld::StatisticsProcessor::addRequestedSampleTag().

◆ getStatisticsType()

StatisticsCruncher::statisticsType StatisticsCruncher::getStatisticsType ( const std::string & type)
static

◆ initStats()

void StatisticsCruncher::initStats ( )
protected

◆ makeName()

string StatisticsCruncher::makeName ( int i,
int j = -1,
int k = -1,
int l = -1 )
protected

Create a derived variable name from input variables i,j,k,l.

Specify j,k,l for 2nd,3rd,4th order products.

References _commonSuffix, _leadCommon, _splitVarNames, and nidas::core::getSample().

Referenced by setupCovariances(), setupFluxes(), setupMoments(), setupPrunedTrivariances(), setupReducedFluxes(), setupReducedScalarFluxes(), and setupTrivariances().

◆ makeUnits() [1/2]

std::string StatisticsCruncher::makeUnits ( const std::vector< std::string > & units)
protected

◆ makeUnits() [2/2]

string StatisticsCruncher::makeUnits ( int i,
int j = -1,
int k = -1,
int l = -1 )
protected

Create a derived units field from input variables i,j,k,l.

Specify j,k,l for 2nd,3rd,4th order products.

References _reqVariables, nidas::core::getSample(), and makeUnits().

Referenced by makeUnits(), setupCovariances(), setupFluxes(), setupMinMax(), setupMoments(), setupPrunedTrivariances(), setupReducedFluxes(), setupReducedScalarFluxes(), and setupTrivariances().

◆ operator=()

StatisticsCruncher & nidas::dynld::StatisticsCruncher::operator= ( const StatisticsCruncher & )
private

No assignment.


◆ receive()

bool StatisticsCruncher::receive ( const Sample * s)
throw ( )
virtual

Method called to pass a sample to this client.

This method is typically called by a SampleSource for each of its SampleClients when it has a sample ready. Returns true: success false: sample rejected. This is meant to signal a warning-type situation - like a socket not being available temporarily. True errors will be thrown as an IOException.

Exceptions

)

Implements nidas::core::SampleClient.

References nidas::core::DOUBLE_ST, nidas::core::FLOAT_ST, nidas::util::LogMessage::format(), nidas::core::Sample::getDataValue(), nidas::core::getSample(), LOG_VERBOSE, nidas::dynld::StatisticsCruncher::sampleInfo::varIndices, and WLOG.

◆ removeSampleClient()

void nidas::dynld::StatisticsCruncher::removeSampleClient ( SampleClient * c)
throw ( )
inlinevirtual

Remove a SampleClient from this SampleSource.

Exceptions

)

Implements nidas::core::SampleSource.

References _source, and nidas::core::SampleSourceSupport::removeSampleClient().

◆ removeSampleClientForTag()

void nidas::dynld::StatisticsCruncher::removeSampleClientForTag ( SampleClient * c,
const SampleTag *  )
throw ( )
inlinevirtual

Remove a SampleClient for a given SampleTag from this SampleSource.

The pointer to the SampleClient must remain valid, until after it is removed.

Exceptions

)

Implements nidas::core::SampleSource.

References _source, and nidas::core::SampleSourceSupport::removeSampleClient().

◆ removeSampleTag()

void nidas::dynld::StatisticsCruncher::removeSampleTag ( const SampleTag * )
throw ( )
inlineprivatevirtual

◆ setEndTime()

void nidas::dynld::StatisticsCruncher::setEndTime ( const nidas::util::UTime & val)
inline

◆ setFillGaps()

void nidas::dynld::StatisticsCruncher::setFillGaps ( bool val)
inline

◆ setStartTime()

void StatisticsCruncher::setStartTime ( const nidas::util::UTime & val)

◆ setupCovariances()

void StatisticsCruncher::setupCovariances ( )
protected

◆ setupFluxes()

void StatisticsCruncher::setupFluxes ( )
protected

◆ setupMinMax()

void StatisticsCruncher::setupMinMax ( const std::string & )
protected

◆ setupMoments()

void StatisticsCruncher::setupMoments ( unsigned int nvars,
unsigned int moment )
protected

◆ setupPrunedTrivariances()

void StatisticsCruncher::setupPrunedTrivariances ( )
protected

◆ setupReducedFluxes()

void StatisticsCruncher::setupReducedFluxes ( )
protected

◆ setupReducedScalarFluxes()

void StatisticsCruncher::setupReducedScalarFluxes ( )
protected

◆ setupTrivariances()

void StatisticsCruncher::setupTrivariances ( )
protected

◆ setupWindDir()

void StatisticsCruncher::setupWindDir ( )
protected

◆ splitNames()

void StatisticsCruncher::splitNames ( )
protected

Split input variable names at periods.

References _commonSuffix, _leadCommon, _reqVariables, _splitVarNames, and nidas::core::getSample().

Referenced by createCombinations().

◆ zeroStats()

void StatisticsCruncher::zeroStats ( )
protected

Member Data Documentation

◆ _commonSuffix

std::string nidas::dynld::StatisticsCruncher::_commonSuffix
private

Trailing portion that is common to all variable names.

Referenced by initStats(), makeName(), setupMinMax(), setupWindDir(), and splitNames().

◆ _countsName

std::string nidas::dynld::StatisticsCruncher::_countsName
private

Name of counts variable.

Referenced by initStats().

◆ _crossTerms

bool nidas::dynld::StatisticsCruncher::_crossTerms
private

Does this cruncher compute cross-terms?

Referenced by attach(), connect(), and StatisticsCruncher().

◆ _endTime

nidas::util::UTime nidas::dynld::StatisticsCruncher::_endTime
private

Referenced by getEndTime(), and setEndTime().

◆ _fillGaps

bool nidas::dynld::StatisticsCruncher::_fillGaps
private

Referenced by getFillGaps(), and setFillGaps().

◆ _higherMoments

bool nidas::dynld::StatisticsCruncher::_higherMoments
private

Referenced by computeStats(), and createCombinations().

◆ _leadCommon

std::string nidas::dynld::StatisticsCruncher::_leadCommon
private

Portion after the first dot-separated word that is common to all variable names.

Referenced by initStats(), makeName(), setupMinMax(), setupWindDir(), and splitNames().

◆ _n1mom

unsigned int nidas::dynld::StatisticsCruncher::_n1mom
private

Number of 1st,2nd,3rd,4th moments to compute.

Referenced by computeStats(), createCombinations(), setupMinMax(), setupMoments(), and setupWindDir().

◆ _n2mom

unsigned int nidas::dynld::StatisticsCruncher::_n2mom
private

◆ _n3mom

unsigned int nidas::dynld::StatisticsCruncher::_n3mom
private

◆ _n4mom

unsigned int nidas::dynld::StatisticsCruncher::_n4mom
private

◆ _ncov

unsigned int nidas::dynld::StatisticsCruncher::_ncov
private

◆ _ninvars

unsigned int nidas::dynld::StatisticsCruncher::_ninvars
private

◆ _nOutVar

unsigned int nidas::dynld::StatisticsCruncher::_nOutVar
private

◆ _nSamples

unsigned int* nidas::dynld::StatisticsCruncher::_nSamples
private

◆ _nsum

unsigned int nidas::dynld::StatisticsCruncher::_nsum
private

◆ _ntot

unsigned int nidas::dynld::StatisticsCruncher::_ntot
private

Total number of products to compute.

Referenced by computeStats(), createCombinations(), and initStats().

◆ _ntri

unsigned int nidas::dynld::StatisticsCruncher::_ntri
private

◆ _numpoints

bool nidas::dynld::StatisticsCruncher::_numpoints
private

Does the user want number-of-points output?

Referenced by computeStats(), initStats(), and StatisticsCruncher().

◆ _outlen

unsigned int nidas::dynld::StatisticsCruncher::_outlen
private

Referenced by computeStats(), and initStats().

◆ _outSample

SampleTag nidas::dynld::StatisticsCruncher::_outSample
private

◆ _periodUsecs

dsm_time_t nidas::dynld::StatisticsCruncher::_periodUsecs
private

◆ _proc

StatisticsProcessor* nidas::dynld::StatisticsCruncher::_proc
private

Referenced by initStats().

◆ _reqTag

SampleTag nidas::dynld::StatisticsCruncher::_reqTag
private

Referenced by attach(), connect(), and StatisticsCruncher().

◆ _reqVariables

std::vector<const Variable*> nidas::dynld::StatisticsCruncher::_reqVariables
private

◆ _resampler

NearestResampler* nidas::dynld::StatisticsCruncher::_resampler
private

Referenced by connect(), and ~StatisticsCruncher().

◆ _sampleMap

std::map<dsm_sample_id_t,sampleInfo > nidas::dynld::StatisticsCruncher::_sampleMap
private

Referenced by attach(), and ~StatisticsCruncher().

◆ _site

const Site* nidas::dynld::StatisticsCruncher::_site
private

Referenced by StatisticsCruncher().

◆ _source

SampleSourceSupport nidas::dynld::StatisticsCruncher::_source
private

◆ _splitVarNames

std::vector<std::vector<std::string> > nidas::dynld::StatisticsCruncher::_splitVarNames
private

Input variable names, split at dots.

Referenced by makeName(), setupMinMax(), setupWindDir(), and splitNames().

◆ _startTime

nidas::util::UTime nidas::dynld::StatisticsCruncher::_startTime
private

Referenced by getStartTime(), and setStartTime().

◆ _station

int nidas::dynld::StatisticsCruncher::_station
private

◆ _statsType

statisticsType nidas::dynld::StatisticsCruncher::_statsType
private

Types of statistics I can generate.

Referenced by computeStats(), createCombinations(), initStats(), and StatisticsCruncher().

◆ _tout

dsm_time_t nidas::dynld::StatisticsCruncher::_tout
private

Referenced by computeStats(), flush(), and setStartTime().

◆ _triComb

unsigned int** nidas::dynld::StatisticsCruncher::_triComb
private

◆ _x4Sum

double* nidas::dynld::StatisticsCruncher::_x4Sum
private

◆ _xMax

float* nidas::dynld::StatisticsCruncher::_xMax
private

◆ _xMin

float* nidas::dynld::StatisticsCruncher::_xMin
private

◆ _xSum

double* nidas::dynld::StatisticsCruncher::_xSum
private

◆ _xySum

double** nidas::dynld::StatisticsCruncher::_xySum
private

◆ _xyzSum

double* nidas::dynld::StatisticsCruncher::_xyzSum
private

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