Skip to content

Documents · Verb reference

local_synchrony_surface

Recover one complete focal S_p(dx, dy) surface from sparse pairs.

Callable type: Grammar verb / pipe stage · Browse: Synchrony and comparison

Usage

from cubedynamics import verbs as v
v.local_synchrony_surface(*, focal_y_index=None, focal_x_index=None, focal_index=None)

Arguments

Argument Meaning Default
focal_y_index Two-dimensional focal grid indices. Supply both together unless using focal_index. None
focal_x_index Two-dimensional focal grid indices. Supply both together unless using focal_index. None
focal_index Flattened focal grid index. None

Accepts

A sparse pair Dataset produced by v.local_synchrony_pairs(...) and one selected focal index.

Returns

The complete cold, warm, and Delta S_p(dx,dy) audit surface with focal-relative displacement, distance, and bearing.

Order / grammar behavior

Use for selected audit or sampled pixels. The observation radius bounds what was observed and is not an inferred characteristic scale.

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"

with xr.open_dataset(path, engine="scipy") as observed:
    temperature = observed[["tmin", "tmax"]].isel(y=slice(0, 12), x=slice(0, 12)).load()
pairs = (pipe(temperature) | v.local_synchrony_pairs(lower_var="tmin", upper_var="tmax", max_radius_km=30, window_days=30, min_t=3)).unwrap()
surface = (pipe(pairs) | v.local_synchrony_surface(focal_y_index=5, focal_x_index=5)).unwrap()
surface["delta_s"].plot(x="offset_x_index", y="offset_y_index", cmap="RdBu", center=0, cbar_kwargs={"label": "Delta S · red warm / blue cold"})
plt.show()

Works with

A sparse pair Dataset produced by v.local_synchrony_pairs(...) and one selected focal index.

See also

Implementation notes

The output retains cold, warm, pairwise Delta, signed displacement, distance, and focal-to-center bearing. It preserves local relational geography before reduction.

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