nidas v1.2.3
|
#include <StatisticsCruncher.h>
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 () | |
SampleSource * | getRawSampleSource () |
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples. | |
SampleSource * | getProcessedSampleSource () |
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 SampleStats & | getSampleStats () 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. | |
StatisticsCruncher & | operator= (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 |
typedef enum nidas::dynld::StatisticsCruncher::statsEnumType nidas::dynld::StatisticsCruncher::statisticsType |
Types of statistics I can generate.
StatisticsCruncher::StatisticsCruncher | ( | StatisticsProcessor * | proc, |
const SampleTag * | stag, | ||
statisticsType | type, | ||
std::string | countsName, | ||
bool | higherMoments ) |
Constructor.
References _crossTerms, _ninvars, _numpoints, _outSample, _periodUsecs, _reqTag, _reqVariables, _site, _statsType, addSampleTag(), nidas::core::SampleTag::getDSMId(), nidas::core::SampleTag::getRate(), nidas::core::getSample(), nidas::core::SampleTag::getSpSId(), LOG_VERBOSE, MSECS_PER_SEC, nidas::core::SampleTag::setDSMId(), nidas::core::SampleTag::setRate(), nidas::core::SampleTag::setSampleId(), STATS_COV, STATS_FLUX, stats_log_variable(), STATS_MAXIMUM, STATS_MEAN, STATS_MINIMUM, STATS_PRUNEDTRIVAR, STATS_RFLUX, STATS_SFLUX, STATS_SUM, STATS_TRIVAR, STATS_UNKNOWN, STATS_VAR, STATS_WINDDIR, and USECS_PER_MSEC.
StatisticsCruncher::~StatisticsCruncher | ( | ) |
References _nSamples, _ntri, _resampler, _sampleMap, _triComb, _x4Sum, _xMax, _xMin, _xSum, _xySum, _xyzSum, nidas::core::getSample(), and nidas::dynld::StatisticsCruncher::sampleInfo::varIndices.
|
private |
No copy.
|
inlinevirtual |
Implementation of SampleSource::addSampleClient().
Implements nidas::core::SampleSource.
References _source, and nidas::core::SampleSourceSupport::addSampleClient().
|
inlinevirtual |
Add a Client for a given SampleTag.
Implementation of SampleSource::addSampleClient().
Implements nidas::core::SampleSource.
References _source, and nidas::core::SampleSourceSupport::addSampleClient().
|
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().
|
protected |
nidas::util::InvalidParameterException |
References _crossTerms, _ninvars, _outSample, _reqTag, _reqVariables, _sampleMap, _station, nidas::core::SampleSource::addSampleClientForTag(), GET_DSM_ID, GET_SPS_ID, nidas::core::SampleTag::getDSMId(), nidas::core::Sample::getId(), nidas::core::getSample(), nidas::core::SampleSource::getSampleTags(), nidas::core::SampleTag::getSpSId(), nidas::core::SampleTag::getVariable(), nidas::util::LogMessage::log(), LOG_VERBOSE, nidas::core::SampleTag::setStation(), VLOG, nidas::core::Variable::WEIGHT, and WLOG.
Referenced by connect().
|
protected |
References _higherMoments, _n1mom, _n3mom, _n4mom, _ninvars, _nSamples, _ntot, _ntri, _numpoints, _outlen, _outSample, _periodUsecs, _source, _statsType, _tout, _triComb, _x4Sum, _xMax, _xMin, _xSum, _xySum, _xyzSum, nidas::util::dirFromUV(), nidas::core::SampleSourceSupport::distribute(), nidas::core::floatNAN, nidas::util::UTime::format(), nidas::core::SampleTag::getId(), nidas::core::getSample(), LOG_VERBOSE, STATS_FLUX, STATS_MAXIMUM, STATS_MEAN, STATS_MINIMUM, STATS_PRUNEDTRIVAR, STATS_RFLUX, STATS_SFLUX, STATS_SUM, STATS_TRIVAR, STATS_VAR, STATS_WINDDIR, and zeroStats().
Referenced by flush().
void nidas::dynld::StatisticsCruncher::connect | ( | SampleOutput * | output | ) |
Connect a SamplePipeline to the cruncher.
|
virtual |
Connect a SamplePipeline to the cruncher.
nidas::util::InvalidParameterException |
Implements nidas::core::Resampler.
References _crossTerms, _outSample, _reqTag, _reqVariables, _resampler, attach(), nidas::core::NearestResampler::connect(), createCombinations(), DLOG, nidas::core::Variable::getName(), nidas::core::getSample(), nidas::core::SampleSource::getSampleTagIterator(), nidas::core::SampleTag::getStation(), nidas::core::Variable::getStation(), nidas::core::SampleTag::getVariable(), nidas::core::SampleTag::getVariables(), initStats(), LOG_VERBOSE, stats_log_variable(), VLOG, WLOG, and zeroStats().
|
protected |
nidas::util::InvalidParameterException |
References _higherMoments, _n1mom, _n2mom, _n3mom, _n4mom, _ncov, _ninvars, _nOutVar, _ntot, _ntri, _outSample, _station, _statsType, _triComb, nidas::core::Variable::getName(), nidas::core::getSample(), nidas::core::SampleTag::getVariable(), nidas::core::SampleTag::getVariableIterator(), nidas::core::SampleTag::getVariables(), LOG_VERBOSE, nidas::core::Variable::setStation(), setupCovariances(), setupFluxes(), setupMinMax(), setupMoments(), setupPrunedTrivariances(), setupReducedFluxes(), setupReducedScalarFluxes(), setupTrivariances(), setupWindDir(), splitNames(), STATS_COV, STATS_FLUX, STATS_MAXIMUM, STATS_MEAN, STATS_MINIMUM, STATS_PRUNEDTRIVAR, STATS_RFLUX, STATS_SFLUX, STATS_SUM, STATS_TRIVAR, STATS_VAR, STATS_WINDDIR, and VLOG.
Referenced by connect().
void nidas::dynld::StatisticsCruncher::disconnect | ( | SampleOutput * | output | ) |
|
virtual |
Implements nidas::core::Resampler.
|
virtual |
Implementation of Resampler::flush().
Implements nidas::core::Resampler.
References _ninvars, _nSamples, _periodUsecs, _tout, and computeStats().
|
inlinevirtual |
How many SampleClients are currently in my list.
)
Implements nidas::core::SampleSource.
References _source, and nidas::core::SampleSourceSupport::getClientCount().
|
inline |
References _endTime.
|
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.
References _periodUsecs.
|
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.
|
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.
|
inlinevirtual |
Implements nidas::core::SampleSource.
References _source, and nidas::core::SampleSourceSupport::getSampleStats().
|
inlinevirtual |
Implementation of SampleSource::getSampleTagIterator().
Implements nidas::core::SampleSource.
References _source, and nidas::core::SampleSourceSupport::getSampleTagIterator().
|
inlinevirtual |
Get the output SampleTags.
Implements nidas::core::SampleSource.
References _source, and nidas::core::SampleSourceSupport::getSampleTags().
|
inline |
References _startTime.
|
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().
|
static |
nidas::util::InvalidParameterException |
References StatsStrings.
Referenced by nidas::dynld::StatisticsProcessor::addRequestedSampleTag().
|
protected |
References _commonSuffix, _countsName, _leadCommon, _n2mom, _n3mom, _n4mom, _ncov, _ninvars, _nSamples, _nsum, _ntot, _ntri, _numpoints, _outlen, _outSample, _proc, _station, _statsType, _x4Sum, _xMax, _xMin, _xSum, _xySum, _xyzSum, nidas::core::SampleTag::addVariable(), nidas::core::Variable::getName(), nidas::core::getSample(), nidas::dynld::StatisticsProcessor::getUniqueCountsName(), nidas::core::SampleTag::getVariables(), nidas::core::Variable::setName(), nidas::core::Variable::setStation(), nidas::core::Variable::setType(), nidas::core::Variable::setUnits(), STATS_FLUX, STATS_MAXIMUM, STATS_MINIMUM, STATS_RFLUX, STATS_SFLUX, and nidas::core::Variable::WEIGHT.
Referenced by connect().
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().
|
protected |
References nidas::core::getSample().
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().
|
private |
No assignment.
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.
)
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.
|
inlinevirtual |
Remove a SampleClient from this SampleSource.
)
Implements nidas::core::SampleSource.
References _source, and nidas::core::SampleSourceSupport::removeSampleClient().
|
inlinevirtual |
Remove a SampleClient for a given SampleTag from this SampleSource.
The pointer to the SampleClient must remain valid, until after it is removed.
)
Implements nidas::core::SampleSource.
References _source, and nidas::core::SampleSourceSupport::removeSampleClient().
|
inlineprivatevirtual |
)
Implements nidas::core::SampleSource.
References _source, and nidas::core::SampleSourceSupport::removeSampleTag().
|
inline |
References _endTime, and nidas::core::getSample().
References _fillGaps, and nidas::core::getSample().
void StatisticsCruncher::setStartTime | ( | const nidas::util::UTime & | val | ) |
References _periodUsecs, _startTime, _tout, nidas::core::getSample(), and nidas::util::UTime::toUsecs().
|
protected |
|
protected |
References _commonSuffix, _leadCommon, _n1mom, _ninvars, _nOutVar, _nsum, _outSample, _splitVarNames, nidas::core::SampleTag::addVariable(), nidas::core::getSample(), nidas::core::SampleTag::getVariable(), nidas::core::SampleTag::getVariables(), makeUnits(), and nidas::core::Variable::setName().
Referenced by createCombinations().
References _n1mom, _n2mom, _n3mom, _n4mom, _nsum, _reqVariables, addVariable(), nidas::core::getSample(), makeName(), and makeUnits().
Referenced by createCombinations(), and setupPrunedTrivariances().
|
protected |
References _n3mom, _ninvars, _nOutVar, _nsum, _ntri, _outSample, _triComb, nidas::core::SampleTag::addVariable(), nidas::core::getSample(), nidas::core::SampleTag::getVariable(), nidas::core::SampleTag::getVariables(), makeName(), makeUnits(), nidas::core::Variable::setName(), and setupMoments().
Referenced by createCombinations().
|
protected |
|
protected |
|
protected |
|
protected |
nidas::util::InvalidParameterException |
References _commonSuffix, _leadCommon, _n1mom, _nOutVar, _nsum, _outSample, _splitVarNames, and nidas::core::SampleTag::addVariable().
Referenced by createCombinations().
|
protected |
Split input variable names at periods.
References _commonSuffix, _leadCommon, _reqVariables, _splitVarNames, and nidas::core::getSample().
Referenced by createCombinations().
|
protected |
|
private |
Trailing portion that is common to all variable names.
Referenced by initStats(), makeName(), setupMinMax(), setupWindDir(), and splitNames().
|
private |
Name of counts variable.
Referenced by initStats().
|
private |
Does this cruncher compute cross-terms?
Referenced by attach(), connect(), and StatisticsCruncher().
|
private |
Referenced by getEndTime(), and setEndTime().
|
private |
Referenced by getFillGaps(), and setFillGaps().
|
private |
Referenced by computeStats(), and createCombinations().
|
private |
Portion after the first dot-separated word that is common to all variable names.
Referenced by initStats(), makeName(), setupMinMax(), setupWindDir(), and splitNames().
Number of 1st,2nd,3rd,4th moments to compute.
Referenced by computeStats(), createCombinations(), setupMinMax(), setupMoments(), and setupWindDir().
Referenced by createCombinations(), initStats(), setupMoments(), and zeroStats().
Referenced by computeStats(), createCombinations(), initStats(), setupMoments(), setupPrunedTrivariances(), and zeroStats().
Referenced by computeStats(), createCombinations(), initStats(), setupMoments(), and zeroStats().
Number of covariances to compute.
Referenced by createCombinations(), initStats(), setupCovariances(), setupFluxes(), setupReducedFluxes(), setupReducedScalarFluxes(), and zeroStats().
Number of input variables.
Referenced by attach(), computeStats(), createCombinations(), flush(), initStats(), setupCovariances(), setupFluxes(), setupMinMax(), setupPrunedTrivariances(), setupReducedFluxes(), setupReducedScalarFluxes(), setupTrivariances(), StatisticsCruncher(), and zeroStats().
Referenced by computeStats(), flush(), initStats(), zeroStats(), and ~StatisticsCruncher().
Number of simple sums to maintain.
Referenced by initStats(), setupCovariances(), setupFluxes(), setupMinMax(), setupMoments(), setupPrunedTrivariances(), setupReducedFluxes(), setupReducedScalarFluxes(), setupTrivariances(), setupWindDir(), and zeroStats().
Total number of products to compute.
Referenced by computeStats(), createCombinations(), and initStats().
Number of trivariances to compute.
Referenced by computeStats(), createCombinations(), initStats(), setupPrunedTrivariances(), setupTrivariances(), zeroStats(), and ~StatisticsCruncher().
|
private |
Does the user want number-of-points output?
Referenced by computeStats(), initStats(), and StatisticsCruncher().
Referenced by computeStats(), and initStats().
|
private |
|
private |
Referenced by computeStats(), flush(), getPeriodUsecs(), setStartTime(), and StatisticsCruncher().
|
private |
Referenced by initStats().
|
private |
Referenced by attach(), connect(), and StatisticsCruncher().
Referenced by attach(), connect(), makeUnits(), setupMoments(), splitNames(), and StatisticsCruncher().
|
private |
Referenced by connect(), and ~StatisticsCruncher().
|
private |
Referenced by attach(), and ~StatisticsCruncher().
Referenced by StatisticsCruncher().
|
private |
|
private |
Input variable names, split at dots.
Referenced by makeName(), setupMinMax(), setupWindDir(), and splitNames().
|
private |
Referenced by getStartTime(), and setStartTime().
|
private |
Referenced by attach(), createCombinations(), and initStats().
|
private |
Types of statistics I can generate.
Referenced by computeStats(), createCombinations(), initStats(), and StatisticsCruncher().
|
private |
Referenced by computeStats(), flush(), and setStartTime().
Referenced by computeStats(), createCombinations(), setupPrunedTrivariances(), and ~StatisticsCruncher().
|
private |
Referenced by computeStats(), initStats(), zeroStats(), and ~StatisticsCruncher().
|
private |
Referenced by computeStats(), initStats(), zeroStats(), and ~StatisticsCruncher().
|
private |
Referenced by computeStats(), initStats(), zeroStats(), and ~StatisticsCruncher().
|
private |
Referenced by computeStats(), initStats(), zeroStats(), and ~StatisticsCruncher().
|
private |
Referenced by computeStats(), initStats(), zeroStats(), and ~StatisticsCruncher().
|
private |
Referenced by computeStats(), initStats(), zeroStats(), and ~StatisticsCruncher().