xsweep#

Content-agnostic parameter sweeps for xarray: lift an expensive point function into a gridded, cached, resumable computation.

Why xsweep

GitHub

Some functions cannot be vectorised along the dims you want to sweep: a Monte-Carlo solver, an iterative scheme whose stopping point depends on the data, an external engine invoked one configuration at a time. numpy has nothing to offer there, and the loop you write by hand quietly grows a cache, a resume path, and a way to guess how long the whole thing will take.

xsweep is that loop, written once.

Know the cost first

explain() resolves the whole sweep and stops. Axes, call count, batches, what the store already has, and what a run will actually compute: all before the first call.

Knowing what a run will cost
Cache, output and resume in one artefact

Results stream into a zarr store as they land. Interrupt at point 4000 of 5000 and relaunch: only the missing points are recomputed.

The store
Never compute the same point twice

A satellite scene has far fewer distinct parameter rows than pixels. Deduplication computes each unique row once and expands the result back.

Deduplication
Semantics from xarray, not from a DSL

Variables sharing a dim vary together; variables on distinct dims multiply. The arrays already say it, so the contract never repeats it.

Semantics come from your data