Time series¶
Time series of rainfall, discharge, elevation and storage values.
- class pyrunoff.utils.time_series.TimeSeries(data, sorted=False, _time_step=None)[source]¶
Bases:
objectBase class for numeric time series indexed by timestamps.
- Parameters:
data (Series) – Numeric values indexed by timestamps.
sorted (bool) – Whether to assume the index is already sorted.
_time_step (Timedelta | None) – Internal override for the series time step. For user-supplied data, the time step should normally be inferred from the DatetimeIndex. This override is not a trusted public API path and should only be used when the caller understands the implications of using it.
- property time_step¶
Return the interval between consecutive time-series values.
- classmethod sum(series)[source]¶
Return the elementwise sum of aligned series with matching intervals.
Every series must be an instance of the class
sumis called on, soDischargeSeries.sumonly accepts discharge series.- Parameters:
series (Iterable[TimeSeries]) – Series to add, with identical indexes and time steps.
- Returns:
Sum, of the class
sumis called on.- Raises:
TypeError – If a series is not of that class.
ValueError – If no series are given, or they are unsorted or their time steps or indexes differ.
- Return type:
- classmethod dict_from_dataframe(data, columns=None, end=None)[source]¶
Return one series per column of a table indexed by timestamps.
The index is sorted and its time step inferred once for all columns.
- Parameters:
- Returns:
Series keyed by column name.
- Raises:
ValueError – If columns are missing or duplicated, or a column’s values are invalid for this class (the error names the column).
TypeError – If a column’s values are not float-convertible.
- Return type:
- class pyrunoff.utils.time_series.DischargeSeries(data, sorted=False, _time_step=None)[source]¶
Bases:
TimeSeriesTime series of discharge values.
- class pyrunoff.utils.time_series.StageSeries(data, sorted=False, _time_step=None)[source]¶
Bases:
TimeSeriesTime series of water-level values.
- class pyrunoff.utils.time_series.ElevationSeries(data, sorted=False, _time_step=None)[source]¶
Bases:
TimeSeriesTime series of elevation values.
- class pyrunoff.utils.time_series.StorageSeries(data, sorted=False, _time_step=None)[source]¶
Bases:
TimeSeriesTime series of storage values.
- class pyrunoff.utils.time_series.RainfallSeries(data, sorted=False, _time_step=None)[source]¶
Bases:
TimeSeriesTime series of incremental rainfall values.
- resample_at(time_step)[source]¶
Resample rainfall while preserving accumulated depth.
Each value is the depth over the interval ending at its timestamp, so the first value covers the interval before the first timestamp. The result therefore starts one new
time_stepafterindex[0] - self.time_stepand keeps the total depth.