Skip to content

series⚓︎

Time series management and processing.

DataSeries ⚓︎

Bases: StatPrint

Basically just an np.ndarray. But adds:

  • Possibility of adding attributes.
  • The class (type) provides way to acertain if an attribute is a series.

Note: subclassing ndarray is too dirty => We'll just use the array attribute, and provide {s,g}etitem.

FAUSt ⚓︎

Bases: DataSeries, StatPrint

Container for time series of a statistic from filtering.

Four attributes, each of which is an ndarray:

  • .f for forecast , (Ko+1,)+item_shape
  • .a for analysis , (Ko+1,)+item_shape
  • .s for smoothed , (Ko+1,)+item_shape
  • .u for universial/all, (K +1,)+item_shape

If store_u=False, then .u series has shape (1,)+item_shape, wherein only the most-recently-written item is stored.

Series can also be indexed as in

self[ko,'a']
self[whatever,ko,'a']
# ... and likewise for 'f' and 's'. For 'u', can use:
self[k,'u']
self[k,whatever,'u']

Note

If a data series only pertains to analysis times, then you should use a plain np.array instead.

__init__(K, Ko, item_shape, store_u, store_s, **kwargs) ⚓︎

Construct object.

  • item_shape : shape of an item in the series.
  • store_u : if False: only the current value is stored.
  • kwargs : passed on to ndarrays.

RollingArray ⚓︎

ND-Array that implements "leftward rolling" along axis 0.

Used for data that gets plotted in sliding graphs.

StatPrint ⚓︎

Bases: NicePrint

Set NicePrint options suitable for stats.

auto_cov(xx, nlags=4, zero_mean=False, corr=False) ⚓︎

Auto covariance function, computed along axis 0.

  • nlags: max lag (offset) for which to compute acf.
  • corr : normalize acf by acf[0] so as to return auto-CORRELATION.

With corr=True, this is identical to statsmodels.tsa.stattools.acf(xx,True,nlags)

estimate_corr_length(xx) ⚓︎

Estimate the correlation length of a time series.

For explanation, see mods.LA.homogeneous_1D_cov. Also note that, for exponential corr function, as assumed here,

\[\text{corr}(L) = \exp(-1) \approx 0.368\]

fit_acf_by_AR1(acf_empir, nlags=None) ⚓︎

Fit an empirical auto cov function (ACF) by that of an AR1 process.

  • acf_empir: auto-corr/cov-function.
  • nlags: length of ACF to use in AR(1) fitting

mean_with_conf(xx) ⚓︎

Compute the mean of a 1d iterable xx.

Also provide confidence of mean, as estimated from its correlation-corrected variance.

monitor_setitem(cls) ⚓︎

Modify cls to track of whether its __setitem__ has been called.

See sub.py for a sublcass solution (drawback: creates a new class).