refactor: refine CLI options and enhance debug logging
- Remove --mode, --transition-type, and --decay-index CLI flags
(parameters now come from ENSDF data or custom JSON input)
- Clarify energy units in all CLI help text (MeV throughout, keV for detector params)
- Enhance logging verbosity:
- -v (INFO): shows source, component initialization, workflow steps
- -vv (DEBUG): shows detailed internals of all spectrum components
(parameters, evaluation counts, input/output ranges)
- Improve CSV headers with element notation (e.g. Tc99 -> Ru99)
- Add CONVENTIONS.md documenting energy unit and logging conventions
- Update TODO.md with completion status
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
# components/fermi.py
|
||||
import logging
|
||||
import numpy as np
|
||||
from scipy.special import loggamma
|
||||
|
||||
@@ -8,14 +9,32 @@ from ..utils import nuclear_radius
|
||||
|
||||
|
||||
class FermiFunction(SpectrumComponent):
|
||||
def __init__(self, Z: int, A: int):
|
||||
def __init__(self, Z: int, A: int, logger: logging.Logger | None = None):
|
||||
super().__init__(logger=logger)
|
||||
self.Z = Z
|
||||
self.A = A
|
||||
self.alphaZ = ALPHA * Z
|
||||
self.gamma = np.sqrt(1.0 - self.alphaZ**2)
|
||||
self.R = nuclear_radius(A)
|
||||
if self._logger:
|
||||
self._logger.debug(
|
||||
"FermiFunction: Z=%d, A=%d, alpha*Z=%.4f, gamma=%.6f, R=%.4f",
|
||||
Z,
|
||||
A,
|
||||
self.alphaZ,
|
||||
self.gamma,
|
||||
self.R,
|
||||
)
|
||||
|
||||
def __call__(self, W: np.ndarray) -> np.ndarray:
|
||||
if self._logger:
|
||||
self._logger.debug(
|
||||
"FermiFunction: evaluating at %d points, W range=[%.4f, %.4f]",
|
||||
len(W),
|
||||
W.min(),
|
||||
W.max(),
|
||||
)
|
||||
|
||||
p = np.sqrt(W**2 - 1.0)
|
||||
|
||||
# Avoid division by zero
|
||||
@@ -43,4 +62,13 @@ class FermiFunction(SpectrumComponent):
|
||||
|
||||
logF = log_prefactor + log_power + log_gamma_abs_sq - log_gamma_denom + log_exp
|
||||
|
||||
return np.asarray(np.exp(logF), dtype=np.float64)
|
||||
result = np.asarray(np.exp(logF), dtype=np.float64)
|
||||
|
||||
if self._logger:
|
||||
self._logger.debug(
|
||||
"FermiFunction: output range=[%.6e, %.6e]",
|
||||
result.min(),
|
||||
result.max(),
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user