Skip to main content

Copy a zarr dataset while changing chunking - variable by variable

Project description

zarr-copy

Copy a zarr dataset while optionally rechunking variables — variable by variable.

Installation

pip install -e .

Or with uv:

uv sync

Usage

zarr-copy [-h] [-v VAR [VAR ...]] [--rechunk DIM=SIZE [DIM=SIZE ...]]
          [--double-remap DIM] [--tmp-path DIR]
          zarr_in zarr_out

Positional arguments

Argument Description
zarr_in Path or S3 URI of the source zarr group
zarr_out Path or S3 URI of the destination zarr group

Optional arguments

Flag Description
-v VAR … Variable names to copy. Copies all variables when omitted.
--rechunk DIM=SIZE … Rechunk one or more dimensions, e.g. --rechunk time=1 lat=256.
--double-remap DIM Use the two-pass copy strategy for the given dimension to reduce peak memory usage.
--tmp-path DIR Directory for temporary files used by --double-remap. Defaults to the system temp dir.

Examples

Copy all variables without rechunking:

zarr-copy /data/input.zarr /data/output.zarr

Copy selected variables and rechunk the time dimension:

zarr-copy /data/input.zarr /data/output.zarr -v temperature salinity --rechunk time=1

Copy from S3, rechunk multiple dimensions, and use the double-remap strategy:

zarr-copy s3://my-bucket/input.zarr /data/output.zarr \
  --rechunk time=1 lat=256 lon=256 \
  --double-remap time \
  --tmp-path /scratch

Write to S3 from a local source:

zarr-copy /data/input.zarr s3://my-bucket/output.zarr \
  --rechunk lat=256 lon=256

Increase spatial chunk sizes for better read performance along lat/lon:

zarr-copy /data/input.zarr /data/output.zarr --rechunk lat=256 lon=256

Optimise for time-series access by making the time dimension unchunked (one chunk per step):

zarr-copy /data/input.zarr /data/output.zarr --rechunk time=1

Rechunk a large dataset where the time axis is being heavily reordered, using /scratch for intermediate storage to cap memory use:

zarr-copy /data/input.zarr /data/output.zarr \
  -v u v w temperature \
  --rechunk time=1 level=1 lat=180 lon=360 \
  --double-remap time \
  --tmp-path /scratch

Notes

  • Rechunking requires _ARRAY_DIMENSIONS metadata on each array (standard for xarray/CF-convention zarr stores).
  • S3 access is handled transparently via s3fs.
  • The --double-remap strategy writes data to a temporary intermediate zarr (lz4-compressed) to avoid holding large in-memory buffers during rechunking.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zarr_copy-0.1.0.tar.gz (174.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zarr_copy-0.1.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file zarr_copy-0.1.0.tar.gz.

File metadata

  • Download URL: zarr_copy-0.1.0.tar.gz
  • Upload date:
  • Size: 174.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for zarr_copy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 06ba865211c60ead51a39a8fbf7e513e389058d74adebae664a19cdf73f73825
MD5 438f7edf8b279f2242e2c05e19bc6dd1
BLAKE2b-256 98be32d54a4a95a398d01ecac3640605b4745a0dd6e20ae9ae53f2acadcf7357

See more details on using hashes here.

File details

Details for the file zarr_copy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: zarr_copy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for zarr_copy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee33ae13ca520722c710730a6e6e84a223eca08f39cbcb3759ac1327f81eb666
MD5 9d2725466ba51df75469ff9fa9a6a472
BLAKE2b-256 a97dbbb65a25b640eb441d0d873c926fa85e1e8b4d121d925ec611e6ecd3ddf5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page