Fix pyright type errors and correct paceENSDF Q-value extraction

- nuclear_data.py: Extract Q-value from ground state branch state[7] instead of
  halflife_data (was reading half-life seconds as Q-value)
- nuclear_data.py: Use ground state branch for forbiddenness code, with fallback
- nuclear_data.py: Add None guards for beta_data and pairs
- spectrum.py: Pass Z=config.Z_daughter, A=config.A_number to RadiativeCorrection
- phase_space.py: Add __init__ debug logging (W0, transition_type, m_e, m_nu)
- phase_space.py: Add output range logging in __call__
- phase_space.py: Fix possibly unbound forbid_factor variable
- logging_utils.py: Fix broken get_git_short_hash indentation
- cli.py: Add explicit SpectrumConfig annotation to fix pyright type identity
- cw_extractor.py: Fix T_to_W ndarray→float conversions (6 locations)
- cw_extractor.py: Fix FermiFunction() calls — was passing Z as __call__ arg
- fitter.py: Add explicit dict type annotation for least_squares kwargs
This commit is contained in:
2026-05-05 12:43:43 +03:00
parent 297778d780
commit 3749220efc
7 changed files with 89 additions and 45 deletions
+14 -6
View File
@@ -30,6 +30,11 @@ class PhaseSpace(SpectrumComponent):
"""
super().__init__(logger=logger)
self.tr_type = transition_type
if self._logger:
self._logger.debug(
"PhaseSpace: W0=%.5f, transition_type=%s, m_e=%.6f, m_nu=%.6f",
W0, transition_type, m_e, m_nu,
)
if self.tr_type not in ["A", "F1", "F1U", "F2", "F2U", "F3", "F3U", "F4"]:
raise ValueError(
f"Cannot calculate phase space for forbiddance '{self.tr_type}'.\nShould be [A, F1, F1U, F2, F2U, F3, F3U, F4].\n"
@@ -47,17 +52,20 @@ class PhaseSpace(SpectrumComponent):
phase_space = p_e * w_e * p_nu * w_nu
if self.tr_type in ["A", "F1"]:
forbid_factor = 1
forbid_factor: float | np.ndarray = 1
elif self.tr_type in ["F1U", "F2"]:
forbid_factor = p_nu**2 + p_e**2
elif self.tr_type in ["F2U", "F3"]:
forbid_factor = p_nu**4 + 3 / 10 * p_nu**2 * p_e**2 + p_e**4
elif self.tr_type in ["F3U", "F4"]:
else: # F3U, F4
forbid_factor = (
p_nu**6 + 7 * p_nu**4 * p_e**2 + 7 * p_nu**2 * p_e**4 + p_e**6
)
return np.asarray(phase_space * forbid_factor, dtype=np.float64)
result = np.asarray(phase_space * forbid_factor, dtype=np.float64)
if self._logger:
self._logger.debug(
"PhaseSpace: output range=[%.6e, %.6e]",
result.min(), result.max(),
)
return result