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:
@ -48,7 +48,7 @@ const ISOTOPE_LINES = [
|
||||
];
|
||||
|
||||
// Filtrer les lignes dans la plage visible du détecteur (30-3050 keV pour Radiacode 103)
|
||||
const VISIBLE_LINES = ISOTOPE_LINES.filter(l => l.energy_keV >= 30 && l.energy_keV <= 3050);
|
||||
const VISIBLE_LINES = ISOTOPE_LINES.filter(l => l.energy_keV >= 30 && l.energy_keV <= 3000);
|
||||
|
||||
// Global crosshair plugin — vertical dashed line on hover for all charts
|
||||
const CrosshairPlugin = {
|
||||
@ -72,6 +72,50 @@ const CrosshairPlugin = {
|
||||
};
|
||||
Chart.register(CrosshairPlugin);
|
||||
|
||||
// Auto-scale Y axis to visible X range
|
||||
const AutoScaleYPlugin = {
|
||||
id: 'autoScaleY',
|
||||
beforeUpdate(chart) {
|
||||
const xScale = chart.scales?.x;
|
||||
const yScale = chart.scales?.y;
|
||||
if (!xScale || !yScale || xScale.type !== 'linear') return;
|
||||
|
||||
const xMin = xScale.min;
|
||||
const xMax = xScale.max;
|
||||
if (xMin == null || xMax == null) return;
|
||||
|
||||
let yMin = Infinity;
|
||||
let yMax = -Infinity;
|
||||
let count = 0;
|
||||
|
||||
chart.data.datasets.forEach(ds => {
|
||||
for (const pt of ds.data) {
|
||||
const x = Array.isArray(pt) ? pt[0] : pt.x;
|
||||
const y = Array.isArray(pt) ? pt[1] : pt.y;
|
||||
if (x === undefined || y === undefined) continue;
|
||||
if (x >= xMin && x <= xMax) {
|
||||
if (y > 0 && y < yMin) yMin = y;
|
||||
if (y > yMax) yMax = y;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (count === 0 || yMin === Infinity) return;
|
||||
|
||||
const isLog = yScale.type === 'logarithmic';
|
||||
if (isLog) {
|
||||
chart.options.scales.y.min = Math.max(0.5, yMin * 0.7);
|
||||
chart.options.scales.y.max = yMax * 1.5;
|
||||
} else {
|
||||
const padding = (yMax - yMin) * 0.05 || 1;
|
||||
chart.options.scales.y.min = Math.max(0, yMin - padding);
|
||||
chart.options.scales.y.max = yMax + padding;
|
||||
}
|
||||
}
|
||||
};
|
||||
Chart.register(AutoScaleYPlugin);
|
||||
|
||||
// Couleurs par catégorie d'isotope
|
||||
function isotopeLineColor(isotope) {
|
||||
if (["K-40", "Bi-214", "Pb-214", "Ra-226"].includes(isotope)) return "rgba(255,152,0,0.5)"; // Uranium chain - orange
|
||||
|
||||
Reference in New Issue
Block a user