Skip to main content

calculateSliceArgs()

function calculateSliceArgs(
shape,
dataSlice,
dimIndices,
selectors,
dimensionValues,
root,
levelInfo,
zarrVersion,
updateDimensionValues?): Promise<{
dimensionValues: DimensionValues;
selectors: {
[key: string]: ZarrSelectorsProps;
};
sliceArgs: SliceArgs;
}>;

Constructs Zarr slice arguments for extracting a subregion of a multidimensional array.

This function:

  • Converts geographic / elevation slice ranges into Zarr slice objects.
  • Converts value-based selectors (e.g. {type: "value", selected: 2020}) into nearest index selectors.
  • Optionally loads dimension coordinate arrays for the selected slice.
  • Produces a new selector map describing index-based selections.

Parameters

ParameterTypeDescription
shapenumber[]Full array shape.
dataSliceDataSlicePropsPixel-space slice ranges { startX, endX, startY, endY, startElevation?, endElevation? } (see DataSliceProps).
dimIndicesDimIndicesPropsMapping of dimension names → indices as returned by identifyDimensionIndices (see DimIndicesProps).
selectors{ [key: string]: ZarrSelectorsProps; }User-provided selection map (lat/lon/elevation/time/etc.). See ZarrSelectorsProps.
dimensionValuesDimensionValuesCache of already-loaded coordinate arrays (mutated by this function).
rootLocation<Readable>Root Zarr group location.
levelInfostring | nullOptional multiscale subpath.
zarrVersion3 | 2 | nullZarr version (2 or 3).
updateDimensionValues?booleanIf true, rewrites dimensionValues only for the selected ranges.

Returns

Promise<{ dimensionValues: DimensionValues; selectors: { [key: string]: ZarrSelectorsProps; }; sliceArgs: SliceArgs; }>

An object containing:

  • sliceArgs: Array of slice objects/indexes matching the array's dimensions. See SliceArgs.
  • dimensionValues: Possibly updated coordinate arrays.
  • selectors: Updated index-based selectors. See ZarrSelectorsProps.