Exemplo n.º 1
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool Detector::emitPick(const Record* rec, const Core::Time& t) {
	// Is there a last pick and a last snr amplitude? Then defer the pick
	// until the max amplitude has been calculated
	if ( _lastAmplitude && (bool)_lastPick ) {
		double dt = (double)(t - _lastPick);
		double deadTime = (double)_deadTime;

		if ( deadTime > 0 ) {
			double dtn = dt/deadTime;
			_minAmplitude = _amplitudeThreshold + *_lastAmplitude * exp(-dtn*dtn);
		}
		else
			_minAmplitude = _amplitudeThreshold;

		SEISCOMP_DEBUG("Time to last pick = %.2f sec, last amplitude = %.2f, minimum amplitude = %.2f", dt, *_lastAmplitude, *_minAmplitude);

		if ( *_minAmplitude > _triggeredAmplitude ) {
			_currentPick = t;
			_currentPickRecord = rec;

			SEISCOMP_DEBUG("Defer pick, minimum amplitude to reach is %.2f", *_minAmplitude);
			return false;
		}

		SEISCOMP_DEBUG("Deferred sending disabled, pick already reached minimum amplitude: %.2f >= %.2f", _triggeredAmplitude, *_minAmplitude);
	}

	return sendPick(rec, t);
}
Exemplo n.º 2
0
SimulationPlanner::SimulationPlanner(QString event, QDir eventDir,
                                     QList<QPair<QString,int> > all,
                                     QList<QPair<QString,int> > picks,
                                     QList<QPair<QString,int> > origins,
                                     int duration,
                                     QObject *parent) :
    QObject(parent),
    requiredEventName(event),
    requiredEventDir(eventDir),
    allBlocks(all),
    picksBlocks(picks),
    originsBlocks(origins),
    simulationDuration(duration),
    eventTimer(new QTimer(this)),
    blocksTimer(new QTimer(this)),
    blocksCounter(0),
    originsCounter(0),
    picksCounter(0),
    config(new QSettings(QDir::currentPath()+"/config/sorges.conf",QSettings::NativeFormat))
{
    //to start the simulation with a bit of delay in order to set everything
    int waitTime=2000;
    std::cout<<"Starting planner in 2 seconds..."<<std::endl;

    connect (blocksTimer,SIGNAL(timeout()),this,SLOT(dispatch()));

    connect (this,SIGNAL(pickTurn(QString)),this,SLOT(sendPick(QString)));
    connect (this,SIGNAL(originTurn(QString)),this,SLOT(sendOrigin(QString)));

    std::cout<<"Starting time triggers for data..."<<std::endl;
    blocksTimer->start(waitTime);
}
Exemplo n.º 3
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void Detector::sendMaxAmplitude(const Record *record) {
	_lastAmplitude = _amplProc.amplitude;

	double offset = (double)_amplProc.index / record->samplingFrequency();

	_amplProc.reset();

	if ( !_lastAmplitude ) {
		SEISCOMP_ERROR("This should never happen: no SNR amplitude to be sent");
		return;
	}

	if ( _minAmplitude && *_lastAmplitude < *_minAmplitude ) {
		SEISCOMP_DEBUG("Skipping pick, minimum amplitude not reached: %.2f < %.2f", *_lastAmplitude, *_minAmplitude);
		return;
	}

	// emit the current pick
	if ( _currentPickRecord && (bool)_currentPick )
		sendPick(_currentPickRecord.get(), _currentPick);

	Core::Time t = _lastPick + Core::TimeSpan(offset);

	if ( _amplPublish && isEnabled() ) {
		if ( _pickID.empty() ) {
			SEISCOMP_DEBUG("No valid pickID set (pick has not been sent), cancel sending 'snr' amplitude");
			return;
		}

		AmplitudeProcessor_SNR ampProc(_lastPick + this->offset());
		Processing::AmplitudeProcessor::Result res;
		ampProc.setReferencingPickID(_pickID);
		res.amplitude.value = *_lastAmplitude;
		res.period = 0.;
		res.snr = -1.;
		res.time.reference = t;
		res.time.begin = -offset;
		res.time.end = (double)_twMax-offset;
		res.record = record;
		_amplPublish(&ampProc, res);
	}
}