RadiaCode-Spectrometer/tools
vhadmin 7e0a78337f Exclude the detector's overflow channel from the likelihood
The RC-110's top channel is an overflow bin: every event above the last
calibrated energy is counted there, so it is not spectral content at that
energy. It shows up as a single-channel spike around a hundred times its
neighbours - 186 counts of 91224 in the indoor background capture, and 618 of
81225 (0.76% of all counts, in one channel) in a new 2.5 h forest background.

No template can reproduce a one-channel spike, so leaving it in the Poisson
likelihood does not invent a nuclide - it hides them. The only way the fit can
cover the spike is by lifting the topmost continuum bump, and that raised
continuum then absorbs genuine counts across the whole high-energy region.

Measured, toggling FIT_OVERFLOW_CHANNELS 0/1 over the real captures:

  capture       residual        reduced chi2    overflow bin
  background    6.8 -> 6.4%     2.18 -> 1.69    0.20% of counts
  forest        9.7 -> 7.2%     3.72 -> 1.28    0.76% of counts
  thorium      11.7 -> 11.5%    1.94 -> 1.84    -
  uranium       8.7 -> 8.5%     2.01 -> 1.84    -

Goodness-of-fit improves on all four and by far the most on the capture with
the largest artefact, which is what ties the effect to this cause. Verdicts
and time-to-identification are unchanged: background 900 s, thorium 120 s,
uranium 300 s, forest 3600 s.

Significance moves modestly in both directions - K-40 rises 3.7 -> 4.6 sigma
on the forest capture but falls 6.8 -> 6.2 on the indoor one. The change is
justified by the artefact being an artefact and by the fit becoming
well-specified (chi2 1.3-1.8 where it was 1.9-3.7), not by larger numbers.
The post-fix figures are the trustworthy ones precisely because the model now
fits.

The peak search already skipped this channel; the template fit, which is what
actually decides identification now, did not.

Also adds:
- host/spectra/forest.csv - a real 9002 s / 81225 count outdoor background
  from a forest, 9.0 cps against the indoor capture's 21.7, now a permanent
  regression case for the low-rate end.
- tools/xml_to_replay_csv.py - converts a RadiaCode XML export into the
  replay harness format. tools/radiacode_to_background.py writes
  counts/second references for the device's background library, which replay
  cannot consume, so there was no way to get an XML export under test.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-04 12:04:21 +02:00
..
radiacode_to_background.py RadiaCode Spectrometer Display: initial public release 2026-08-30 10:25:50 +02:00
xml_to_replay_csv.py Exclude the detector's overflow channel from the likelihood 2026-10-04 12:04:21 +02:00