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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-11-02 14:31:23 -05:00
1 parent 15a27d5921
commit 7a58bad28d
10 files changed
+312 -6

No files matched your search

+5 -2
View File
@@ -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:
+22 -1
View File
@@ -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
+2
View File
@@ -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 ──────────────────────────────────────────────────────────
+5
View File
@@ -32,6 +32,8 @@ Layout written to `<filename>.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)
Binary file not shown.
+116
View File
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<Event>
<FileVersion>8.0</FileVersion>
<EventType>Full Histogram</EventType>
<SerialNumber>BE9557</SerialNumber>
<Version>V 10.72-8.17 MiniMate Plus</Version>
<FileName>K557I55Y.I20H</FileName>
<HistogramStartTime>12:54:02</HistogramStartTime>
<HistogramStartDate>2019-10-07</HistogramStartDate>
<HistogramStopTime>12:54:28</HistogramStopTime>
<HistogramStopDate>2019-10-07</HistogramStopDate>
<Channels>
<Channel>Tran</Channel>
<Channel>Vert</Channel>
<Channel>Long</Channel>
<Channel>MicL</Channel>
</Channels>
<NumberofIntervals>1.00</NumberofIntervals>
<IntervalSize>1 minute</IntervalSize>
<SampleRate>1024 sps</SampleRate>
<BatteryLevel>6.4 Volts</BatteryLevel>
<Calibration>January 18, 2019 by Instantel</Calibration>
<Units>in/s and dB(L)</Units>
<Project>Landmark - The Standard - Atherton Hotel</Project>
<Client>Landmark Constructors</Client>
<UserName>Terra-Mechanics, Inc. - D. Bartholomae</UserName>
<SeisLocation>Loc 2- Atherton Hotel - 125 S. Atherton</SeisLocation>
<GeoRange>
<Value>10.000</Value>
<Units>in/s</Units>
</GeoRange>
<TranPPV>
<Value>0.425</Value>
<Units>in/s</Units>
</TranPPV>
<VertPPV>
<Value>0.010</Value>
<Units>in/s</Units>
</VertPPV>
<LongPPV>
<Value>0.485</Value>
<Units>in/s</Units>
</LongPPV>
<TranZCFreq>
<Value>&gt;100</Value>
<Units>Hz</Units>
</TranZCFreq>
<VertZCFreq>
<Value>&gt;100</Value>
<Units>Hz</Units>
</VertZCFreq>
<LongZCFreq>
<Value>&gt;100</Value>
<Units>Hz</Units>
</LongZCFreq>
<TranPeakTime>12:54:28</TranPeakTime>
<TranPeakDate>2019-10-07</TranPeakDate>
<VertPeakTime>12:54:28</VertPeakTime>
<VertPeakDate>2019-10-07</VertPeakDate>
<LongPeakTime>12:54:28</LongPeakTime>
<LongPeakDate>2019-10-07</LongPeakDate>
<PeakVectorSum>
<Value>0.645</Value>
<Units>in/s</Units>
</PeakVectorSum>
<PeakVectorSumTime>12:54:28</PeakVectorSumTime>
<PeakVectorSumDate>2019-10-07</PeakVectorSumDate>
<Microphone>Linear Weighting</Microphone>
<MicLPSPL>
<Value>91.5</Value>
<Units>dB(L)</Units>
</MicLPSPL>
<MicLTime>12:54:28</MicLTime>
<MicLDate>2019-10-07</MicLDate>
<MicLZCFreq>
<Value>&gt;100</Value>
<Units>Hz</Units>
</MicLZCFreq>
<TranTestFreq>7.9 Hz.</TranTestFreq>
<TranTestRatio>3.4</TranTestRatio>
<TranTestResults>Passed</TranTestResults>
<VertTestFreq>7.4 Hz.</VertTestFreq>
<VertTestRatio>3.7</VertTestRatio>
<VertTestResults>Passed</VertTestResults>
<LongTestFreq>7.7 Hz.</LongTestFreq>
<LongTestRatio>3.9</LongTestRatio>
<LongTestResults>Passed</LongTestResults>
<MicLTestFreq>20.1 Hz.</MicLTestFreq>
<MicLTestAmplitude>585 mv</MicLTestAmplitude>
<MicLTestResults>Passed</MicLTestResults>
<UsbSummaryChannels>
</UsbSummaryChannels>
<MonitorLog>2019-10-07 12:54:01 - 2019-10-07 12:54:28 &quot;Event Recorded Modem Exit&quot;</MonitorLog>
<HistogramData>
<HistogramDataColumnTitle>
<ColumnTitle> Tran Peak in/s </ColumnTitle>
<ColumnTitle> Tran Freq Hz </ColumnTitle>
<ColumnTitle> Vert Peak in/s </ColumnTitle>
<ColumnTitle> Vert Freq Hz </ColumnTitle>
<ColumnTitle> Long Peak in/s </ColumnTitle>
<ColumnTitle> Long Freq Hz </ColumnTitle>
<ColumnTitle> Geo PVS in/s </ColumnTitle>
<ColumnTitle> MicL Peak psi(L) </ColumnTitle>
<ColumnTitle> MicL Peak dB(L) </ColumnTitle>
<ColumnTitle> MicL Freq Hz </ColumnTitle>
</HistogramDataColumnTitle>
<HistogramDataIntervals>
<Time>2019-10-07 12:54:28</Time>
<Row>
<Cell>0.425</Cell><Cell>&gt;100</Cell><Cell>0.010</Cell><Cell>&gt;100</Cell><Cell>0.485</Cell><Cell>&gt;100</Cell><Cell>0.645</Cell><Cell>0.000</Cell><Cell>91.48</Cell><Cell>&gt;100</Cell></Row>
</HistogramDataIntervals>
</HistogramData>
<HistogramDataUsbChannels>
</HistogramDataUsbChannels>
</Event>
Binary file not shown.
+117
View File
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<Event>
<FileVersion>8.0</FileVersion>
<EventType>Full Histogram</EventType>
<SerialNumber>BE18438</SerialNumber>
<Version>V 10.72-8.17 MiniMate Plus</Version>
<FileName>T438I4V5.DJ0H</FileName>
<HistogramStartTime>16:48:55</HistogramStartTime>
<HistogramStartDate>2019-10-01</HistogramStartDate>
<HistogramStopTime>16:48:57</HistogramStopTime>
<HistogramStopDate>2019-10-01</HistogramStopDate>
<Channels>
<Channel>Tran</Channel>
<Channel>Vert</Channel>
<Channel>Long</Channel>
<Channel>MicL</Channel>
</Channels>
<NumberofIntervals>1.00</NumberofIntervals>
<IntervalSize>1 minute</IntervalSize>
<SampleRate>1024 sps</SampleRate>
<BatteryLevel>6.8 Volts</BatteryLevel>
<Calibration>September 3, 2019 by Instantel</Calibration>
<Units>in/s and dB(L)</Units>
<JobNumber>1</JobNumber>
<Project>Univ of Pitt - Scaife Hall-UPMC - Loc 2</Project>
<Client>P J Dick, Inc.</Client>
<UserName>Terra-Mechanics, Inc. - D. Harrison</UserName>
<Seis.Loc>Unit #2 - Station #2 - Loc 2</Seis.Loc>
<GeoRange>
<Value>10.000</Value>
<Units>in/s</Units>
</GeoRange>
<TranPPV>
<Value>0.550</Value>
<Units>in/s</Units>
</TranPPV>
<VertPPV>
<Value>1.335</Value>
<Units>in/s</Units>
</VertPPV>
<LongPPV>
<Value>0.270</Value>
<Units>in/s</Units>
</LongPPV>
<TranZCFreq>
<Value>N/A</Value>
<Units>Hz</Units>
</TranZCFreq>
<VertZCFreq>
<Value>N/A</Value>
<Units>Hz</Units>
</VertZCFreq>
<LongZCFreq>
<Value>N/A</Value>
<Units>Hz</Units>
</LongZCFreq>
<TranPeakTime>16:48:57</TranPeakTime>
<TranPeakDate>2019-10-01</TranPeakDate>
<VertPeakTime>16:48:57</VertPeakTime>
<VertPeakDate>2019-10-01</VertPeakDate>
<LongPeakTime>16:48:57</LongPeakTime>
<LongPeakDate>2019-10-01</LongPeakDate>
<PeakVectorSum>
<Value>1.394</Value>
<Units>in/s</Units>
</PeakVectorSum>
<PeakVectorSumTime>16:48:57</PeakVectorSumTime>
<PeakVectorSumDate>2019-10-01</PeakVectorSumDate>
<Microphone>Linear Weighting</Microphone>
<MicLPSPL>
<Value>114.4</Value>
<Units>dB(L)</Units>
</MicLPSPL>
<MicLTime>16:48:57</MicLTime>
<MicLDate>2019-10-01</MicLDate>
<MicLZCFreq>
<Value>51</Value>
<Units>Hz</Units>
</MicLZCFreq>
<TranTestFreq>7.5 Hz.</TranTestFreq>
<TranTestRatio>4.0</TranTestRatio>
<TranTestResults>Passed</TranTestResults>
<VertTestFreq>7.5 Hz.</VertTestFreq>
<VertTestRatio>3.9</VertTestRatio>
<VertTestResults>Passed</VertTestResults>
<LongTestFreq>7.6 Hz.</LongTestFreq>
<LongTestRatio>3.7</LongTestRatio>
<LongTestResults>Passed</LongTestResults>
<MicLTestFreq>0.0 Hz.</MicLTestFreq>
<MicLTestAmplitude>0 mv</MicLTestAmplitude>
<MicLTestResults>Check</MicLTestResults>
<UsbSummaryChannels>
</UsbSummaryChannels>
<MonitorLog>2019-10-01 16:48:54 - 2019-10-01 16:48:57 &quot;Event Recorded Modem Exit&quot;</MonitorLog>
<HistogramData>
<HistogramDataColumnTitle>
<ColumnTitle> Tran Peak in/s </ColumnTitle>
<ColumnTitle> Tran Freq Hz </ColumnTitle>
<ColumnTitle> Vert Peak in/s </ColumnTitle>
<ColumnTitle> Vert Freq Hz </ColumnTitle>
<ColumnTitle> Long Peak in/s </ColumnTitle>
<ColumnTitle> Long Freq Hz </ColumnTitle>
<ColumnTitle> Geo PVS in/s </ColumnTitle>
<ColumnTitle> MicL Peak psi(L) </ColumnTitle>
<ColumnTitle> MicL Peak dB(L) </ColumnTitle>
<ColumnTitle> MicL Freq Hz </ColumnTitle>
</HistogramDataColumnTitle>
<HistogramDataIntervals>
<Time>2019-10-01 16:48:57</Time>
<Row>
<Cell>0.550</Cell><Cell>N/A</Cell><Cell>1.335</Cell><Cell>N/A</Cell><Cell>0.270</Cell><Cell>N/A</Cell><Cell>1.394</Cell><Cell>0.002</Cell><Cell>114.4</Cell><Cell>51</Cell></Row>
</HistogramDataIntervals>
</HistogramData>
<HistogramDataUsbChannels>
</HistogramDataUsbChannels>
</Event>
+27
View File
@@ -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)
+18 -3
View File
@@ -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"