Skip to content

API reference / Analyses

tsdive.screen

screen(
    archive: str | Path,
    baseline: str,
    window: str,
    *,
    method: str = "mad",
    k: float = 3.0,
    mode: str | Path | None = None,
    basis: str
    | CalculationBasis = CalculationBasis.TIME_WEIGHTED,
    stepped: bool = False,
) -> ScreenAnalysis

Screen one window of a single-tag archive against a baseline.

Parameters:

Name Type Description Default
archive str | Path

parquet archive carrying tsdive.meta.

required
baseline str

START/END in ISO 8601 UTC for the history.

required
window str

START/END in ISO 8601 UTC to screen.

required
method str

"mad" or "moving-range"; ignored with mode.

'mad'
k float

flag beyond k times the scale from the center.

3.0
mode str | Path | None

MODE archive; one baseline per regime instead of one for the window.

None
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, unknown method.

TSDiveError

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

Examples:

>>> import tsdive
>>> s = tsdive.screen("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
>>> s.to_dict()["n_flagged"], s.to_dict()["n_screened"]
(29, 300)
>>> len(s.frame)
29