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 __future__ import annotations
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Optional
|
from typing import TYPE_CHECKING, Any, Optional
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from beta_spectrum.spectrum import BetaSpectrum
|
from beta_spectrum.spectrum import BetaSpectrum
|
||||||
from beta_spectrum.components.detector_response import DetectorResponse
|
|
||||||
from exp_data.spectrum import ExpSpectrum
|
from exp_data.spectrum import ExpSpectrum
|
||||||
|
|
||||||
|
|
||||||
@@ -39,8 +38,11 @@ class SpectrumModel:
|
|||||||
----------
|
----------
|
||||||
spectrum : BetaSpectrum
|
spectrum : BetaSpectrum
|
||||||
Theoretical spectrum calculator.
|
Theoretical spectrum calculator.
|
||||||
detector_response : DetectorResponse, optional
|
detector_response : optional
|
||||||
Detector response function. If None, no convolution is applied.
|
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
|
channel_energies : np.ndarray, optional
|
||||||
Energy values for detector channels (keV). Used to set up
|
Energy values for detector channels (keV). Used to set up
|
||||||
the response if detector_response is None.
|
the response if detector_response is None.
|
||||||
@@ -49,7 +51,7 @@ class SpectrumModel:
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
spectrum: "BetaSpectrum",
|
spectrum: "BetaSpectrum",
|
||||||
detector_response: Optional["DetectorResponse"] = None,
|
detector_response: Optional[Any] = None,
|
||||||
channel_energies: Optional[np.ndarray] = None,
|
channel_energies: Optional[np.ndarray] = None,
|
||||||
):
|
):
|
||||||
self.spectrum = spectrum
|
self.spectrum = spectrum
|
||||||
@@ -79,11 +81,10 @@ class SpectrumModel:
|
|||||||
if energies_keV is not None:
|
if energies_keV is not None:
|
||||||
W = self._keV_to_W(energies_keV)
|
W = self._keV_to_W(energies_keV)
|
||||||
return self.spectrum(W)
|
return self.spectrum(W)
|
||||||
return self.spectrum(
|
w_grid = getattr(self.spectrum, "_W_grid", None)
|
||||||
self.spectrum._W_grid
|
if w_grid is None:
|
||||||
if hasattr(self.spectrum, "_W_grid") and self.spectrum._W_grid is not None
|
return np.array([], dtype=np.float64)
|
||||||
else np.array([])
|
return self.spectrum(w_grid)
|
||||||
)
|
|
||||||
|
|
||||||
def _keV_to_W(self, energies_keV: np.ndarray) -> np.ndarray:
|
def _keV_to_W(self, energies_keV: np.ndarray) -> np.ndarray:
|
||||||
"""Convert kinetic energy in keV to total energy in m_e units."""
|
"""Convert kinetic energy in keV to total energy in m_e units."""
|
||||||
|
|||||||
Reference in New Issue
Block a user