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:
@@ -309,6 +309,7 @@ def _resolve_decay_index(
|
||||
|
||||
e = pe.ENSDF()
|
||||
pairs = e.ensdf_pairs(edata, mode)
|
||||
assert pairs is not None, "paceENSDF returned None for ensdf_pairs"
|
||||
|
||||
matching = [(k, v) for k, v in pairs.items() if str(k[0]) == parent_symbol]
|
||||
|
||||
@@ -378,13 +379,31 @@ def get_decay_info_from_paceENSDF(
|
||||
jpi_data = e.get_parent_jpi(edata, nuclide, decay_idx, mode=mode)
|
||||
beta_data = e.get_beta_minus(edata, nuclide, decay_idx, units="best")
|
||||
|
||||
# Extract Q-value and half-life
|
||||
q_value_keV = 0.0
|
||||
# Extract Q-value from ground state branch (state[7] = endpoint energy in keV)
|
||||
# and half-life from halflife_data
|
||||
endpoint_keV = 0.0
|
||||
half_life_str = "unknown"
|
||||
for k, v in halflife_data.items():
|
||||
q_value_keV = v[0]
|
||||
half_life_str = str(v[2]) if len(v) > 2 else "unknown"
|
||||
break
|
||||
|
||||
if beta_data:
|
||||
for k, v in beta_data.items():
|
||||
for state in v:
|
||||
if state[0] == 0: # ground state branch
|
||||
endpoint_keV = float(state[7])
|
||||
break
|
||||
if endpoint_keV > 0:
|
||||
break
|
||||
|
||||
# No ground state branch — use first available branch
|
||||
if endpoint_keV == 0.0:
|
||||
for k, v in beta_data.items():
|
||||
if v and len(v) > 0:
|
||||
endpoint_keV = float(v[0][7])
|
||||
break
|
||||
|
||||
if halflife_data:
|
||||
for k, v in halflife_data.items():
|
||||
half_life_str = str(v[2]) if len(v) > 2 else "unknown"
|
||||
break
|
||||
|
||||
# Extract parent spin/parity
|
||||
parent_J = jpi_data[0][0] if jpi_data else 0.0
|
||||
@@ -398,10 +417,19 @@ def get_decay_info_from_paceENSDF(
|
||||
forbidden_code = "0A" # default
|
||||
transition_type = "A" # default
|
||||
|
||||
if beta_data is None:
|
||||
beta_data = {}
|
||||
|
||||
for k, v in beta_data.items():
|
||||
for state in v:
|
||||
# state[15] contains forbiddenness code (e.g. '2F', '1UF')
|
||||
if len(state) > 15 and state[15] is not None:
|
||||
# Use ground state branch (level_index == 0) for forbiddenness
|
||||
if state[0] == 0 and len(state) > 15 and state[15] is not None:
|
||||
code = str(state[15])
|
||||
if code in FORBIDDENNESS_MAP:
|
||||
forbidden_code = code
|
||||
transition_type = FORBIDDENNESS_MAP[code]
|
||||
# Fallback: use first branch's forbiddenness if no ground state
|
||||
elif transition_type == "A" and len(state) > 15 and state[15] is not None:
|
||||
code = str(state[15])
|
||||
if code in FORBIDDENNESS_MAP:
|
||||
forbidden_code = code
|
||||
@@ -420,8 +448,8 @@ def get_decay_info_from_paceENSDF(
|
||||
Z_parent=Z_parent,
|
||||
Z_daughter=Z_daughter,
|
||||
A_number=A_number,
|
||||
endpoint_keV=q_value_keV,
|
||||
endpoint_MeV=q_value_keV / 1000.0,
|
||||
endpoint_keV=endpoint_keV,
|
||||
endpoint_MeV=endpoint_keV / 1000.0,
|
||||
transition_type=transition_type,
|
||||
forbiddenness_code=forbidden_code,
|
||||
parent_J=parent_J,
|
||||
|
||||
Reference in New Issue
Block a user