Compare commits
2 Commits
main
...
gac-x02da_
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c164ea19f | |||
|
|
096ac3ff43 |
@@ -53,7 +53,7 @@ def test_std_daq_live_processing_set_mode(std_daq_live_processing):
|
||||
std_daq_live_processing.set_mode("sum")
|
||||
assert std_daq_live_processing.get_mode() == "sum"
|
||||
with pytest.raises(TypeCheckError):
|
||||
std_daq_live_processing.set_mode("average")
|
||||
std_daq_live_processing.set_mode("mode_that_does_not_exist")
|
||||
with pytest.raises(TypeCheckError):
|
||||
std_daq_live_processing.set_mode(123)
|
||||
|
||||
|
||||
@@ -45,14 +45,14 @@ class StdDaqLiveProcessing:
|
||||
return self._mode
|
||||
|
||||
@typechecked
|
||||
def set_mode(self, mode: Literal["sum"]):
|
||||
def set_mode(self, mode: Literal["sum", "average"]):
|
||||
"""
|
||||
Set the processing mode.
|
||||
Args:
|
||||
mode (str): Processing mode, currently only "sum" is supported.
|
||||
mode (str): Processing mode, currently only "sum" and "average" are supported.
|
||||
"""
|
||||
if mode not in ["sum"]:
|
||||
raise ValueError("Unsupported mode. Only 'sum' is currently supported.")
|
||||
if mode not in ["sum", "average"]:
|
||||
raise ValueError("Unsupported mode. Only 'sum' and 'average' are currently supported.")
|
||||
self._mode = mode
|
||||
|
||||
def set_enabled(self, value: bool):
|
||||
@@ -83,6 +83,8 @@ class StdDaqLiveProcessing:
|
||||
match self._mode:
|
||||
case "sum":
|
||||
self.process_sum(data)
|
||||
case "average":
|
||||
self.process_average(data)
|
||||
case _:
|
||||
raise ValueError(f"Unknown mode: {self._mode}")
|
||||
|
||||
@@ -98,6 +100,18 @@ class StdDaqLiveProcessing:
|
||||
summed_data = np.sum(np.sum(data))
|
||||
self.signal.put(summed_data)
|
||||
|
||||
def process_average(self, data: np.ndarray):
|
||||
"""
|
||||
Process data by averaging it.
|
||||
Args:
|
||||
data (np.ndarray): Data to average.
|
||||
"""
|
||||
if not isinstance(data, np.ndarray):
|
||||
raise ValueError("Data must be a numpy array.")
|
||||
|
||||
averaged_data = np.mean(data)
|
||||
self.signal.put(averaged_data)
|
||||
|
||||
########################################
|
||||
## Flat and Dark Field References ######
|
||||
########################################
|
||||
|
||||
Reference in New Issue
Block a user