Exemplo n.º 1
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool AmplitudeProcessor_msbb::computeAmplitude(const DoubleArray &data,
                                               size_t i1, size_t i2,
                                               size_t si1, size_t si2, double offset,
                                               AmplitudeIndex *dt,
                                               AmplitudeValue *amplitude,
                                               double *period, double *snr) {
	/*
	* Low-level signal amplitude computation. This is magnitude specific.
	*
	* Input:
	*      f           double array of length n
	*      i1,i2       indices defining the measurement window,
	*                  0 <= i1 < i2 <= n
	*      offset      this is subtracted from the samples in f before
	*                  computation
	*
	* Output:
	*      dt          Point at which the measurement was mad/completed. May
	*                  be the peak time or end of integration.
	*      amplitude   amplitude. This may be a peak amplitude as well as a
	*                  sum or integral.
	*      period      dominant period of the signal. Optional. If the period
	*                  is not computed, set it to -1.
	*/

	size_t imax = find_absmax(data.size(), (const double*)data.data(), si1, si2, offset);
	double amax = fabs(data[imax] - offset);
	double pmax = -1;
	double pstd =  0; // standard error of period
	if ( !measure_period(data.size(), static_cast<const double*>(data.data()), imax, offset, &pmax, &pstd) )
		pmax = -1;

	if ( amax < *_noiseAmplitude * _config.snrMin ) {
		amplitude->value = amax / *_noiseAmplitude;
		setStatus(LowSNR, amplitude->value);
		return false;
	}

	dt->index = imax;
	*period = pmax;
	amplitude->value = amax;

	if ( _usedComponent <= SecondHorizontal ) {
		if ( _streamConfig[_usedComponent].gain != 0.0 )
			amplitude->value /= _streamConfig[_usedComponent].gain;
		else {
			setStatus(MissingGain, 0.0);
			return false;
		}
	}
	else
		return false;

	return true;
}
Exemplo n.º 2
0
double fractile(const DoubleArray &v, double x)
{
	return fractile(v.size(), (const double*)v.data(), x);
}
Exemplo n.º 3
0
double mean(const DoubleArray &v)
{
	return mean(v.size(), (const double*)v.data());	
}
Exemplo n.º 4
0
double
trimmedMean(const DoubleArray &v, double percent)
{
// XXX deprecated XXX
	return trimmedMean(v.size(), (const double*)v.data(), percent);	
}