/zarr-data-format:compression-codecsfrom zarr-data-format
Configures Zarr compression codecs (Blosc, Zstd, Gzip, LZ4, LZMA, BZ2) and numcodecs filters (Delta, Quantize, BitRound) in zarr-python 3. Helps when porting v2 code, optimizing storage ratio, or debugging codec errors.
Ships in zarr-data-format. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Configures the zarr-python 3 codec pipeline (filters, serializer, compressors) for an array and measures which codecs suit its data.
Core principle: the data sets the ratio more than the codec does. On real float32 climate data every lossless codec gave 1.5–4.8x, and the zarr 3 default (ZstdCodec) came within 10% of the best Blosc setting. Lossy filters gave the larger gains. Measure a sample of the real data before changing the default.
compressor=, numcodecs.Blosc(...) or numcodecs.Delta(...) now raise on v3 arrays.When NOT to use:
zarr-chunk-optimization's chunking-strategy.to_zarr workflows beyond the codec keys, Dask alignment: use zarr-xarray-integration.| Slot | create_array argument | Codecs |
|---|---|---|
| array → array | filters=[...] | TransposeCodec; zarr.codecs.numcodecs.Delta, Quantize, BitRound, FixedScaleOffset, PackBits |
| array → bytes | serializer= | BytesCodec() (default); sharding via shards= |
| bytes → bytes | compressors=[...] | ZstdCodec (default, level=0), BloscCodec, GzipCodec, Crc32cCodec; zarr.codecs.numcodecs.LZ4, LZMA, BZ2, Zlib |
import zarr
from zarr.codecs import BloscCodec, Crc32cCodec
from zarr.codecs.numcodecs import BitRound
z = zarr.create_array(
store="air.zarr", shape=(2920, 25, 53), chunks=(730, 25, 53), dtype="float32",
filters=[BitRound(keepbits=10)], # lossy: keeps 10 of 23 mantissa bits
compressors=[BloscCodec(cname="zstd", clevel=5, shuffle="shuffle"), Crc32cCodec()],
)
print(z.compressors) # z.compressor raises TypeError on v3 arrays
print(z.info_complete()) # after writing: "No. bytes stored", "Storage ratio"
zarr.codecs.numcodecs.* codecs are saved as numcodecs.<id>, outside the v3 spec: other Zarr implementations may not read them. numcodecs.zarr3 is deprecated.BloscCodec() defaults to zstd, clevel=5, "shuffle" ("bitshuffle" for 1-byte dtypes), typesize from the dtype.zarr_format=2 arrays take numcodecs objects (compressors=numcodecs.Blosc(...)). Their default depends on the call: zarr.create_array gives Zstd(level=0), but Group.create_array (used by xarray) gives Blosc(cname="lz4"). Set it explicitly.encoding={"var": {"compressors": [...], "filters": [...], "chunks": (730, 25, 53)}}. The "compressor" key raises ValueError.NCEP air temperature (xarray tutorial air_temperature, float32, 15.5 MB, zarr 3.1.5, Apple M5 Max). More datasets in examples.md.
| Configuration | Ratio | Read MB/s |
|---|---|---|
ZstdCodec() default | 2.83x | 4,460 |
| Blosc zstd 5: shuffle / noshuffle / bitshuffle | 2.97x / 2.89x / 1.72x | 3,100–4,500 |
| Blosc lz4 5, shuffle | 1.74x | 5,170 |
GzipCodec(level=5) | 2.76x | 1,560 |
| BZ2 5 / LZMA 6 (numcodecs) | 4.80x / 4.15x | 290 / 490 |
| BitRound(10) + Blosc zstd (lossy, max error 0.11 K) | 5.18x | 2,800 |
Measure your own sample: python assets/codec-comparison.py --zarr store.zarr/<var> (or --npy sample.npy).
| Mistake | Fix |
|---|---|
compressor= or numcodecs objects on a v3 array (ValueError: compressor cannot be used for arrays with zarr_format 3, TypeError: Expected an ArrayArrayCodec) | compressors=[zarr.codecs...], filters=[zarr.codecs.numcodecs...], or zarr_format=2 |
z.nbytes / z.nbytes_stored | nbytes_stored() is a method |
Benchmarking Blosc().encode(arr.tobytes()) | Bytes have typesize 1, so shuffle does nothing. Encode the ndarray or benchmark through zarr. |
[Delta, Quantize] on floats | Quantize or BitRound first. Delta-then-Quantize had 140x the max error. |
| "SHUFFLE for floats, BITSHUFFLE for ints" | Bitshuffle lost to shuffle with zstd on float32 and uint32. Measure. |
np.isfinite as a corruption check | A flipped bit decoded to finite, wrong values. Add Crc32cCodec() or ZstdCodec(checksum=True). |
numcodecs.blosc.use_threads = False against corruption | Importing zarr already sets it, and numcodecs never uses Blosc threads in a forked child. Its source names a hang, not corruption. |
| Choosing codecs on synthetic noise | Noise gives 1.0–1.3x under every codec. Sample the real data. |
What SKILL.md sets; muted values are Claude Code's defaults
Generated from the plugin's indexed repository (uw-ssec/savvy) — no native marketplace selected
npx claudepluginhub p/uw-ssec-zarr-data-format-plugins-zarr-data-format5 skills in this plugin
/cloud-storage-backendsUse when reading or writing Zarr data on Amazon S3, Google Cloud Storage, Azure Blob or an S3-compatible endpoint such as MinIO, when setting up FsspecStore, ObjectStore (obstore), s3fs, gcsfs, adlfs or Icechunk storage and credentials, or when remote Zarr access fails or is slow, with symptoms like 403 Forbidden, NoCredentialsError, requester-pays buckets, slow store opens, timeouts, high GET-request bills, CORS errors, or an fsspec simplecache or filecache that errors or never hits./data-migrationUse when converting HDF5 (.h5) or NetCDF (.nc) files to Zarr, migrating scientific datasets or a Zarr v2 store to Zarr v3, or building a virtual Zarr store over existing files with VirtualiZarr or kerchunk. Also use when a converted store lost scale_factor, _FillValue or time units, kept the old chunk layout, shows phony_dim names, or fails validation against its source./zarr-fundamentalsUse when creating, opening, indexing or organizing Zarr arrays and groups with zarr-python (.zarr stores, zarr.json or .zarray metadata), setting attributes, fill values, dimension names or shards, choosing between Zarr format v2 and v3, porting zarr 2 code that breaks on zarr 3 (FSStore, ProcessSynchronizer, len(), .compressor), or when parallel writes to one Zarr array lose data./zarr-xarray-integrationUse when reading or writing Zarr stores with xarray (open_zarr, to_zarr), setting to_zarr encoding, appending with append_dim, writing regions from parallel workers, or aligning Dask chunks with Zarr chunks or shards. Also use when to_zarr raises "would overlap multiple Dask chunks" or "must be an int or a tuple of ints", when appended times or coordinates come back wrong, or when a consolidated store opens stale.Other plugins' skills for the same job