TimeSeriesStoreDecorators

The TimeSeriesStoreDecorators allow you to “wrap” a TimeSeriesStore to extend its functionality.

class kisters.water.time_series.store_decorators.AddMetadataStore(forward: kisters.water.time_series.core.time_series_store.TimeSeriesStore, metadata: Mapping[str, Any])

Bases: kisters.water.time_series.core.time_series_store.TimeSeriesStore

AddMetadataStore is a TimeSeriesStore decorator which allows to add metadata to TimeSeries inside the original TimeSeriesStore. To add metadata you must provide a Mapping of paths to metadata dictionaries.

Parameters:
  • forward – The TimeSeriesStore to be decorated.
  • metadata – The mapping providing metadata. Keys are the time series paths, and values are the metadata maps for each time series.

Example

import json
from kisters.water.file_io import FileStore, ZRXPFormat
from kisters.water.store_decorators import AddMetadataStore
with open('tests/data/addmetadata.json', 'r') as f:
    j = json.load(f)
store = AddMetadataStore(FileStore('tests/data', ZRXPFormat()), j)
ts = store.get_by_path('validation/threshold/05BJ004.HG.datum.O')
ts.metadata['THRESHOLDATTR']
class kisters.water.time_series.store_decorators.CacheStore(forward: kisters.water.time_series.core.time_series_store.TimeSeriesStore)

Bases: kisters.water.time_series.core.time_series_store.TimeSeriesStore

CacheStore is a TimeSeriesStore decorator which allows to cache the retrieval of TimeSeries inside the original TimeSeriesStore. Also TimeSeries retrieved this way cache the data they contain in memory.

Parameters:forward – The TimeSeriesStore to be decorated.

Example

from kisters.water.file_io import FileStore, ZRXPFormat
from kisters.water.store_decorators import CacheStore
store = CacheStore(FileStore('tests/data', ZRXPFormat()))
ts = store.get_by_path('validation/threshold/05BJ004.HG.datum.O')