Fix: CsI(Tl) non-linear response correction + detector calibration overhaul

Root cause of Am-241 misidentification: the Radiacode 103's CsI(Tl) crystal
shifts low-energy peaks upward (59.5 keV → 71.6 keV for Am-241) due to
non-proportional scintillation response. The model was trained on theoretical
peak positions and couldn't match the shifted real peaks.

Changes:
- Add inverse CsI(Tl) non-linear correction to inference pipeline
  (radiacode_monitor.py, web/config.py, test_detection.py)
  E_apparent = E_true * (1 + 0.37 * exp(-E_true/100))
  Corrects channel mapping so peaks appear at theoretical energies
- Fix energy calibration: DetectorConfig now uses E = 0.33 + 2.97*ch
  with 1023 channels, matching the real detector (was energy_min=20,
  skip_first_channel=True, different channel width)
- Add K-escape peaks for CsI(Tl) iodine X-ray escape (E - 28.5 keV)
- Add asymmetric peak shapes for low-energy tails (< 200 keV)
- Add log1p normalization in dataset and inference (replaces max-norm)
- Add background-subtracted training mode (subtract_background flag)
- Add low-signal augmentation (0.01-5 Bq activities, 30-300s durations)
- Update docker-compose.yml: batch_size=32, duration=30-300s,
  CSI_NONLINEAR_ALPHA/BETA env vars for detect and web
- Web dashboard: apply CsI correction to displayed spectra
- Various UI fixes (Chart.js width, zoom/pan, isotope lines)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Jacquin Antoine
2026-05-21 17:35:22 +02:00
parent 3b4446b181
commit 0847a3fc80
21 changed files with 913 additions and 278 deletions

View File

@ -41,10 +41,9 @@ function updateCpsChart(labels, values) {
}]
};
const existingMin = cpsChart?.scales.x?.min;
const existingMax = cpsChart?.scales.x?.max;
const xMin = existingMin ?? labels[0];
const xMax = existingMax ?? labels[labels.length - 1];
const panRange = cpsChart?._panRange;
const xMin = panRange ? panRange[0] : labels[0];
const xMax = panRange ? panRange[1] : labels[labels.length - 1];
const options = {
responsive: true,
maintainAspectRatio: false,
@ -114,10 +113,15 @@ function updateCpsChart(labels, values) {
}
}
// Reset zoom
// Reset zoom — restore full time range
document.getElementById('reset-zoom-cps')?.addEventListener('click', () => {
if (cpsChart) {
cpsChart.resetZoom();
delete cpsChart._panRange;
const labels = cpsChart.data.labels;
cpsChart.options.scales.x.min = labels[0];
cpsChart.options.scales.x.max = labels[labels.length - 1];
cpsChart.update();
document.getElementById('reset-zoom-cps').style.display = 'none';
}
});