DASCore supports users who prefer to work with xarray. Spools become lazy DataTrees, patches convert to DataArrays and back, patch methods run directly on DataArrays, and patches index, compute, and write the way xarray users expect. Xarray is optional; install it with DASCore’s extras.
Spools as lazy DataTrees
Spool.io.to_xarray turns a whole spool into a dask-backed DataTree, with one node per group of related patches and one child node per merged segment. Building the tree reads no data; computing a selection reads only the patches it touches.
import numpy as npimport dascore as dcspool = dc.get_example_spool("diverse_das")tree = spool.io.to_xarray()first =next(node for node in tree.subtree if"data"in node.dataset)small = first.dataset["data"].isel(time=slice(0, 100)).compute()small.shape
lazy_coords=True keeps DASCore’s coordinates as the index, computing labels only for the samples selected, so converting back is exact even for fractional sampling rates and gaps. Use it to keep the sampling step of a dimension with one sample, which materialized labels cannot record:
DataArrays from DASCore have a dc accessor with every Patch method; methods that return a patch return a DataArray. For other DataArrays, import dascore.xarray.accessor first.
Their docstrings give the exact rules and what is unsupported. Patches have no .loc or .iloc. For DASCore’s range tuples and relative selections, use Patch.select.
Familiar methods
Many patch methods share xarray’s names: transpose, squeeze, where, fillna, dropna, pipe, rolling, idxmax, and the reductions (mean, max, std, …). Reductions keep the reduced dimension with length one unless given dim_reduce="squeeze". NumPy functions also return patches.