nidas v1.2.3
|
A simple, nearest-point resampler, for generating merged samples from variables from one or more sample sources. More...
#include <NearestResampler.h>
Private Member Functions | |
void | ctorCommon (const std::vector< const Variable * > &vars, bool nansVariable) |
Common tasks of constructors. | |
void | addSampleTag (const SampleTag *tag) throw () |
Add a SampleTag to this SampleSource. | |
void | removeSampleTag (const SampleTag *tag) throw () |
NearestResampler & | operator= (const NearestResampler &) |
No assignment. | |
NearestResampler (const NearestResampler &x) | |
No copy. | |
Private Attributes | |
SampleSourceSupport | _source |
SampleTag | _outSample |
std::vector< Variable * > | _reqVars |
Requested variables. | |
std::map< Variable *, unsigned int > | _outVarIndices |
Index of each requested output variable in the output sample. | |
std::map< dsm_sample_id_t, std::vector< unsigned int > > | _inmap |
For each input sample, first index of variable data values to be read. | |
std::map< dsm_sample_id_t, std::vector< unsigned int > > | _lenmap |
For each input sample, length of variables to read. | |
std::map< dsm_sample_id_t, std::vector< unsigned int > > | _outmap |
For each input sample, index into output sample of each variable. | |
unsigned int | _ndataValues |
unsigned int | _outlen |
unsigned int | _master |
int | _nmaster |
dsm_time_t * | _prevTT |
dsm_time_t * | _nearTT |
float * | _prevData |
float * | _nearData |
int * | _samplesSinceMaster |
std::map< dsm_sample_id_t, unsigned int > | _ttOutOfOrder |
bool | _debug |
A simple, nearest-point resampler, for generating merged samples from variables from one or more sample sources.
The first variable added to NearestResample with the addVariable() method becomes the "master" variable. The time tags of the master variable become the output sample time tags, and values of other variables are merged into the output sample by associating those values with the nearest time tag to the master times.
The only requirement is that the samples which are fed to the receive() method should be sorted in time. It they aren't sorted some data will be lost. NearestResampler does not need to know sampling rates, and the sampling rates of the input variables, including the master variable, may vary.
NearestResampler::NearestResampler | ( | const std::vector< const Variable * > & | vars, |
bool | nansVariable = true ) |
Constructor.
References ctorCommon().
NearestResampler::NearestResampler | ( | const std::vector< Variable * > & | vars, |
bool | nansVariable = true ) |
References ctorCommon(), and nidas::core::getSample().
NearestResampler::~NearestResampler | ( | ) |
References _nearData, _nearTT, _prevData, _prevTT, _reqVars, _samplesSinceMaster, and nidas::core::getSample().
|
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.
Implements nidas::core::SampleSource.
References _source, and nidas::core::SampleSourceSupport::addSampleTag().
Referenced by ctorCommon().
|
virtual |
Connect the resampler to a SampleSource.
nidas::util::InvalidParameterException |
Implements nidas::core::Resampler.
References _inmap, _lenmap, _outmap, _outVarIndices, _reqVars, nidas::core::SampleSource::addSampleClientForTag(), nidas::core::Sample::getId(), nidas::core::Variable::getName(), nidas::core::getSample(), nidas::core::SampleSource::getSampleTags(), and WLOG.
Referenced by nidas::dynld::StatisticsCruncher::connect().
|
private |
Common tasks of constructors.
References _debug, _master, _ndataValues, _nearData, _nearTT, _nmaster, _outlen, _outSample, _outVarIndices, _prevData, _prevTT, _reqVars, _samplesSinceMaster, addSampleTag(), nidas::core::SampleTag::addVariable(), nidas::core::floatNAN, GET_DSM_ID, GET_SPS_ID, nidas::core::Sample::getId(), nidas::core::Project::getInstance(), nidas::core::Variable::getLength(), nidas::core::Variable::getName(), nidas::core::getSample(), nidas::core::Variable::getSite(), nidas::core::Variable::getStation(), nidas::core::SampleTag::setDSMId(), nidas::core::Variable::setName(), nidas::core::SampleTag::setSampleId(), nidas::core::Variable::setType(), nidas::core::Variable::setUnits(), and nidas::core::Variable::WEIGHT.
Referenced by NearestResampler(), and NearestResampler().
|
virtual |
Implements nidas::core::Resampler.
|
virtual |
Implementation of Resampler::flush().
Send out whatever samples are available.
Implements nidas::core::Resampler.
References _master, _ndataValues, _nearData, _nearTT, _nmaster, _outlen, _outSample, _prevData, _prevTT, _samplesSinceMaster, _source, nidas::core::SampleSourceSupport::distribute(), nidas::core::floatNAN, nidas::core::SampleTag::getId(), and nidas::core::getSample().
|
inlinevirtual |
How many SampleClients are currently in my list.
)
Implements nidas::core::SampleSource.
References _source, and nidas::core::SampleSourceSupport::getClientCount().
|
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().
Get the SampleTag of my merged output sample.
Implements nidas::core::SampleSource.
References _source, and nidas::core::SampleSourceSupport::getSampleTags().
|
private |
No assignment.
Implementation of SampleClient::receive().
Implements nidas::core::SampleClient.
References nidas::core::DOUBLE_ST, nidas::core::FLOAT_ST, nidas::core::floatNAN, nidas::util::UTime::format(), GET_DSM_ID, GET_SPS_ID, nidas::core::getSample(), USECS_PER_SEC, 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().
|
private |
Referenced by ctorCommon().
|
private |
For each input sample, first index of variable data values to be read.
Referenced by connect().
|
private |
For each input sample, length of variables to read.
Referenced by connect().
Referenced by ctorCommon(), and flush().
Referenced by ctorCommon(), and flush().
|
private |
Referenced by ctorCommon(), flush(), and ~NearestResampler().
|
private |
Referenced by ctorCommon(), flush(), and ~NearestResampler().
|
private |
Referenced by ctorCommon(), and flush().
Referenced by ctorCommon(), and flush().
|
private |
For each input sample, index into output sample of each variable.
Referenced by connect().
|
private |
Referenced by ctorCommon(), and flush().
Index of each requested output variable in the output sample.
Referenced by connect(), and ctorCommon().
|
private |
Referenced by ctorCommon(), flush(), and ~NearestResampler().
|
private |
Referenced by ctorCommon(), flush(), and ~NearestResampler().
|
private |
Requested variables.
Referenced by connect(), ctorCommon(), and ~NearestResampler().
|
private |
Referenced by ctorCommon(), flush(), and ~NearestResampler().
|
private |
|
private |