Release v0.35.0 — 80 of 88 report fields from the file, and monitor logs (.MLG) #60

Merged
serversdown merged 50 commits from dev into main 2026-11-16 15:49:06 -05:00
9 changed files with 25513 additions and 4 deletions
Showing only changes of commit 0b6150adb5 - Show all commits

No files matched your search

+23 -2
View File
@@ -272,8 +272,25 @@ def _same_text(a: object, b: str) -> bool:
return " ".join(str(a).split()) == " ".join(b.split())
def _mic_table_units(ref: XmlReport) -> str:
"""The unit a report's mic sample table is printed in. Its cells say so --
a mic dB value is never under 60, psi never over 1 -- where the event's
Units line need not: S353JTHU.DT0W prints dB under psi (2026-11-09)."""
if ref.sample_rows and "MicL" in ref.channels:
i, seen = ref.channels.index("MicL"), False
for row in ref.sample_rows:
p = _printed_number(row[i]) if len(row) == len(ref.channels) else None
if p is not None:
if abs(p[0]) > 1.0:
return "dB(L)"
seen = True
if seen:
return "psi(L)"
return ref.event_units or ""
def _mic_converter(ref: XmlReport, sfm: SfmSide) -> Optional[Callable[[int], float]]:
units = ref.event_units or ""
units = _mic_table_units(ref)
d = sfm.mic_divisor
if "dB(L)" in units:
return lambda c: mic_count_to_db(c / d)
@@ -293,7 +310,11 @@ def _compare_scalar(tag: str, printed: str, sfm: SfmSide, ref: XmlReport) -> Fie
if tag in ("MicLPSPL", "MicTriggerLevel"):
# A printed value that states its unit is compared in that unit:
# K441LA17.IN0W's Units say psi(L), its MicTriggerLevel "125.0 dB(L)".
units = printed if ("dB(L)" in printed or "psi(L)" in printed) else (ref.event_units or "")
# Else the field's own <Units>, then the event's line: 7 DL2 reports
# print the mic peak in dB under a psi line, 3 the reverse (2026-11-09).
own = ref.units.get(tag) or ""
units = (printed if ("dB(L)" in printed or "psi(L)" in printed)
else own if ("dB(L)" in own or "psi(L)" in own) else (ref.event_units or ""))
key = (f"{tag} dB(L)" if "dB(L)" in units else
f"{tag} psi(L)" if "psi(L)" in units else None)
value = sfm.values.get(key) if key else None
+44 -2
View File
@@ -17,7 +17,10 @@ from dataclasses import dataclass
from typing import Callable
from .bw_xml_report import XmlReport
from .decode_check import FieldResult, SfmSide, _printed_number, series_pairs, matches_printed
from .decode_check import (FieldResult, SfmSide, _mic_table_units, _printed_number, series_pairs,
matches_printed)
from .event_file_io import _MIC_PSI_PER_COUNT
from .waveform_codec import mic_count_to_db
@dataclass(frozen=True)
@@ -155,5 +158,44 @@ UNITS_IS_A_DISPLAY_PREFERENCE = Carveout(
applies=_units_is_a_display_preference,
)
def _other_mic_unit(sfm: SfmSide, units: str):
"""SFM's mic value in the unit the report did NOT say, as Blastware renders it."""
d = sfm.mic_divisor
if "dB(L)" in units:
return lambda c: c * _MIC_PSI_PER_COUNT / d
if "psi(L)" in units:
return lambda c: mic_count_to_db(c / d)
return None
def _mic_units_mixed(sfm: SfmSide, ref: XmlReport, res: FieldResult) -> bool:
"""Every mic cell SFM disagrees with is SFM's own value in the other unit."""
counts = sfm.counts.get("MicL") or []
if res.field == "MicLPSPL":
own = ref.units.get("MicLPSPL") or ""
alt = _other_mic_unit(sfm, own if ("dB(L)" in own or "psi(L)" in own) else (ref.event_units or ""))
peak = max((abs(c) for c in counts), default=None)
return alt is not None and peak is not None and not _differs(alt(peak), res.bw or "")
got = series_pairs(sfm, ref, res.field)
alt = _other_mic_unit(sfm, _mic_table_units(ref))
if got is None or got[1] or alt is None:
return False
differing = [(j, cell) for j, cell, v in got[0] if _differs(v, cell)]
return bool(differing) and all(j < len(counts) and not _differs(alt(counts[j]), cell)
for j, cell in differing)
MIC_UNITS_MIXED = Carveout(
id="mic-units-mixed",
fields=("MicLPSPL", "samples.MicL"),
evidence=("Blastware's dB(L) / psi(L) labels do not hold for the mic on every report: 7 DL2 "
"reports print the mic peak in dB under a psi line, 3 the reverse, and some mix the "
"two inside one column -- K441L9IN.OT0W prints psi '0.000' / '-0.000' for counts of 1 "
"to 3 in a dB table, S353JTHU.DT0W psi rows then dB rows. On 19 DL2 events (14 "
"sample tables, 5 peaks) every mic cell SFM disagrees with is SFM's own value in the "
"other unit; a cell matching neither is still a mismatch. 2026-11-09."),
applies=_mic_units_mixed,
)
CARVEOUTS: tuple[Carveout, ...] = (SATURATION, INTERVAL_COUNT_IS_DURATION,
UNITS_IS_A_DISPLAY_PREFERENCE)
UNITS_IS_A_DISPLAY_PREFERENCE, MIC_UNITS_MIXED)
BIN
View File
Binary file not shown.
File diff suppressed because it is too large. Load diff
BIN
View File
Binary file not shown.
File diff suppressed because it is too large. Load diff
BIN
View File
Binary file not shown.
File diff suppressed because it is too large. Load diff
+39
View File
@@ -505,3 +505,42 @@ def test_a_range_1_mic_matches_blastware():
res = {r.field: r for r in compare(sfm_side(path.read_bytes()), ref, CARVEOUTS)}
for f in ("MicLPSPL", "samples.MicL"):
assert res[f].verdict == "match", (f, res[f])
# ── The unit Blastware printed, field by field (2026-11-09) ─────────────────
# A report's event Units line does not always say what its mic values are in:
# 7 DL2 reports print the mic peak in dB under a psi line, 3 the reverse, and
# S353JTHU prints its sample table in dB under psi on both. The peak carries
# its own unit, and a mic table's cells are unmistakable (dB >= 60, psi < 1).
_UL = FIX.parent / "mic-units-11-09-26"
def _res(path, side=None):
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
return {r.field: r for r in compare(side or sfm_side(path.read_bytes()), ref, CARVEOUTS)}
@pytest.mark.parametrize("path,field", [
(_UL / "K441L9IN.OT0W", "MicLPSPL"), # psi line; the peak in dB, saying so
(_UL / "K888JOU7.8K0H", "MicLPSPL"), # the same on a histogram
])
def test_a_mic_peak_is_read_in_its_own_unit(path, field):
assert _res(path)[field].verdict == "match", _res(path)[field]
@pytest.mark.parametrize("path", [
_UL / "K441L9IN.OT0W", # a dB table with psi cells ("0.000", "-0.000") for counts of 1 to 3
_UL / "S353JTHU.DT0W", # psi rows, then dB rows, all under a psi line
])
def test_a_mic_column_mixing_dB_and_psi_is_accepted(path):
r = _res(path)["samples.MicL"]
assert (r.verdict, r.carveout) == ("accepted", "mic-units-mixed"), r
def test_the_mixed_units_carveout_needs_every_cell_in_one_unit_or_the_other():
path = _UL / "S353JTHU.DT0W"
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
i = ref.channels.index("MicL")
ref.sample_rows[0][i] = "50.00" # neither SFM's dB nor its psi
res = {r.field: r for r in compare(sfm_side(path.read_bytes()), ref, CARVEOUTS)}
assert res["samples.MicL"].verdict == "mismatch"