mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/SPATZ.git
synced 2025-12-17 01:38:02 +00:00
Updated observers and Kalman Filter, added running average
This commit is contained in:
@@ -106,19 +106,27 @@ class Simulation:
|
||||
self.__sensors.append(sensor(self.__dataset, self.__logger, *args, **kwargs))
|
||||
|
||||
return self.__sensors[-1]
|
||||
|
||||
def add_observer(self, attributes: List[str]) -> Observer:
|
||||
"""Register a new observer for this simulation observing the provided attributes.
|
||||
|
||||
def add_observer(self, observer_or_attributes: List[str] | Observer) -> Observer:
|
||||
"""Register a new observer for this simulation.
|
||||
|
||||
Args:
|
||||
attributes (List[str]): A list of strings describing the attributes to observe.
|
||||
observer_or_attributes (List[str] | Observer): A list of strings describing the attributes to observe
|
||||
or a custom observer class.
|
||||
|
||||
Returns:
|
||||
Observer: An observer object which can be called like a function to obtain the desired data.
|
||||
"""
|
||||
assert len(attributes) != 0, "Observed attributes list must be nonempty."
|
||||
assert isinstance(observer_or_attributes, list) or issubclass(observer_or_attributes, Observer)
|
||||
|
||||
self.__sensors.append(Observer(self.__dataset, self.__logger, attributes))
|
||||
if isinstance(observer_or_attributes, list):
|
||||
attributes = observer_or_attributes
|
||||
assert len(attributes) != 0, "Observed attributes list must be nonempty."
|
||||
|
||||
self.__sensors.append(Observer(self.__dataset, self.__logger, attributes))
|
||||
else:
|
||||
observer = observer_or_attributes
|
||||
self.__sensors.append(observer(self.__dataset, self.__logger))
|
||||
|
||||
return self.__sensors[-1]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user