[installation] Change to nightly
This commit is contained in:
@ -25,6 +25,7 @@
|
||||
|
||||
#include <seiscomp/processing/waveformoperator.h>
|
||||
#include <seiscomp/core/genericrecord.h>
|
||||
#include <seiscomp/core/optional.h>
|
||||
#include <seiscomp/core/recordsequence.h>
|
||||
|
||||
|
||||
@ -54,8 +55,8 @@ class NCompsOperator : public WaveformOperator {
|
||||
public:
|
||||
NCompsOperator(const PROC &proc) : _proc(proc), _processing(false) {}
|
||||
|
||||
WaveformProcessor::Status feed(const Record *record);
|
||||
void reset();
|
||||
WaveformProcessor::Status feed(const Record *record) override;
|
||||
void reset() override;
|
||||
|
||||
// Returns the RingBuffer of each component.
|
||||
const Seiscomp::RingBuffer &buffer(int i) const {
|
||||
@ -72,8 +73,8 @@ class NCompsOperator : public WaveformOperator {
|
||||
protected:
|
||||
struct State {
|
||||
State() : buffer(BSIZE) {}
|
||||
RingBuffer buffer;
|
||||
Core::Time endTime;
|
||||
RingBuffer buffer;
|
||||
OPT(Core::Time) endTime;
|
||||
};
|
||||
|
||||
// Stores the N channel codes and the according record buffer
|
||||
@ -94,12 +95,17 @@ template <typename T, template <typename,int> class PROC>
|
||||
class CodeWrapper<T,2,PROC> {
|
||||
public:
|
||||
CodeWrapper(const std::string &code1, const std::string &code2,
|
||||
const PROC<T,2> &proc) : _proc(proc) {}
|
||||
const PROC<T,2> &proc)
|
||||
: _proc(proc), _code1(code1), _code2(code2) {}
|
||||
|
||||
void operator()(const Record *rec, T *data[2], int n, const Core::Time &stime, double sfreq) const { _proc(rec, data, n, stime, sfreq); }
|
||||
bool publish(int c) const { return _proc.publish(c); }
|
||||
|
||||
int compIndex(const std::string &code) const { return -1; }
|
||||
int compIndex(const std::string &code) const {
|
||||
if ( code == _code1 ) return 0;
|
||||
else if ( code == _code2 ) return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
const std::string &translateChannelCode(int c, const std::string &code) { return code; }
|
||||
|
||||
|
||||
@ -39,9 +39,9 @@ struct ScopedUnsetFlag {
|
||||
|
||||
template <typename T, int N, class PROC, int BSIZE>
|
||||
WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::process(int, const Record *rec) {
|
||||
Core::Time minStartTime;
|
||||
Core::Time maxStartTime;
|
||||
Core::Time minEndTime;
|
||||
OPT(Core::Time) minStartTime;
|
||||
OPT(Core::Time) maxStartTime;
|
||||
OPT(Core::Time) minEndTime;
|
||||
WaveformProcessor::Status status;
|
||||
|
||||
status = WaveformProcessor::WaitingForData;
|
||||
@ -51,9 +51,10 @@ WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::process(int, const Rec
|
||||
|
||||
for ( int i = 0; i < N; ++i ) {
|
||||
// Not all traces available, nothing to do
|
||||
if ( _states[i].endTime.valid() ) {
|
||||
if ( _states[i].endTime > minStartTime )
|
||||
minStartTime = _states[i].endTime;
|
||||
if ( _states[i].endTime ) {
|
||||
if ( !minStartTime || (*_states[i].endTime > *minStartTime) ) {
|
||||
minStartTime = *_states[i].endTime;
|
||||
}
|
||||
}
|
||||
|
||||
if ( _states[i].buffer.empty() ) {
|
||||
@ -69,8 +70,9 @@ WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::process(int, const Rec
|
||||
double samplingFrequency, timeTolerance;
|
||||
|
||||
// Initialize iterators for each component
|
||||
for ( int i = 0; i < N; ++i )
|
||||
for ( int i = 0; i < N; ++i ) {
|
||||
it[i] = _states[i].buffer.begin();
|
||||
}
|
||||
|
||||
// Store sampling frequency of first record of first component
|
||||
// All records must match this sampling frequency
|
||||
@ -81,15 +83,18 @@ WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::process(int, const Rec
|
||||
if ( minStartTime ) {
|
||||
for ( int i = 0; i < N; ++i ) {
|
||||
while ( it[i] != _states[i].buffer.end() ) {
|
||||
if ( (*it[i])->endTime() <= minStartTime )
|
||||
if ( (*it[i])->endTime() <= *minStartTime ) {
|
||||
it[i] = _states[i].buffer.erase(it[i]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// End of stream?
|
||||
if ( it[i] == _states[i].buffer.end() )
|
||||
if ( it[i] == _states[i].buffer.end() ) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,11 +148,14 @@ WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::process(int, const Rec
|
||||
const Record *rec = it_end[i]->get();
|
||||
|
||||
// Skip records with wrong sampling frequency
|
||||
if ( rec->samplingFrequency() != samplingFrequency )
|
||||
if ( rec->samplingFrequency() != samplingFrequency ) {
|
||||
return WaveformProcessor::InvalidSamplingFreq;
|
||||
}
|
||||
|
||||
double diff = (double)(rec->startTime()-(*tmp)->endTime());
|
||||
if ( fabs(diff) > timeTolerance ) break;
|
||||
if ( fabs(diff) > timeTolerance ) {
|
||||
break;
|
||||
}
|
||||
|
||||
tmp = it_end[i];
|
||||
++it_end[i];
|
||||
@ -158,11 +166,12 @@ WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::process(int, const Rec
|
||||
|
||||
// Find minimum end time of all three records
|
||||
for ( int i = 0; i < N; ++i ) {
|
||||
if ( !i || minEndTime > (*it_end[i])->endTime() )
|
||||
if ( !i || minEndTime > (*it_end[i])->endTime() ) {
|
||||
minEndTime = (*it_end[i])->endTime();
|
||||
}
|
||||
}
|
||||
|
||||
typedef typename Core::SmartPointer< NumericArray<T> >::Impl DataArrayPtr;
|
||||
using DataArrayPtr = Core::SmartPointer< NumericArray<T> >;
|
||||
|
||||
DataArrayPtr data[N];
|
||||
GenericRecordPtr comps[N];
|
||||
@ -170,8 +179,9 @@ WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::process(int, const Rec
|
||||
int minLen = 0;
|
||||
|
||||
// Clip maxStartTime to minStartTime
|
||||
if ( maxStartTime < minStartTime )
|
||||
if ( maxStartTime < minStartTime ) {
|
||||
maxStartTime = minStartTime;
|
||||
}
|
||||
|
||||
BitSetPtr clipMask;
|
||||
|
||||
@ -180,26 +190,28 @@ WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::process(int, const Rec
|
||||
float tq = 0;
|
||||
int tqCount = 0;
|
||||
|
||||
if ( _proc.publish(i) )
|
||||
if ( _proc.publish(i) ) {
|
||||
comps[i] = new GenericRecord((*it[i])->networkCode(),
|
||||
(*it[i])->stationCode(),
|
||||
(*it[i])->locationCode(),
|
||||
_proc.translateChannelCode(i, (*it[i])->channelCode()),
|
||||
maxStartTime, samplingFrequency);
|
||||
*maxStartTime, samplingFrequency);
|
||||
}
|
||||
|
||||
data[i] = new NumericArray<T>;
|
||||
RecordSequence::iterator seq_end = it_end[i];
|
||||
++seq_end;
|
||||
|
||||
for ( RecordSequence::iterator rec_it = it[i]; rec_it != seq_end; ) {
|
||||
for ( auto rec_it = it[i]; rec_it != seq_end; ) {
|
||||
const Array *rec_data = (*rec_it)->data();
|
||||
if ( (*rec_it)->startTime() > minEndTime )
|
||||
if ( (*rec_it)->startTime() > minEndTime ) {
|
||||
break;
|
||||
}
|
||||
|
||||
++it[i];
|
||||
|
||||
const NumericArray<T> *srcData = NumericArray<T>::ConstCast(rec_data);
|
||||
typename Core::SmartPointer< NumericArray<T> >::Impl tmp;
|
||||
Core::SmartPointer<NumericArray<T>> tmp;
|
||||
if ( srcData == nullptr ) {
|
||||
tmp = (NumericArray<T>*)rec_data->copy(NumericArray<T>::ArrayType);
|
||||
srcData = tmp.get();
|
||||
@ -208,11 +220,13 @@ WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::process(int, const Rec
|
||||
int startIndex = 0;
|
||||
int endIndex = srcData->size();
|
||||
|
||||
if ( (*rec_it)->startTime() < maxStartTime )
|
||||
startIndex += (int)(double(maxStartTime-(*rec_it)->startTime())*(*rec_it)->samplingFrequency()+0.5);
|
||||
if ( (*rec_it)->startTime() < *maxStartTime ) {
|
||||
startIndex += (int)(double(*maxStartTime - (*rec_it)->startTime()) * (*rec_it)->samplingFrequency() + 0.5);
|
||||
}
|
||||
|
||||
if ( (*rec_it)->endTime() > minEndTime )
|
||||
endIndex -= (int)(double((*rec_it)->endTime()-minEndTime)*(*rec_it)->samplingFrequency());
|
||||
if ( (*rec_it)->endTime() > *minEndTime ) {
|
||||
endIndex -= (int)(double((*rec_it)->endTime() - *minEndTime) * (*rec_it)->samplingFrequency());
|
||||
}
|
||||
|
||||
int len = endIndex-startIndex;
|
||||
// Skip empty records
|
||||
@ -231,13 +245,16 @@ WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::process(int, const Rec
|
||||
if ( (recClipMask != nullptr) && recClipMask->any() ) {
|
||||
int ofs = data[i]->size();
|
||||
int nBits = data[i]->size() + len;
|
||||
if ( !clipMask )
|
||||
if ( !clipMask ) {
|
||||
clipMask = new BitSet(nBits);
|
||||
else if ( (int)clipMask->size() < nBits )
|
||||
}
|
||||
else if ( (int)clipMask->size() < nBits ) {
|
||||
clipMask->resize(nBits, false);
|
||||
}
|
||||
|
||||
for ( int i = startIndex; i < len; ++i, ++ofs )
|
||||
for ( int i = startIndex; i < len; ++i, ++ofs ) {
|
||||
clipMask->set(ofs, clipMask->test(ofs) || recClipMask->test(i));
|
||||
}
|
||||
}
|
||||
|
||||
data[i]->append(len, srcData->typedData()+startIndex);
|
||||
@ -245,21 +262,27 @@ WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::process(int, const Rec
|
||||
++rec_it;
|
||||
}
|
||||
|
||||
if ( comps[i] && (tqCount > 0) )
|
||||
if ( comps[i] && (tqCount > 0) ) {
|
||||
comps[i]->setTimingQuality((int)(tq / tqCount));
|
||||
}
|
||||
|
||||
minLen = i==0?data[i]->size():std::min(minLen, data[i]->size());
|
||||
|
||||
if ( comps[i] ) comps[i]->setData(data[i].get());
|
||||
if ( comps[i] ) {
|
||||
comps[i]->setData(data[i].get());
|
||||
}
|
||||
}
|
||||
|
||||
// Trim clip mask to sample array size
|
||||
if ( clipMask ) {
|
||||
if ( (int)clipMask->size() > minLen )
|
||||
if ( (int)clipMask->size() > minLen ) {
|
||||
clipMask->resize(minLen);
|
||||
}
|
||||
|
||||
// Destroy clip mask if no bit is set
|
||||
if ( !clipMask->any() )
|
||||
if ( !clipMask->any() ) {
|
||||
clipMask = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
T *data_samples[N];
|
||||
@ -268,16 +291,17 @@ WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::process(int, const Rec
|
||||
NumericArray<T> *ar = data[i].get();
|
||||
if ( ar->size() > minLen ) {
|
||||
ar->resize(minLen);
|
||||
if ( comps[i] ) comps[i]->dataUpdated();
|
||||
if ( comps[i] ) {
|
||||
comps[i]->dataUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
data_samples[i] = data[i]->typedData();
|
||||
|
||||
Core::Time endTime = maxStartTime + Core::TimeSpan(data[i]->size() / rec->samplingFrequency());
|
||||
Core::Time endTime = *maxStartTime + Core::TimeSpan(data[i]->size() / rec->samplingFrequency());
|
||||
|
||||
// Set last transformed end time of component
|
||||
if ( !_states[i].endTime.valid() ||
|
||||
_states[i].endTime < endTime ) {
|
||||
if ( !_states[i].endTime || *_states[i].endTime < endTime ) {
|
||||
_states[i].endTime = endTime;
|
||||
}
|
||||
}
|
||||
@ -285,7 +309,7 @@ WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::process(int, const Rec
|
||||
if ( minLen > 0 ) {
|
||||
// Process finally
|
||||
try {
|
||||
_proc(rec, data_samples, minLen, maxStartTime, rec->samplingFrequency());
|
||||
_proc(rec, data_samples, minLen, *maxStartTime, rec->samplingFrequency());
|
||||
}
|
||||
catch ( ... ) {
|
||||
return WaveformProcessor::Error;
|
||||
@ -293,8 +317,9 @@ WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::process(int, const Rec
|
||||
|
||||
for ( int i = 0; i < N; ++i ) {
|
||||
if ( comps[i] ) {
|
||||
if ( clipMask )
|
||||
if ( clipMask ) {
|
||||
comps[i]->setClipMask(clipMask.get());
|
||||
}
|
||||
store(comps[i].get());
|
||||
}
|
||||
}
|
||||
@ -315,7 +340,9 @@ WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::process(int, const Rec
|
||||
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
template <typename T, int N, class PROC, int BSIZE>
|
||||
WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::feed(const Record *rec) {
|
||||
if ( rec->data() == nullptr ) return WaveformProcessor::WaitingForData;
|
||||
if ( !rec->data() ) {
|
||||
return WaveformProcessor::WaitingForData;
|
||||
}
|
||||
|
||||
int i = _proc.compIndex(rec->channelCode());
|
||||
if ( i >= 0 ) {
|
||||
@ -334,7 +361,9 @@ WaveformProcessor::Status NCompsOperator<T,N,PROC,BSIZE>::feed(const Record *rec
|
||||
template <typename T, int N, class PROC, int BSIZE>
|
||||
void NCompsOperator<T,N,PROC,BSIZE>::reset() {
|
||||
// No reset while in processing
|
||||
if ( _processing ) return;
|
||||
if ( _processing ) {
|
||||
return;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < N; ++i ) {
|
||||
_states[i] = State();
|
||||
|
||||
@ -36,8 +36,8 @@ class PipeOperator : public WaveformOperator {
|
||||
public:
|
||||
PipeOperator(WaveformOperator *op1, WaveformOperator *op2);
|
||||
|
||||
WaveformProcessor::Status feed(const Record *record);
|
||||
void reset();
|
||||
WaveformProcessor::Status feed(const Record *record) override;
|
||||
void reset() override;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user