fix: resolve 4 fatal bugs — json_to_config, create_config_from_source, Am-241 constant, CLI positional args

This commit is contained in:
2026-05-26 14:57:35 +03:00
parent 38e97213c5
commit 8b0ced4b65
6 changed files with 99 additions and 46 deletions
+5 -2
View File
@@ -312,7 +312,7 @@ class EnergyCalibrator:
filepath : str or Path
Path to the Am-241 binary calibration file (CAM1.DAT or CAM2.DAT).
known_energies : list of float, optional
Known Am-241 line energies in keV. Defaults to [13.8, 17.8, 26.3].
Known Am-241 line energies in keV. Defaults to [13.9, 17.8, 26.3, 59.54].
n_channels : int
Number of channels (default 4096).
@@ -352,8 +352,11 @@ class EnergyCalibrator:
peak_counts = counts_search[peaks]
# Known Am-241 gamma lines (keV)
# Am-241 decays to Np-237; Np K X-rays at 13.9 keV (Kα), 17.8 keV (Kβ),
# 20.8 keV (L-series); Np gamma at 26.3 keV; Np/Am gamma at 59.54 keV.
# Source: LNHb Table de Radionucléides, IAEA nuclear data.
if known_energies is None:
known_energies = [13.0, 17.8, 26.3, 59.54]
known_energies = [13.9, 17.8, 26.3, 59.54]
# Match peaks to known energies using a simpler, more robust
# approach: find the two strongest peaks that span the largest
+4 -4
View File
@@ -151,7 +151,7 @@ def calibrate_from_am241(
Path to the Am-241 binary file (CAM1.DAT or CAM2.DAT).
known_peaks
Mapping of energy_keV -> expected channel. If None, auto-detects
Am-241 peaks at 13.8, 17.8, 26.3 keV.
Am-241 peaks at 13.9, 17.8, 26.3 keV.
n_channels
Number of channels.
@@ -175,7 +175,7 @@ def calibrate_from_am241(
_peak_heights = props["peak_heights"] # noqa: F841
# Known Am-241 gamma lines (keV)
am241_lines = {13.8: None, 17.8: None, 26.3: None}
am241_lines = {13.9: None, 17.8: None, 26.3: None}
if known_peaks:
am241_lines = known_peaks
else:
@@ -220,7 +220,7 @@ def read_am241_calibration(
"""
filepath = Path(filepath)
# Am-241 known peaks (keV): 13.8, 17.8, 26.3, 59.54
# Am-241 known peaks (keV): 13.9, 17.8, 26.3, 59.54
# The spectrum typically has a few prominent peaks
with open(filepath, "rb") as f:
_header = f.read(128)
@@ -232,7 +232,7 @@ def read_am241_calibration(
metadata = {
"source": "Am241",
"calibration_type": "energy",
"known_peaks_keV": [13.8, 17.8, 26.3, 59.54],
"known_peaks_keV": [13.9, 17.8, 26.3, 59.54],
}
return ExpSpectrum(