Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/noise_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path

import hamma
from hamma.header.core import _diagnostic_data
from hamma import diagnostic_data

# HAMMA2 fast-channel sample rate. preTriggerSize is a count of fast samples;
# the header's sampleRateFast field is not populated, so use the known rate.
Expand Down Expand Up @@ -92,7 +92,7 @@ def _compute(self, input_data):
pretrigger_ms, self.min_pretrigger_ms)
return None

offset, vmax, vmin, noise = _diagnostic_data(data.voltFast, self.medsize)
offset, vmax, vmin, noise = diagnostic_data(data.voltFast, self.medsize)
vpp = float(vmax) - float(vmin)
snr = vpp / noise if noise else float("nan")
threshold = float(h.data.threshold.iloc[0])
Expand Down
5 changes: 2 additions & 3 deletions tests/python/test_noise_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def load_module(diag_return=(0.1, 4.7, -4.7, 0.035), volt_fast=object(), thresho
mock_brokkr.pipeline.base = mock_base

mock_hamma = MagicMock()
mock_hamma.diagnostic_data.return_value = diag_return
if times_fast is None:
times_fast = np.array(["2026-06-23T21:36:57.000", "2026-06-23T21:36:58.857",
"2026-06-23T21:36:59.000"], dtype="datetime64[ms]")
Expand All @@ -43,7 +44,6 @@ def _col(name):
return col
header.data.__getitem__.side_effect = _col
mock_hamma.Header.return_value = header
mock_core = MagicMock(); mock_core._diagnostic_data.return_value = diag_return

with patch.dict("sys.modules", {
"brokkr": mock_brokkr, "brokkr.pipeline": mock_pipeline,
Expand All @@ -53,7 +53,6 @@ def _col(name):
"brokkr.config.unit": MagicMock(),
"brokkr.config.metadata": MagicMock(),
"hamma": mock_hamma, "hamma.header": MagicMock(),
"hamma.header.core": mock_core,
"notifiers": MagicMock(),
}):
spec = importlib.util.spec_from_file_location("noise_diag", str(PLUGIN_PATH))
Expand Down Expand Up @@ -135,7 +134,7 @@ def test_compute_skips_short_pretrigger():
step.medsize = 200000
step.min_pretrigger_ms = 50
step.logger = MagicMock()
with patch.object(module, "_diagnostic_data") as mock_diag:
with patch.object(module, "diagnostic_data") as mock_diag:
result = step._compute(make_input())
assert result is None
mock_diag.assert_not_called()
Expand Down