Skip to content

API reference / Analyses

tsdive.spc

spc(
    archive: str | Path,
    baseline: str,
    window: str,
    *,
    basis: str
    | CalculationBasis = CalculationBasis.TIME_WEIGHTED,
    stepped: bool = False,
) -> SpcAnalysis

Chart one window of a single-tag archive against baseline limits.

Parameters:

Name Type Description Default
archive str | Path

parquet archive carrying tsdive.meta.

required
baseline str

START/END in ISO 8601 UTC the limits are computed from.

required
window str

START/END in ISO 8601 UTC to chart.

required
basis str | CalculationBasis

calculation basis declared on the read.

TIME_WEIGHTED
stepped bool

stepped interpolation between samples.

False

Raises:

Type Description
ValueError

malformed window, overlapping windows.

TSDiveError

a censored baseline, or any typed refusal from the read path.

Examples:

>>> import tsdive
>>> c = tsdive.spc("data/demo/fic101_demo.parquet",
...                "2024-03-30T20:00:00Z/2024-03-31T01:00:00Z",  # baseline
...                "2024-03-31T01:00:00Z/2024-03-31T06:00:00Z")  # window
>>> round(c.limits.lcl, 3), round(c.limits.center, 3), round(c.limits.ucl, 3)
(60.673, 62.319, 63.966)
>>> c.frame["rule"].value_counts().to_dict()
{'BEYOND_3SIGMA': 29, 'RUN_9_SAMESIDE': 6, 'TREND_6': 2}