Skip to content

Documents · Verb reference

sync_with

Compare one state cube with another using coordinate-label lags.

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. Positive lags shift the comparison so +5D means left at t is compared with right at t+5D: the right-hand condition occurs five days later. Negative lags mean the right-hand condition occurs earlier. Lags do not shift or harmonize the physical observation support represented by either source.

Returns

State cube + aligned state cube -> coupling Dataset. Positive lags shift the comparison so +5D means left at t is compared with right at t+5D: the right-hand condition occurs five days later. Negative lags mean the right-hand condition occurs earlier. Lags do not shift or harmonize the physical observation support represented by either source.

Order / grammar behavior

+5D compares left(t) with right(t+5D), so the right-hand condition occurs later. Negative lags mean it occurs earlier. Physical observation support is not shifted.

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. Positive lags shift the comparison so +5D means left at t is compared with right at t+5D: the right-hand condition occurs five days later. Negative lags mean the right-hand condition occurs earlier. Lags do not shift or harmonize the physical observation support represented by either source.

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.