Skip to content

Documents · Verb reference

change_state

Convert lagged absolute or relative change to a state cube.

Callable type: Grammar verb / pipe stage · Browse: State and events

Usage

from cubedynamics import verbs as v
v.change_state(*, change, threshold, lag, variable=None, name=None)

Arguments

Argument Meaning Default
change See implementation docstring below; no parameter-specific description supplied. required
threshold See implementation docstring below; no parameter-specific description supplied. required
lag See implementation docstring below; no parameter-specific description supplied. required
variable See implementation docstring below; no parameter-specific description supplied. None
name See implementation docstring below; no parameter-specific description supplied. None

Accepts

Raw biological or environmental cube -> state Dataset.

Returns

Raw biological or environmental cube -> state Dataset.

Order / grammar behavior

Raw biological or environmental cube -> state Dataset.

Minimal example

Run from the repository root after python -m pip install -e '.[vignettes]'. Uses the checked observational PRISM fixture; no network is required.

from pathlib import Path
import xarray as xr
import matplotlib.pyplot as plt
from cubedynamics import pipe, verbs as v

# Frozen, reviewed PRISM observations; run from the repository root.
path = Path("tests/fixtures/real_data/prism_boulder_january_2024.nc")
with xr.open_dataset(path, engine="scipy") as observed:
    cube = observed["tmax"].load()
assert cube.attrs["units"] == "degC"

result = (pipe(cube) | v.change_state(change="absolute", threshold=5, lag=1)).unwrap()
result.state.mean("time").plot()
plt.show()

Works with

Raw biological or environmental cube -> state Dataset.

See also

Implementation notes

No additional implementation notes in the current docstring.

Implementation source. Signatures and descriptions on this page are generated from this checkout, not hand-maintained copies.