Documents · Verb reference
sync_with
Compare one aligned state cube with another.
Callable type: Grammar verb / pipe stage · Browse: Synchrony and comparison
Usage
from cubedynamics import verbs as v
v.sync_with(other, *, synchrony='occurrence', spatial_relation='same_pixel', lags=('0D',), state_var='state')
Arguments
| Argument | Meaning | Default |
|---|---|---|
| other | See implementation docstring below; no parameter-specific description supplied. | required |
| synchrony | See implementation docstring below; no parameter-specific description supplied. | 'occurrence' |
| spatial_relation | See implementation docstring below; no parameter-specific description supplied. | 'same_pixel' |
| lags | See implementation docstring below; no parameter-specific description supplied. | ('0D',) |
| state_var | See implementation docstring below; no parameter-specific description supplied. | 'state' |
Accepts
State cube + aligned state cube -> coupling Dataset.
Returns
State cube + aligned state cube -> coupling Dataset.
Order / grammar behavior
State cube + aligned state cube -> coupling 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"
cold = (pipe(cube) | v.threshold_state(threshold=0, direction="below")).unwrap()
unusual = (pipe(cube) | v.quantile_state(quantile=0.2, direction="below")).unwrap()
result = (pipe(cold) | v.sync_with(unusual, lags=("0D",))).unwrap()
result["coupling_score"].squeeze().plot()
plt.show()
Works with
State cube + aligned state cube -> coupling 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.