v0.20.0 - prerelease features. #25
@@ -811,7 +811,18 @@ def read_blastware_file(path: Union[str, Path]) -> Event:
|
||||
project=project, client=client, operator=user, sensor_location=seisloc,
|
||||
)
|
||||
ev.raw_samples = samples
|
||||
ev.peak_values = _peaks_from_samples(samples)
|
||||
# Only compute peaks from samples when we actually have samples.
|
||||
# For events the codec couldn't decode (histogram-mode bodies, until
|
||||
# the §7.6.2 histogram codec is wired in), samples is an empty dict
|
||||
# and ``_peaks_from_samples`` would return PeakValues(0, 0, 0, 0, 0).
|
||||
# That would then OVERWRITE existing good DB peak values (e.g. from
|
||||
# paired BW ASCII reports) during the backfill UPSERT path.
|
||||
# Leaving peak_values=None signals "we don't know" to downstream
|
||||
# consumers; the backfill script seeds from the DB row when it sees
|
||||
# None, and ``apply_report_to_event`` overlays from a paired ASCII
|
||||
# report when one is supplied.
|
||||
has_samples = any(samples.get(ch) for ch in ("Tran", "Vert", "Long", "MicL"))
|
||||
ev.peak_values = _peaks_from_samples(samples) if has_samples else None
|
||||
ev._a5_frames = None # not recoverable from BW file
|
||||
|
||||
return ev
|
||||
|
||||
@@ -289,9 +289,15 @@ def test_read_blastware_file_round_trip(tmp_path: Path):
|
||||
assert parsed.timestamp.second == ev.timestamp.second
|
||||
# No A5 source recoverable.
|
||||
assert parsed._a5_frames is None
|
||||
# Peaks computed from samples (synthetic = zero samples → zero peaks).
|
||||
assert parsed.peak_values is not None
|
||||
assert parsed.peak_values.peak_vector_sum == 0.0
|
||||
# The synthetic event has no real waveform body, so the codec can't
|
||||
# decode samples → read_blastware_file leaves peak_values=None
|
||||
# (the "we don't know" signal) rather than fabricating all-zero
|
||||
# peaks that would otherwise overwrite real DB values via UPSERT.
|
||||
assert parsed.peak_values is None
|
||||
assert parsed.raw_samples is not None
|
||||
# Empty channels — codec returned None for the malformed synthetic body.
|
||||
for ch in ("Tran", "Vert", "Long", "MicL"):
|
||||
assert parsed.raw_samples[ch] == []
|
||||
|
||||
|
||||
_BW_CODEC_FIXTURES = [
|
||||
|
||||
Reference in New Issue
Block a user