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

ParameterTypeDefault valueDescription
shapenumber[]undefinedFull array shape.
dataSliceDataSlicePropsundefinedPixel-space slice ranges { startX, endX, startY, endY, startElevation?, endElevation? } (see DataSliceProps).
dimIndicesDimIndicesPropsundefinedMapping of dimension names → indices as returned by identifyDimensionIndices (see DimIndicesProps).
selectors{ [key: string]: ZarrSelectorsProps; }undefinedUser-provided selection map (lat/lon/elevation/time/etc.). See ZarrSelectorsProps.
dimensionValuesDimensionValuesundefinedCache of already-loaded coordinate arrays (mutated by this function).
rootLocation<FetchStore>undefinedRoot Zarr group location.
levelInfostring | nullundefinedOptional multiscale subpath.
zarrVersion2 | 3 | nullundefinedZarr version (2 or 3).
updateDimensionValuesbooleanfalseIf 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.