From 7a58bad28dd248a6763fd8e585d572397d93dd14 Mon Sep 17 00:00:00 2001 From: serversdown Date: Mon, 2 Nov 2026 14:31:23 -0500 Subject: [PATCH] feat(decode): a Blastware file's job number, and whether Blastware shows it The setup block has Series IV's 0x1A layout here too: report flags at k - 9 (bit 0x02 = job number shown) and the number, uint16 BE, at k - 8, kept while switched off. The flag matches Blastware's JobNumber on 2,997 / 2,997 DL2 events that print one and 66,986 / 66,986 that don't. Every printed value is 1 and matches; hidden ones hold real numbers (802, 1012, 1013, 622), so the value is only proven for 1. - ProjectInfo.job_number_enabled / job_number, named as in micromate.setup_block. - write_event_hdf5 stores both as .h5 attrs when read (additive). - The checker reports the number only when shown, and scores a number only SFM shows as a mismatch. The old test that pinned JobNumber as sfm_blank now checks only the ZC cases it also covered. Not carried into the DB, the API or the PDF report yet (needs a column). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9 --- minimateplus/decode_check.py | 7 +- minimateplus/event_file_io.py | 23 +++- minimateplus/models.py | 2 + sfm/event_hdf5.py | 5 + .../job-number-11-02-26/K557I55Y.I20H | Bin 0 -> 1858 bytes .../job-number-11-02-26/K557I55Y_I20H_XML.XML | 116 +++++++++++++++++ .../job-number-11-02-26/T438I4V5.DJ0H | Bin 0 -> 1544 bytes .../job-number-11-02-26/T438I4V5_DJ0H_XML.XML | 117 ++++++++++++++++++ tests/test_bw_file_fields.py | 27 ++++ tests/test_decode_check.py | 21 +++- 10 files changed, 312 insertions(+), 6 deletions(-) create mode 100755 tests/fixtures/job-number-11-02-26/K557I55Y.I20H create mode 100755 tests/fixtures/job-number-11-02-26/K557I55Y_I20H_XML.XML create mode 100755 tests/fixtures/job-number-11-02-26/T438I4V5.DJ0H create mode 100755 tests/fixtures/job-number-11-02-26/T438I4V5_DJ0H_XML.XML diff --git a/minimateplus/decode_check.py b/minimateplus/decode_check.py index 6133d77..0c19fdd 100644 --- a/minimateplus/decode_check.py +++ b/minimateplus/decode_check.py @@ -36,7 +36,7 @@ class SfmSide: event: Event values: dict[str, object] # reference tag -> SFM's value; absent or None = blank notes: list[str] # non-empty user-note slots, in order - job_number: Optional[str] # None until the decoder reads it + job_number: Optional[str] # only when the file says Blastware shows it channels: list[str] # channels with decoded data, in Tran/Vert/Long/MicL order counts: dict[str, list[int]] # waveform samples or histogram interval peaks geo_ips_per_count: float = GEO_IPS_PER_COUNT # at the event's range, as SFM read it @@ -78,7 +78,7 @@ def sfm_side(raw: bytes) -> SfmSide: values=values, notes=[v for v in (pi.project, pi.client, pi.operator, pi.sensor_location) if v] if pi is not None else [], - job_number=None, + job_number=str(pi.job_number) if pi is not None and pi.job_number_enabled else None, channels=[ch for ch in _CHANNELS if counts[ch]], counts=counts, geo_ips_per_count=_GEO_FS_BY_RANGE.get(ev.geo_range, _GEO_NORMAL_FS_INS) / _GEO_INT16_FS, @@ -289,6 +289,9 @@ def compare(sfm: SfmSide, ref: XmlReport, carveouts: Sequence["Carveout"] = ()) if sfm.job_number is None else FieldResult("JobNumber", "match" if _same_text(sfm.job_number, ref.job_number) else "mismatch", ref.job_number, sfm.job_number)) + elif sfm.job_number is not None: + # SFM says the job number is shown; Blastware printed none. + out.append(FieldResult("JobNumber", "mismatch", None, sfm.job_number)) out.append(FieldResult("Channels", "match" if ref.channels == sfm.channels else "mismatch", " ".join(ref.channels), " ".join(sfm.channels))) if ref.sample_rows is not None: diff --git a/minimateplus/event_file_io.py b/minimateplus/event_file_io.py index 7907e29..dd486b3 100644 --- a/minimateplus/event_file_io.py +++ b/minimateplus/event_file_io.py @@ -996,8 +996,29 @@ def _setup_notes(raw: bytes) -> ProjectInfo: text = [p.decode("ascii", errors="replace").strip() or None for p in parts] text += [None] * (2 + 2 * _NOTE_SLOTS - len(text)) project, client, operator, location = text[2:2 + 2 * _NOTE_SLOTS:2] + enabled, number = _setup_job_number(raw, k) return ProjectInfo(setup_name=text[0], project=project, client=client, - operator=operator, sensor_location=location) + operator=operator, sensor_location=location, + job_number_enabled=enabled, job_number=number) + + +# The job number, in Series IV's 0x1A layout ([39] report flags, [40:42] the +# number): flags at k - 9, bit 0x02 = shown; the number, uint16 BE, at k - 8, +# kept while switched off. The flag matches Blastware's JobNumber on 2,997 / +# 2,997 DL2 events that print one and 66,986 / 66,986 that don't, and every +# printed value matches (all are 1; measured 2026-11-02). +_REPORT_FLAGS_BEFORE_NAME = 9 +_JOB_NUMBER_BEFORE_NAME = 8 +_JOB_NUMBER_ON = 0x02 + + +def _setup_job_number(raw: bytes, k: int) -> tuple[Optional[bool], Optional[int]]: + """(shown, number) from the setup block whose name starts at k.""" + if k < _REPORT_FLAGS_BEFORE_NAME: + return None, None + flags = raw[k - _REPORT_FLAGS_BEFORE_NAME] + j = k - _JOB_NUMBER_BEFORE_NAME + return bool(flags & _JOB_NUMBER_ON), int.from_bytes(raw[j:j + 2], "big") # The geophone range sits in the setup's channel blocks, which follow the diff --git a/minimateplus/models.py b/minimateplus/models.py index 81eb9ea..6096342 100644 --- a/minimateplus/models.py +++ b/minimateplus/models.py @@ -379,6 +379,8 @@ class ProjectInfo: operator: Optional[str] = None # operator / user name sensor_location: Optional[str] = None # sensor location string notes: Optional[str] = None # extended notes + job_number_enabled: Optional[bool] = None # Blastware prints the job number + job_number: Optional[int] = None # kept while switched off # ── Compliance Config ────────────────────────────────────────────────────────── diff --git a/sfm/event_hdf5.py b/sfm/event_hdf5.py index bde0e28..f8c3a4e 100644 --- a/sfm/event_hdf5.py +++ b/sfm/event_hdf5.py @@ -32,6 +32,8 @@ Layout written to `.h5`: client str operator str sensor_location str + job_number int (only when read; kept while not shown) + job_number_enabled bool (Blastware prints the job number) peak_tran_ips float (from 0C; authoritative) peak_vert_ips float peak_long_ips float @@ -257,6 +259,9 @@ def write_event_hdf5( attrs["client"] = (pi.client if pi else "") or "" attrs["operator"] = (pi.operator if pi else "") or "" attrs["sensor_location"] = (pi.sensor_location if pi else "") or "" + if pi is not None and getattr(pi, "job_number", None) is not None: + attrs["job_number"] = int(pi.job_number) + attrs["job_number_enabled"] = bool(pi.job_number_enabled) attrs["peak_tran_ips"] = float(pv.tran if pv and pv.tran is not None else 0.0) attrs["peak_vert_ips"] = float(pv.vert if pv and pv.vert is not None else 0.0) attrs["peak_long_ips"] = float(pv.long if pv and pv.long is not None else 0.0) diff --git a/tests/fixtures/job-number-11-02-26/K557I55Y.I20H b/tests/fixtures/job-number-11-02-26/K557I55Y.I20H new file mode 100755 index 0000000000000000000000000000000000000000..f56537a732086860cd297898c3d9094727d56d17 GIT binary patch literal 1858 zcma)+ZERCz6vxl)I(oUc?R{?P_JQDdIw5WdrRzF2aRc@iMLS&Fi$R5O?XFv4+>*8! zB_Sa(Bt{L1l87c#aTud6!GK?IUE&85d|8)Z6cS{eo8x5&y?q;lK(_07x-pI61LyYK zr+0hKdH%n1&Mg7%5WrR~5>>RQ+6$Jo;3$B$_UGG;IZn2CI2k~kf)W9kaRPKe0hsVo za4mpBfGzjVj6vTLXlQ<-s;U~EIwAvSI>TJaW)uHau$Dm()~h#IEbl)dUkXjj8wWnGIJ=uxy_AhMQj z)dFtJ*W{)RN;ujR>J9BxRA^I!5$X>GlxQ%dp^i|1djEeYMpbyLXq$Uc3^czURkbd) zi*7?z5n%mWbpU*2*q8ROqTwS4tsp@e6qyP*Ggbq(oIN%Ru*n}E32N?qx7K4BzwZHG zIqvR6$cK+A?*`u*jPi%H?uUju-px`It7=2^6F%c0l{#xFR<%#ay&qwhL% z8j35yFz`fX?4I}j87TIFaSErM8QXsny}N!KimSkwUD%Jxz>0249)YtsWH|Zo9F%es zEDcx7)q<6xmfQVrzIW{6jSIhCni&7<^3?SkdMZ0TbNlYSSz^vSN_~YEeyJeZY<4># zvg~j;mN9dp<5$@s%Y;ahWVhL@q9_Og&s&x(A@8b9-U=BEJ(-9P565ByUk?rr#s*@s zp?Ex=Na(trGK@3;rX((h>?(CQm^)l9*@YSL;!y8O;0Z55TH1o#hVjKoI9E5%@eHgs zt^F5ySAt6rr( zUJ$G{ny+^c1C3tg{4b*o+lr6cQjR&l9iI4Ope46Duzr0 z1B0>H@X%0vbR;o0rt5Qtlun~`nPat*UCh|Z3WdfILO4`Q7!knOB%IqcPt*dBamhSU z1J{6^L7H11Gnzw3KDbDo*MC2EY5dQL$*Jo%lc_w*y*cd9s`>tiqBY+ig2%81F{p*^ zU^Q8L>(wR&qo5?cEcz8q4{y4HrPw(pMFQQ}x5d|w|$a7#4559Al=6#v; zo;YSu=ObfR(>aV|@%YK*a@m}RN4_iS&J-Mehm=qvTQM4)854myI8l6UhfF^IsKia3 z6IW8%96O%{vn!WNdU#zo_UzoBhJ9kmGD>VXIaaLZ{Y02Uwr+p6UzYmn>Mv7rIkgap z!D!RSVdSQB%k@-bht@%zChEko${S0Q&%|o6dBgEfh_U^JDa?_|P0yc>@pvJJF*lv7 iIj9>i_g3G*N>eEQqZyXl`GwyUZt=Ipg@Xg-tN#H;Cl|;7 literal 0 HcmV?d00001 diff --git a/tests/fixtures/job-number-11-02-26/K557I55Y_I20H_XML.XML b/tests/fixtures/job-number-11-02-26/K557I55Y_I20H_XML.XML new file mode 100755 index 0000000..9d649bd --- /dev/null +++ b/tests/fixtures/job-number-11-02-26/K557I55Y_I20H_XML.XML @@ -0,0 +1,116 @@ + + +8.0 +Full Histogram +BE9557 +V 10.72-8.17 MiniMate Plus +K557I55Y.I20H +12:54:02 +2019-10-07 +12:54:28 +2019-10-07 + +Tran +Vert +Long +MicL + +1.00 +1 minute +1024 sps +6.4 Volts +January 18, 2019 by Instantel +in/s and dB(L) +Landmark - The Standard - Atherton Hotel +Landmark Constructors +Terra-Mechanics, Inc. - D. Bartholomae +Loc 2- Atherton Hotel - 125 S. Atherton + +10.000 +in/s + + +0.425 +in/s + + +0.010 +in/s + + +0.485 +in/s + + +>100 +Hz + + +>100 +Hz + + +>100 +Hz + +12:54:28 +2019-10-07 +12:54:28 +2019-10-07 +12:54:28 +2019-10-07 + +0.645 +in/s + +12:54:28 +2019-10-07 +Linear Weighting + +91.5 +dB(L) + +12:54:28 +2019-10-07 + +>100 +Hz + +7.9 Hz. +3.4 +Passed +7.4 Hz. +3.7 +Passed +7.7 Hz. +3.9 +Passed +20.1 Hz. +585 mv +Passed + + +2019-10-07 12:54:01 - 2019-10-07 12:54:28 "Event Recorded Modem Exit" + + + Tran Peak in/s + Tran Freq Hz + Vert Peak in/s + Vert Freq Hz + Long Peak in/s + Long Freq Hz + Geo PVS in/s + MicL Peak psi(L) + MicL Peak dB(L) + MicL Freq Hz + + + + +0.425>1000.010>1000.485>1000.6450.00091.48>100 + + + + + + diff --git a/tests/fixtures/job-number-11-02-26/T438I4V5.DJ0H b/tests/fixtures/job-number-11-02-26/T438I4V5.DJ0H new file mode 100755 index 0000000000000000000000000000000000000000..9b25a4070ebe04466ed1aa005939bd1b8e58ccf5 GIT binary patch literal 1544 zcma)+QA}G^7{~t?Zr9ru=xxi8Ory6DxYY_~Mhtvw=FqIhxkXXQ@R%pgpAyaRo*B)x^ zu!7l_%AUmMJMf&ptIyZnhm-?M%~>rNuzzu226&b}wDEqeKiJ*f=jrMNx;j0*UesF5 zi~p~N67Of+{UgRCSsDu~q7aBpC%5y4y=Z3vmfAqosjURHuoI7YFztVH@SDl2FoPMN z!lg&JAnipooQMkJVkDl3O7bxwC@Rw@5J<#d6C+ALCS)lk#E%LANl}CjAs7iuM@3;I z9E){K1jdHQH5!iyUJS(~QKtBS@VszHiX7i79F`*_9G-F65)<9G4g6y zmLf?bfbtJ{s9Yi;CF3%JqLlP#74?Y~VYgSCQwb|lTsA(8+5B%Pq8t^Y!jZTlCP^DI z^%Q(Lt_ulxlb|R_Hwmr6tCNI4XZGV~I#_ht@dDbITN(o6XZ$?N z16(Hy6*zxNXg>YHcQ*?c7mCH=?|&{`zp++Y-zfjHdFKw#mUat1lgZ3kthTzkh6cNx zcaS-^&Ea%7c%HZ0?F|j}^>sFz&1$u99LI-JqTlCjaX?j9SMs@BCY#BoGnu)$xokF@ zpU>x43#%1XRZAs0|NH>Y=!La%#zV6(T4kPRX#FhDqI9rEqw8JAg~2M*6EzR(OvB7D z>I|Om-xiwRdGFih-25;3LZSG_wWaGfS4+1y%9~qvd3Mbu_}Cq0&T6yO8#GRrv(eSK zv$2tSt+`wTM^JWNBO)XMvRL?!U!R`vdEE}XT3N~Ea&zg-x%BL8dNxf^*=#PKFRZMt zt?4|B#=dr_x2zwILuLC9nq3&}H--&@k#r zDE*F;WM()8&SI);mT%uG^V|=q7l%4o4vd9jmW;fuR_tov?%k4}?c3s}{~|(D{{avA Bf)@Y) literal 0 HcmV?d00001 diff --git a/tests/fixtures/job-number-11-02-26/T438I4V5_DJ0H_XML.XML b/tests/fixtures/job-number-11-02-26/T438I4V5_DJ0H_XML.XML new file mode 100755 index 0000000..03c6b02 --- /dev/null +++ b/tests/fixtures/job-number-11-02-26/T438I4V5_DJ0H_XML.XML @@ -0,0 +1,117 @@ + + +8.0 +Full Histogram +BE18438 +V 10.72-8.17 MiniMate Plus +T438I4V5.DJ0H +16:48:55 +2019-10-01 +16:48:57 +2019-10-01 + +Tran +Vert +Long +MicL + +1.00 +1 minute +1024 sps +6.8 Volts +September 3, 2019 by Instantel +in/s and dB(L) +1 +Univ of Pitt - Scaife Hall-UPMC - Loc 2 +P J Dick, Inc. +Terra-Mechanics, Inc. - D. Harrison +Unit #2 - Station #2 - Loc 2 + +10.000 +in/s + + +0.550 +in/s + + +1.335 +in/s + + +0.270 +in/s + + +N/A +Hz + + +N/A +Hz + + +N/A +Hz + +16:48:57 +2019-10-01 +16:48:57 +2019-10-01 +16:48:57 +2019-10-01 + +1.394 +in/s + +16:48:57 +2019-10-01 +Linear Weighting + +114.4 +dB(L) + +16:48:57 +2019-10-01 + +51 +Hz + +7.5 Hz. +4.0 +Passed +7.5 Hz. +3.9 +Passed +7.6 Hz. +3.7 +Passed +0.0 Hz. +0 mv +Check + + +2019-10-01 16:48:54 - 2019-10-01 16:48:57 "Event Recorded Modem Exit" + + + Tran Peak in/s + Tran Freq Hz + Vert Peak in/s + Vert Freq Hz + Long Peak in/s + Long Freq Hz + Geo PVS in/s + MicL Peak psi(L) + MicL Peak dB(L) + MicL Freq Hz + + + + +0.550N/A1.335N/A0.270N/A1.3940.002114.451 + + + + + + diff --git a/tests/test_bw_file_fields.py b/tests/test_bw_file_fields.py index fc57beb..1dc7b6a 100644 --- a/tests/test_bw_file_fields.py +++ b/tests/test_bw_file_fields.py @@ -276,3 +276,30 @@ def test_an_imported_file_and_the_backfill_store_its_range(tmp_path): "--db-path", str(tmp_path / "seismo_relay.db"), "--force"]) == 0 with h5py.File(h5, "r") as f: assert f.attrs["geo_range"] == "sensitive" + + +# ── The job number ────────────────────────────────────────────────────────── +# Series IV's 0x1A layout again: report flags at k - 9 (bit 0x02 = job number +# shown) and the number, uint16 BE, at k - 8, kept while switched off. The flag +# matches Blastware's JobNumber on 2,997 / 2,997 DL2 events that print one and +# 66,986 / 66,986 that don't (measured 2026-11-02). Every printed value is 1; +# hidden ones hold real numbers (802, 1012, 1013, 622). + +@pytest.mark.parametrize("rel,enabled,number", [ + ("decode-checker-10-29-26/T1905KDW.5F0W", True, 1), # XML JobNumber 1 + ("job-number-11-02-26/T438I4V5.DJ0H", True, 1), # histogram, XML JobNumber 1 + ("job-number-11-02-26/K557I55Y.I20H", False, 802), # no JobNumber in the XML + ("decode-checker-10-29-26/R352HFZ7.530H", False, 1), +]) +def test_job_number_comes_from_the_file(rel, enabled, number): + pi = read_blastware_file(_FIX / rel).project_info + assert (pi.job_number_enabled, pi.job_number) == (enabled, number) + + +def test_the_h5_carries_the_job_number(tmp_path): + import h5py + from sfm import event_hdf5 + ev = read_blastware_file(_FIX / "job-number-11-02-26/K557I55Y.I20H") + event_hdf5.write_event_hdf5(tmp_path / "e.h5", ev, serial="BE9557") + with h5py.File(tmp_path / "e.h5", "r") as f: + assert (bool(f.attrs["job_number_enabled"]), int(f.attrs["job_number"])) == (False, 802) diff --git a/tests/test_decode_check.py b/tests/test_decode_check.py index d030611..b9848de 100644 --- a/tests/test_decode_check.py +++ b/tests/test_decode_check.py @@ -86,9 +86,8 @@ def test_an_extra_reference_row_is_a_mismatch_with_detail(): assert "row_length_disagreements=1" in res["samples.Tran"].detail -def test_job_number_na_and_above_range(): - res = _results("T1905KDW.5F0W") - assert res["JobNumber"].verdict == "sfm_blank" +def test_zc_frequency_na_and_above_range(): + res = _results("T1905KDW.5F0W") # its JobNumber: test_the_job_number_matches_blastware assert res["TranZCFreq"].verdict == "no_reference" # N/A assert res["VertZCFreq"].verdict == "sfm_blank" # >100, SFM has no flag yet @@ -172,3 +171,19 @@ def test_a_sensitive_range_event_now_matches(): for f in ("GeoRange", "TranPPV", "VertPPV", "LongPPV", "PeakVectorSum", "samples.Tran", "samples.Vert", "samples.Long"): assert res[f].verdict == "match", (f, res[f]) + + +def test_the_job_number_matches_blastware(): + assert _results("T1905KDW.5F0W", CARVEOUTS)["JobNumber"].verdict == "match" + + +def test_a_hidden_job_number_is_not_reported(): + # Flag off: Blastware prints no JobNumber, and SFM's side reports none either. + assert sfm_side((FIX / "R352HFZ7.530H").read_bytes()).job_number is None + + +def test_a_job_number_only_sfm_shows_is_a_mismatch(): + side = sfm_side((FIX / "R352HFZ7.530H").read_bytes()) + side.job_number = "1" + res = {r.field: r for r in compare(side, parse_xml_report_file(FIX / "R352HFZ7_530H_XML.XML"))} + assert res["JobNumber"].verdict == "mismatch"