mirror of
https://github.com/bec-project/ophyd_devices.git
synced 2025-07-10 18:51:53 +02:00
fix: fix bug in computation of negative data within SimMonitor
This commit is contained in:
@ -423,7 +423,7 @@ class SimulatedDataMonitor(SimulatedDataBase):
|
|||||||
if compute_readback:
|
if compute_readback:
|
||||||
method = self._compute
|
method = self._compute
|
||||||
value = self.execute_simulation_method(method=method, signal_name=signal_name)
|
value = self.execute_simulation_method(method=method, signal_name=signal_name)
|
||||||
value = self.bit_depth(value)
|
value = self.bit_depth(np.max(value, 0))
|
||||||
self.update_sim_state(signal_name, value)
|
self.update_sim_state(signal_name, value)
|
||||||
|
|
||||||
def _compute(self, *args, **kwargs) -> int:
|
def _compute(self, *args, **kwargs) -> int:
|
||||||
@ -453,12 +453,12 @@ class SimulatedDataMonitor(SimulatedDataBase):
|
|||||||
int: Value with added noise.
|
int: Value with added noise.
|
||||||
"""
|
"""
|
||||||
if noise == NoiseType.POISSON:
|
if noise == NoiseType.POISSON:
|
||||||
v = np.ceil(np.random.poisson(v)).astype(int)
|
v = np.random.poisson(v)
|
||||||
return v
|
return v
|
||||||
elif noise == NoiseType.UNIFORM:
|
elif noise == NoiseType.UNIFORM:
|
||||||
noise = np.ceil(np.random.uniform(0, 1) * noise_multiplier).astype(int)
|
noise = np.random.uniform(-1, 1) * noise_multiplier
|
||||||
v += noise * (np.random.randint(0, 2) * 2 - 1)
|
v += noise
|
||||||
return v if v > 0 else 0
|
return v
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user