ExZarr.ChunkGrid.Irregular (ExZarr v1.1.0)

View Source

Irregular chunk grid implementation for Zarr v3.

In an irregular chunk grid, chunks can have different shapes. This is useful for arrays where different regions have different optimal chunk sizes, such as datasets with varying spatial or temporal resolution.

Configuration

The configuration map can specify chunk shapes in two ways:

1. Per-dimension chunk sizes

%{
  "chunk_sizes" => [[50, 50, 25], [100, 50, 50]]
}

Each inner list specifies the chunk sizes along one dimension.

2. Explicit chunk index to shape mapping

%{
  "chunk_shapes" => %{
    "{0,0}" => [50, 100],
    "{0,1}" => [50, 50],
    "{1,0}" => [25, 100],
    "{1,1}" => [25, 50]
  }
}

Example

# Variable resolution: first chunks are larger
config = %{
  "chunk_sizes" => [
    [500, 250, 250],  # First dim: 500, 250, 250
    [500, 500]        # Second dim: 500, 500
  ]
}

{:ok, grid} = ExZarr.ChunkGrid.Irregular.init(config)

Specification

Zarr v3 extensions may define irregular chunk grid patterns. This implementation provides a flexible foundation for such patterns.

Summary

Functions

Get all chunk indices for this irregular grid.

Set the array shape for this chunk grid.

Types

t()

@type t() :: %ExZarr.ChunkGrid.Irregular{
  array_shape: tuple() | nil,
  chunk_shapes_map: %{required(tuple()) => tuple()} | nil,
  chunk_sizes: [[non_neg_integer()]] | nil
}

Functions

all_chunk_indices(irregular)

@spec all_chunk_indices(t()) :: [tuple()]

Get all chunk indices for this irregular grid.

Parameters

  • grid - Irregular chunk grid state

Returns

  • List of chunk index tuples

set_array_shape(grid, array_shape)

@spec set_array_shape(t(), tuple()) :: t()

Set the array shape for this chunk grid.

Required for validation and calculations.