Separate monolithic beta_spectrum package into:
beta_spectrum — pure theory (components, spectrum, CLI, visualize)
exp_data — experimental data handling (spectrum, calibration,
fitters, corrections)
fitter — analysis framework (model, fit_engine, extractor,
result)
beta_spectrum.visualize — plotting (BetaSpectrumAnalyzer)
Phase 1 — exp_data module:
ExpSpectrum dataclass with metadata, normalization, serialization
EnergyCalibrator (linear/quadratic calibration)
GaussianFitter + PeakFitter for calibration sources
DeadTimeCorrection, PileUpCorrection, BackgroundSubtractor
43 new tests, ruff + mypy clean
Phase 2 — fitter module:
SpectrumModel wraps BetaSpectrum + DetectorResponse with convolution
SpectrumFitter with χ² minimization, covariance, profile likelihood,
confidence intervals, robust loss functions
CWExtractor + GVAExtractor for C(W) and g_V/g_A extraction
AnalysisResult + FitSummary for physics-specific results
CurveFitter general-purpose callable model fitter
34 new tests, ruff + mypy clean
Phase 3 — clean up beta_spectrum:
Remove cw_extractor.py and fitter.py (moved to fitter/)
Clean __init__.py to export only theory classes
Add backward-compat methods to CWExtractor
Fix BetaSpectrumAnalyzer._get_branch_spectrum returning BetaSpectrum
objects instead of numpy arrays (plot fix)
Phase 4 — package structure:
Auto-discovered by setuptools (4 packages)
All imports updated across 26 source files
Black formatting applied
322 tests pass (262 original + 60 new)
ruff + mypy clean on all source files
Bug fixes:
- Fix multi-branch spectrum plotting: universal component keys
(Fermi, Screening, etc.) don't have per-branch prefix; fixed
fallback lookup.
- Fix negative phase space beyond endpoint: BetaSpectrum returns
negative values for W > W0; clamp branch spectra to zero.
58 lines
1.4 KiB
Python
58 lines
1.4 KiB
Python
# beta_spectrum/__init__.py
|
|
|
|
from .constants import ALPHA, HBAR_C_MEV_FM, ME_MEV, MP_MEV
|
|
from .utils import T_to_W, W_to_T, momentum
|
|
|
|
from .components.phase_space import PhaseSpace
|
|
from .components.fermi import FermiFunction
|
|
from .components.finite_size import FiniteSizeL0, ChargeDistributionU
|
|
from .components.screening import ScreeningCorrection
|
|
from .components.exchange import ExchangeCorrection
|
|
from .components.radiative import RadiativeCorrection
|
|
from .components.detector_response import DetectorResponse
|
|
|
|
from .spectrum import BetaSpectrum, SpectrumConfig, BranchConfig
|
|
from .visualize import BetaSpectrumAnalyzer
|
|
from .nuclear_data import (
|
|
DecayInfo,
|
|
BranchInfo,
|
|
get_decay_info_from_paceENSDF,
|
|
decay_info_to_config,
|
|
create_config_from_source,
|
|
load_json_input,
|
|
json_to_config,
|
|
DEFAULT_JSON_SCHEMA,
|
|
)
|
|
|
|
__all__ = [
|
|
"ALPHA",
|
|
"HBAR_C_MEV_FM",
|
|
"ME_MEV",
|
|
"MP_MEV",
|
|
"T_to_W",
|
|
"W_to_T",
|
|
"momentum",
|
|
"PhaseSpace",
|
|
"FermiFunction",
|
|
"FiniteSizeL0",
|
|
"ChargeDistributionU",
|
|
"ScreeningCorrection",
|
|
"ExchangeCorrection",
|
|
"RadiativeCorrection",
|
|
"DetectorResponse",
|
|
"BetaSpectrum",
|
|
"SpectrumConfig",
|
|
"BetaSpectrumAnalyzer",
|
|
"BranchConfig",
|
|
"DecayInfo",
|
|
"BranchInfo",
|
|
"get_decay_info_from_paceENSDF",
|
|
"decay_info_to_config",
|
|
"create_config_from_source",
|
|
"load_json_input",
|
|
"json_to_config",
|
|
"DEFAULT_JSON_SCHEMA",
|
|
]
|
|
|
|
__version__ = "0.3.0"
|