fips.Constant#

class fips.Constant(*, within=None)[source]#

Bases: _Kernel

A correlation of one between every two labels (of a group, with within).

Parameters:

within (str | Sequence[str] | None) – Correlate only labels that are the same on these levels; labels of different groups are independent. "level.attribute" groups by an attribute of a datetime level ("obs_time.date").

Examples

Errors shared by every observation of a site on one day:

>>> import pandas as pd
>>> from fips import Constant, Space
>>> times = pd.to_datetime(
...     ["2024-01-01 10:00", "2024-01-01 14:00", "2024-01-02 10:00"]
... )
>>> obs = pd.MultiIndex.from_product([["A"], times], names=["site", "obs_time"])
>>> model = Constant(within=["site", "obs_time.date"])
>>> model.with_std(1.0).build(Space({"co2": obs})).dense()
array([[1., 1., 0.],
       [1., 1., 0.],
       [0., 0., 1.]])

Attributes

levels

No levels, since the correlation is one at any distance.

within

The levels on which two labels must be the same to be correlated ("time.hour" is an attribute of a datetime level).

Methods

correlation(coords)

Return the correlation between the rows of coords, zero between groups (see CorrelationModel.correlation()).

Inherited

From CorrelationModel: with_std