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:
@ -6,11 +6,11 @@ let bgContinuumData = null;
|
||||
document.getElementById('reset-zoom-bg')?.addEventListener('click', () => {
|
||||
if (bgChart) {
|
||||
bgChart.resetZoom();
|
||||
// After resetZoom, force the scale to full energy range
|
||||
delete bgChart._panRange;
|
||||
const firstPt = bgChart.data.datasets[0]?.data?.[0];
|
||||
const lastPt = bgChart.data.datasets[0]?.data?.[bgChart.data.datasets[0].data.length - 1];
|
||||
const fullMin = firstPt?.x ?? 0;
|
||||
const fullMax = lastPt?.x ?? 3036;
|
||||
const fullMax = lastPt?.x ?? 3000;
|
||||
bgChart.options.scales.x.min = fullMin;
|
||||
bgChart.options.scales.x.max = fullMax;
|
||||
bgChart.update();
|
||||
@ -170,12 +170,12 @@ function updateBackgroundChart(spec) {
|
||||
datasets: datasets,
|
||||
};
|
||||
|
||||
// Preserve pan range (user zoomed), but reset to full range when data refreshes
|
||||
// Preserve pan range only if user has explicitly zoomed/panned
|
||||
const panRange = bgChart?._panRange;
|
||||
const firstX = datasets[0].data[0]?.x;
|
||||
const lastX = datasets[0].data[datasets[0].data.length - 1]?.x;
|
||||
const xMin = panRange ? panRange[0] : (firstX ?? 0);
|
||||
const xMax = panRange ? panRange[1] : (lastX ?? 3036);
|
||||
const firstX = datasets[0].data[0]?.x ?? 0;
|
||||
const lastX = datasets[0].data[datasets[0].data.length - 1]?.x ?? 3000;
|
||||
const xMin = panRange ? panRange[0] : firstX;
|
||||
const xMax = panRange ? panRange[1] : lastX;
|
||||
const options = {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
@ -214,8 +214,8 @@ function updateBackgroundChart(spec) {
|
||||
},
|
||||
y: {
|
||||
type: showLog ? 'logarithmic' : 'linear',
|
||||
min: showLog ? 0.5 : undefined,
|
||||
title: { display: true, text: `Comptages (${showLog ? 'log' : 'lin'})`, color: '#888' },
|
||||
...(showLog ? { min: 0.9 } : {}),
|
||||
ticks: { color: '#888' },
|
||||
grid: { color: '#333' },
|
||||
}
|
||||
@ -229,7 +229,7 @@ function updateBackgroundChart(spec) {
|
||||
} else {
|
||||
bgChart = new Chart(ctx, { type: 'line', data: chartData, ...options });
|
||||
const firstX = datasets[0].data[0]?.x ?? 0;
|
||||
const lastX = datasets[0].data[datasets[0].data.length - 1]?.x ?? 3036;
|
||||
const lastX = datasets[0].data[datasets[0].data.length - 1]?.x ?? 3000;
|
||||
enablePan(bgChart, 'reset-zoom-bg', firstX, lastX);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user