xsweep#
Content-agnostic parameter sweeps for xarray: lift an expensive point function into a gridded, cached, resumable computation.
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.
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.
Results stream into a zarr store as they land. Interrupt at point 4000 of 5000 and relaunch: only the missing points are recomputed.
A satellite scene has far fewer distinct parameter rows than pixels. Deduplication computes each unique row once and expands the result back.
Variables sharing a dim vary together; variables on distinct dims multiply. The arrays already say it, so the contract never repeats it.