merge: dev into feat/series4-sfm-parity -- #41, a Blastware event's record type from its bytes

Brings ede6292 (fix 46daea1, changelog b6fc71b) from the decode checker's
branch.  Completes #8's live S3 download path: a live histogram, whose direct
download name (K441LTON.900) carries no type letter, is now labelled from
STRT[18] instead of defaulting to Waveform.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-10-29 23:57:41 -04:00
commit a1d2b61f22
4 files changed
+73 -10

No files matched your search

+17 -6
View File
@@ -784,6 +784,12 @@ def _peaks_from_samples(samples: dict[str, list[int]]) -> PeakValues:
)
# STRT[18], the record-type byte (#41): 0x46 on every one of DL2's 6,577
# waveform files and 0x0A on every one of its 63,535 histograms (measured
# 2026-10-29). Manual / Event / Combo never occur there, so their bytes are
# unknown and decode as None, not as a guess.
_RECORD_TYPE_BY_STRT = {0x46: "Waveform", 0x0A: "Histogram"}
_RECORD_TYPE_BY_EXT_SUFFIX = {
'H': 'Histogram',
'W': 'Waveform',
@@ -1128,12 +1134,17 @@ def decode_blastware_bytes(raw: bytes, *, name: Optional[str] = None) -> Event:
ev = Event(index=-1)
if strt_fields.get("waveform_key"):
ev._waveform_key = bytes.fromhex(strt_fields["waveform_key"])
# Derive record_type from the filename's extension suffix (H/W/M/E/C).
# When called from save_imported_bw the path here is a tmp file with a
# ".bw" suffix, so the derivation falls back to "Waveform" and the
# caller overrides ev.record_type using the original filename — see
# waveform_store.save_imported_bw.
ev.record_type = derive_record_type_from_filename(name)
# The record type comes from the bytes: STRT[18] (#41). The filename's
# last letter is only a cross-check -- SFM's own downloads have no name,
# and a manual download's (".QZ0") carries no type at all.
type_byte = strt_raw[18]
ev.record_type = _RECORD_TYPE_BY_STRT.get(type_byte)
if ev.record_type is None:
ev.decode_problems.append(f"unknown record type byte 0x{type_byte:02x} at STRT[18]")
named_type = derive_record_type_from_filename(name, default=None) if name else None
if named_type is not None and ev.record_type is not None and named_type != ev.record_type:
log.warning("%s: record type %s from the file disagrees with the filename's %s; "
"the file's is kept", label, ev.record_type, named_type)
# Setup fields come from the recording-setup block (#44/#45), not the STRT
# record: STRT[18] is the record-type marker (0x46 / 0x0A), which is why