Time Series Store¶
TimeSeriesStore provides access to time series data from different backends. All TimeSeriesStore implementations provide this methods, to see details on a concrete Store usage go to Stores Backends
-
class
kisters.water.time_series.core.time_series_store.
TimeSeriesStore
¶ Bases:
abc.ABC
-
create_time_series
(path: str, display_name: str, attributes: Mapping = None, params: Mapping[str, Any] = None) → kisters.water.time_series.core.time_series.TimeSeries¶ Create an empty time series.
Parameters: - path – The time series path.
- display_name – The time series name to display.
- attributes – The metadata of the time series.
- params – The additional parameters, which are passed to the backend.
-
create_time_series_from
(copy_from: kisters.water.time_series.core.time_series.TimeSeries, **kwargs) → kisters.water.time_series.core.time_series.TimeSeries¶ Create a time series as a copy from another existing time series e.g. from another system. This function only copies meta data and only if the underlaying backend supports it.
Parameters: copy_from – The time series object to be copied.
-
get_by_filter
(ts_filter: str, params: Mapping[str, Any] = None) → Iterable[kisters.water.time_series.core.time_series.TimeSeries]¶ Get the time series list by filter.
Parameters: - ts_filter – time series path or filter.
- params – the additional parameters, which are passed to the backend.
Returns: The list of the found TimeSeries objects.
Examples
store.get_by_filter("W7AgentTest/20004/S/*")
-
get_by_id
(ts_id: Union[int, str, Iterable[int], Iterable[str]], params: Mapping[str, Any] = None) → Union[kisters.water.time_series.core.time_series.TimeSeries, Iterable[kisters.water.time_series.core.time_series.TimeSeries]]¶ Get the time series by id.
Parameters: - ts_id – List of ids or single id.
- params – The additional parameters, which are passed to the backend.
Returns: The time series or a list of time series if ts_id is a list.
Examples
store.get_by_id(4711) store.get_by_id([4711, 4712])
-
get_by_path
(path: str, params: Mapping[str, Any] = None) → kisters.water.time_series.core.time_series.TimeSeries¶ Get the time series by path.
Parameters: - path – The full qualified time series path.
- params – The additional parameters, which are passed to the backend.
Returns: The TimeSeries object.
Examples
store.get_by_path("W7AgentTest/20003/S/cmd")
-
get_entity
(entity_path: str = None, entity_id: int = None, **kwargs) → kisters.water.time_series.core.entity.Entity¶ Retrieve a single Entity from the backend.
Basic implementation is given based on get_entity_list, but it is recommended to overwrite this method based on the backend specifications. :param entity_path: The entity path. :param entity_id: The entity id. :param **kwargs: Additional arguments dependent on the backend.
Returns: The matching Entity.
-
get_entity_list
(entity_filter: str = None, entities_id: Iterable[int] = None, **kwargs) → Iterable[kisters.water.time_series.core.entity.Entity]¶ Retrieve a list of entities from the backend.
The behaviour depends totally on the backend implementation, this should decide if both entity_filter and entities_id arguments can be given and how they behave if both are given. As a rule of thumb if both arguments are given a double filter should be applied. :param entity_filter: The entity filter. :param entities_id: A list of entities id. :param **kwargs: Additional arguments dependent on the backend.
Returns: The list of Entity objects.
-
get_time_series
(**kwargs)¶
-
get_time_series_list
(**kwargs)¶
-
read_data_frames
(ts_list: Iterable[kisters.water.time_series.core.time_series.TimeSeries], start: Union[str, datetime.datetime] = None, end: Union[str, datetime.datetime] = None, params: Mapping = None, t0: datetime.datetime = None, dispatch_info: str = None, member: str = None) → Mapping[kisters.water.time_series.core.time_series.TimeSeries, pandas.core.frame.DataFrame]¶ Read multiple time series as data frames.
Note: TimeSeriesStore provides a default unoptimized implementation. Override this method if your store can provide a more efficient bulk read method.
-
write_data_frames
(ts_list: Iterable[kisters.water.time_series.core.time_series.TimeSeries], data_frames: Iterable[pandas.core.frame.DataFrame], start: Union[datetime.datetime, Iterable] = None, end: Union[datetime.datetime, Iterable] = None, t0: Union[datetime.datetime, Iterable] = None, dispatch_info: Iterable = None, member: Iterable = None)¶ Write multiple data frames to time series
Note: Override this method if your store can provide a better implementation to bulk write data frames.
-
write_time_series
(ts: kisters.water.time_series.core.time_series.TimeSeries, start: datetime.datetime = None, end: datetime.datetime = None, auto_create: bool = False) → kisters.water.time_series.core.time_series.TimeSeries¶ Write a single time series to the time series back end for the given time range.
Parameters: - ts – The time series to write.
- start – The starting date from which data will be written.
- end – The ending date until which data will be written.
- auto_create – Create the time series if not exists in the back end.
Examples
ts = store1.get_by_id(47122) store2.write_time_series(ts)
-
write_time_series_list
(ts_list: Iterable[kisters.water.time_series.core.time_series.TimeSeries], start: datetime.datetime = None, end: datetime.datetime = None, auto_create: bool = False)¶ Write a time series list to the back end for the given time range.
Parameters: - ts_list – The time series list.
- start – The starting date from which data will be written.
- end – The ending date until which data will be written.
- auto_create – Create the time series if not exists in the back end.
Examples
ts_list = store1.get_by_filter('W7AgentTest/2000*') store2.write_time_series_list(ts_list, datetime(2001, 1, 1), datetime(2002, 1, 1))
-