v0.20.0 -- Full s3 event parse and PDF creation. #28

Merged
serversdown merged 46 commits from dev into main 2026-05-28 17:54:34 -04:00
2 changed files with 21 additions and 4 deletions
Showing only changes of commit fa9d3cdef2 - Show all commits
+12 -1
View File
@@ -811,7 +811,18 @@ def read_blastware_file(path: Union[str, Path]) -> Event:
project=project, client=client, operator=user, sensor_location=seisloc, project=project, client=client, operator=user, sensor_location=seisloc,
) )
ev.raw_samples = samples 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 ev._a5_frames = None # not recoverable from BW file
return ev return ev
+9 -3
View File
@@ -289,9 +289,15 @@ def test_read_blastware_file_round_trip(tmp_path: Path):
assert parsed.timestamp.second == ev.timestamp.second assert parsed.timestamp.second == ev.timestamp.second
# No A5 source recoverable. # No A5 source recoverable.
assert parsed._a5_frames is None assert parsed._a5_frames is None
# Peaks computed from samples (synthetic = zero samples → zero peaks). # The synthetic event has no real waveform body, so the codec can't
assert parsed.peak_values is not None # decode samples → read_blastware_file leaves peak_values=None
assert parsed.peak_values.peak_vector_sum == 0.0 # (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 = [ _BW_CODEC_FIXTURES = [