Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

xrtoolz

Composable operators for geoprocessing Earth System Data Cubes.

xrtoolz gives every preprocessing, physics, inference, and evaluation step a single shape — an Operator: a callable that maps xarray in to xarray out, carries its configuration, and reports its shape signature. Operators chain linearly with Sequential or wire into a DAG with the functional Graph API — the same operator works in both.

The carrier-agnostic composition core lives in pipekit; xrtoolz adds the xarray-specific operator families on top, organised by Earth-science domain.

Why xrtoolz

Install

uv add xrtoolz          # recommended (resolves pipekit from its source)

xrtoolz depends on pipekit-ops, which is pre-PyPI and resolved via [tool.uv.sources]. A plain pip install will fail until pipekit-ops reaches PyPI — use uv:

uv pip install "git+https://github.com/jejjohnson/geotoolz@main#subdirectory=packages/xrtoolz"

Optional extras pull in heavier backends only where they are used:

ExtraPulls inNeeded for
mapscartopyProjected map panels — SpatialMapPanel(projection=...), make_axes(projection=...), coastlines in EventVerificationPanel
waveletsPyWaveletstransforms.wavelet (cwt, dwt)
imagescikit-imageStructural image metrics
functaxfunctax (with JAX and SciPy; pre-PyPI, so a pip install also names "functax[jax,scipy] @ git+https://github.com/jejjohnson/functax.git@v0.0.6")The Laplace, biharmonic, global RBF and Euclidean IDW gap fills in xrops.interpolate
vectorgeopandas, shapely, rasteriogeo vector ↔ raster bridge (vectorize, rasterize, footprint, …)
uv add "xrtoolz[maps]"

Quickstart

Compute geostrophic surface currents from sea-surface height, then map them — as a single pipeline:

from pipekit_ops import Sequential
from xrops.anomaly import RemoveMean
from xrops.ocn import Streamfunction, GeostrophicVelocities
from xrops.viz.validation import SpatialMapPanel

pipeline = Sequential(
    RemoveMean(dim=("lat", "lon")),  # subtract the spatial mean
    Streamfunction(),            # ψ = g·η / f
    GeostrophicVelocities(),     # (u_g, v_g) from ψ
)

currents = pipeline(ds)          # xr.Dataset in → xr.Dataset out
fig = SpatialMapPanel(variable="u")(currents)

The same three operators can be wired as a DAG with Graph when you need branching or shared intermediates — see Composition.

Where to go next