Fix: mask channels below 30 keV in inference and training to prevent misidentification
Below ~30 keV the detector signal is dominated by X-ray fluorescence (L-shell) and artifacts not modelled in training data. This spurious low-energy continuum caused the model to misidentify Am-241 as Th-232/U-235. Masking channels <30 keV before inference fixes Am-241 detection from 2% to 99%. Same masking applied in the synthetic spectrum generator for consistent retraining. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@ -307,6 +307,12 @@ class SpectrumGenerator:
|
||||
# Subtract and clip — same as inference: net = clip(rate - bg_rate, 0, inf)
|
||||
spectrum = np.maximum(spectrum - bg_spectrum2, 0)
|
||||
|
||||
# Mask channels below ~30 keV — below this energy the detector signal is
|
||||
# dominated by X-ray fluorescence and artefacts not modelled in training.
|
||||
min_channel = max(0, int((30.0 - self.detector_config.calibration_offset_kev)
|
||||
/ self.detector_config.calibration_slope_kev))
|
||||
spectrum[:min_channel] = 0
|
||||
|
||||
# Normalize if requested
|
||||
if config.normalize:
|
||||
spectrum = normalize_spectrum(spectrum, config.normalization_method)
|
||||
|
||||
Reference in New Issue
Block a user