fix(fitter): stop referencing removed detector_response module
This commit is contained in:
+11
-10
@@ -11,13 +11,12 @@ Usage:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
from typing import TYPE_CHECKING, Any, Optional
|
||||
|
||||
import numpy as np
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from beta_spectrum.spectrum import BetaSpectrum
|
||||
from beta_spectrum.components.detector_response import DetectorResponse
|
||||
from exp_data.spectrum import ExpSpectrum
|
||||
|
||||
|
||||
@@ -39,8 +38,11 @@ class SpectrumModel:
|
||||
----------
|
||||
spectrum : BetaSpectrum
|
||||
Theoretical spectrum calculator.
|
||||
detector_response : DetectorResponse, optional
|
||||
Detector response function. If None, no convolution is applied.
|
||||
detector_response : optional
|
||||
Detector response object exposing ``channel_energies`` and
|
||||
``convolve`` (duck-typed: the DetectorResponse module was removed
|
||||
from beta_spectrum and is pending a restore-or-delete decision).
|
||||
If None, no convolution is applied.
|
||||
channel_energies : np.ndarray, optional
|
||||
Energy values for detector channels (keV). Used to set up
|
||||
the response if detector_response is None.
|
||||
@@ -49,7 +51,7 @@ class SpectrumModel:
|
||||
def __init__(
|
||||
self,
|
||||
spectrum: "BetaSpectrum",
|
||||
detector_response: Optional["DetectorResponse"] = None,
|
||||
detector_response: Optional[Any] = None,
|
||||
channel_energies: Optional[np.ndarray] = None,
|
||||
):
|
||||
self.spectrum = spectrum
|
||||
@@ -79,11 +81,10 @@ class SpectrumModel:
|
||||
if energies_keV is not None:
|
||||
W = self._keV_to_W(energies_keV)
|
||||
return self.spectrum(W)
|
||||
return self.spectrum(
|
||||
self.spectrum._W_grid
|
||||
if hasattr(self.spectrum, "_W_grid") and self.spectrum._W_grid is not None
|
||||
else np.array([])
|
||||
)
|
||||
w_grid = getattr(self.spectrum, "_W_grid", None)
|
||||
if w_grid is None:
|
||||
return np.array([], dtype=np.float64)
|
||||
return self.spectrum(w_grid)
|
||||
|
||||
def _keV_to_W(self, energies_keV: np.ndarray) -> np.ndarray:
|
||||
"""Convert kinetic energy in keV to total energy in m_e units."""
|
||||
|
||||
Reference in New Issue
Block a user