TimeSeriesBuffer - the reference

class time_series_buffer.buffer.TimeSeriesBuffer(maxlen=10, return_type='array')[source]

Custom buffer class, that allows to save streams of time-series with uncertainty in timestamps and values. Acts like a FIFO buffer.

add(data=None, time=nan, time_unc=0.0, val=nan, val_unc=0.0)[source]

Append one or more new datapoints to the buffer. A datapoint consists of the tuple (time, time_uncertainty, value, value_uncertainty).

Parameters:
  • data (iterable of iterables with shape (N, M) (default: None)) –

    If given, all other kwargs are ignored.

    • M==2 (pairs): assumed to be like (time, value)
    • M==3 (triple): assumed to be like (time, value, value_unc)
    • M==4 (4-tuple): assumed to be like (time, time_unc, value, value_unc)
  • time (float, or iterable of float/ufloat (default: np.nan)) – Timestamp(s) to be added.
  • time_unc (float, or iterable of float (default: 0.0)) – Uncertainty(ies) of the timestamp(s) to be added.
  • val ((iterable of) float/ufloat (default: np.nan)) – Value(s) to be added.
  • val_unc ((iterable of) float (default: 0.0)) – Uncertainty(ies) of the value(s) to be added.
  • time_unc, val, val_unc need to be of same shape, but uncertainties can be omitted. (time,) –
pop(n_samples=1)[source]

Return the next n_samples from the left side of the buffer.

View the latest n additions to the buffer. Returns the format that was specified during init of the buffer.

Parameters:n (int (default: 1)) – How many datapoints to return.
Returns:
Return type:Depends on return_type, see __init__() for details
show(n_samples=1)[source]

View the latest n_samples additions to the buffer. Returns the format that was specified during init of the buffer.

Parameters:n_samples (int (default: 1)) – How many samples to return. Return all samples in buffer, if set to -1.
Returns:
Return type:Depends on return_type, see __init__() for details