Skip to content

Commit

Permalink
eewamp bug (work done with @luca-s): the horizontal channel clip mask…
Browse files Browse the repository at this point in the history
… is not long enough for checking all samples, happens only with combining horizontal channels from faulty sensor continuously close to clipping level.
  • Loading branch information
FMassin committed Jun 12, 2024
1 parent 85c1b4b commit d3787f4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
14 changes: 13 additions & 1 deletion libs/seiscomp/processing/eewamps/processors/envelope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ void EnvelopeProcessor::process(const Record *rec, const DoubleArray &data) {
Core::Time ts = rec->startTime();
const BitSet *clipMask = rec->clipMask();

if ( clipMask != NULL && ((unsigned int)data.size()) != clipMask->size() ) {
SEISCOMP_WARNING("%s: data.size() != clipMask->size() (%d != %zu)",
rec->streamID().c_str(),
data.size(),
clipMask->size());
}

// Process all samples
if ( clipMask == NULL ) {
for ( int i = 0; i < data.size(); ++i ) {
Expand Down Expand Up @@ -135,9 +142,14 @@ void EnvelopeProcessor::process(const Record *rec, const DoubleArray &data) {
}

_samplePool.push(data[i]);
if ( clipMask->test(i) )
if ( ((unsigned int)i) < clipMask->size() && clipMask->test(i) )
_samplePool.clipped = true;

if ( ((unsigned int)i) >= clipMask->size() ){

This comment has been minimized.

Copy link
@FMassin

FMassin Jun 12, 2024

Author Member

Dear @gempa-jabe (cc @luca-s)

This sanity check responds to a bug(?) in eewamp: the horizontal channel clip mask is sometimes not long enough for checking all samples, it happens only with combining horizontal channels from faulty sensors continuously close to the clipping level.

Any help?

This comment has been minimized.

Copy link
@gempa-jabe

gempa-jabe Jun 12, 2024

Contributor

It is actually more important to fix the bug rather than adding sanity checks, right? Can you dump some data to be able to reproduce the bug offline?

This comment has been minimized.

Copy link
@FMassin

FMassin Jun 12, 2024

Author Member

Yes I agree that is why I have added logs related to the issue. The software also needs to run so I decided to avoid the crash and to request your help. This commit also helps me explaning to you exactly what the issue is instead of writing a poor description in an email. But the data will be in your emails.

SEISCOMP_WARNING("%s: cannot check if data[%d] is clipped (clip mask too short) unreliable data.",
rec->streamID().c_str(),
i);
}
ts += _dt;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,15 @@ Record *GainAndBaselineCorrectionRecordFilter<T>::feed(const Record *rec) {
}

if ( clipMask ) {
std::cerr << rec->streamID() << ": set clip mask: clipped = " << clipMask->numberOfBitsSet() << std::endl;
//std::cerr << rec->streamID() << ": set clip mask: clipped = " << clipMask->numberOfBitsSet() << std::endl;
SEISCOMP_INFO("%s: set clip mask: clipped = %zu",
rec->streamID().c_str(),
clipMask->numberOfBitsSet());
SEISCOMP_DEBUG("%s: rec.size()=%d clipMask->size()=%zu correctedData->size()=%d",
rec->streamID().c_str(),
rec->data()->size(),
clipMask->size(),
correctedData->size());
}

*correctedData *= _gainCorrectionFactor;
Expand Down

0 comments on commit d3787f4

Please sign in to comment.