mirror of
https://github.com/bec-project/ophyd_devices.git
synced 2026-07-29 02:23:04 +02:00
fix(sim): mixed_mon zero division guard
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot Autofix powered by AI
parent
5a604b02d1
commit
d5d7d1f613
@@ -408,6 +408,8 @@ class SimMonitorMixedSignals(PSIDeviceBase, SimMonitorMixedSignalsControl):
|
||||
def _generate_spectrum(self) -> np.ndarray:
|
||||
"""Generate a noisy 1D spectrum whose peak drifts with the trigger counter."""
|
||||
size = int(self.spectrum_size.get())
|
||||
if size <= 0:
|
||||
raise ValueError(f"{self.name}: spectrum_size must be > 0, got {size}")
|
||||
x = np.arange(size)
|
||||
center = (self._counter * max(size // 20, 1)) % size
|
||||
spectrum = 100 * np.exp(-((x - center) ** 2) / (2 * (size / 20) ** 2))
|
||||
|
||||
Reference in New Issue
Block a user