Time Series

TimeSeries is the object representation of the time series data it provides all the attributes and metadata of the time series as well as access to the data itself through the read_data_frame and write_data_frame methods.

class kisters.water.time_series.core.time_series.TimeSeries(*args, **kwargs)

Bases: abc.ABC

This class provides the interface of TimeSeries.

coverage_from

The date from which the TimeSeries data starts.

Returns:The start date
coverage_until

The date until which the TimeSeries data covers.

Returns:The end date
id

The id number which fully identifies the TimeSeries.

Returns:The id number
metadata

The map containing all the metadata related to this TimeSeries.

Returns:The metadata map
name

The full name of the TimeSeries.

Returns:The full name
path

The full path to this TimeSeries.

Returns:The path string
read_data_frame(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, **kwargs) → pandas.core.frame.DataFrame

This method returns the TimeSeries data between the start and end dates (both dates included) structured as a pandas DataFrame.

Parameters:
  • start – The starting date from which the data will be returned, expressed either
  • an ISO Datetime string or as a datetime object. If TimeZone is not included, (as) –
  • assumes the TimeZone of the TimeSeries. (it) –
  • end – The ending date until which the data will be covered (end date included),
  • either as an ISO Datetime string or as a datetime object. If TimeZone (expressed) –
  • not included, it assumes the TimeZone of the TimeSeries. (is) –
  • params – The parameters passed to the backend call.
  • ensemble time series only (For) –
    To retrieve all data points of all dispatch_infos and members
    set t0, dispatch_info, member to None including t0, dispatch_info, member as additional columns
    To retrieve a single ensemble member
    t0: the t0 time stamp of the ensemble member dispatch_info: ensemble dispatch_info identifier member: ensemble member identifier
Returns:

The DataFrame containing the TimeSeries data

read_ensemble_members(t0_start: datetime.datetime = None, t0_end: datetime.datetime = None)

Returns a list of dictionaries with the corresponding t0, member and dispatch_infos as key.

Parameters:
  • t0_start – The starting date from which the data will be returned.
  • t0_end – The ending date until which the data will be covered (end date included).
short_name

The short name of the TimeSeries.

Returns:The short name
write_data_frame(data_frame: pandas.core.frame.DataFrame, start: datetime.datetime = None, end: datetime.datetime = None, t0: datetime.datetime = None, dispatch_info: str = None, member: str = None, **kwargs)

This methods writes the TimeSeries data from the data_frame into this TimeSeries. If either start or end, cover data missing in the data_frame these date ranges will be deleted. So if you specify an empty DataFrame, you can remove all data between start and end.

Parameters:
  • data_frame – The TimeSeries data to be written in the form of a pandas DataFrame.
  • start – The date from which data will be writen.
  • end – The date until which data will be writen (end date included).
  • ensemble time series only (For) –
    To write a single ensemble member at once
    t0: the t0 time stamp of the ensemble member dispatch_info: ensemble dispatch_info identifier member: ensemble member identifier start, end will be ignored