zarr-python
하는 일
Zarr-Python은 대규모 과학 데이터셋을 덩어리(청크) 단위로 정리하고 접근하는 도구입니다. 데이터가 메모리에 다 들어가지 않아도 효율적으로 저장하고, 필요한 부분만 읽을 수 있게 해 줍니다.
사용하는 경우
- ✓메모리에 들어가기에 너무 큰 과학 데이터가 있을 때.
- ✓전체를 불러오지 않고 데이터셋의 특정 부분만 읽거나 쓰고 싶을 때.
- ✓Amazon S3나 Google Cloud Storage 같은 클라우드에 데이터를 저장하는 경우.
스킬 링크
https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/zarr-python/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“거대한 NumPy 배열을 덩어리 단위로 저장하고, 그중 작은 부분만 읽으려면 어떻게 하나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
데이터를 더 작은 블록(청크)으로 나누고, 압축을 사용할 수도 있습니다. 덕분에 필요한 데이터 블록에만 접근할 수 있어 시간과 메모리를 아낄 수 있습니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Zarr Python
When to use
Use for chunked scientific arrays, hierarchical stores, codecs, sharding, partial reads,
cloud object storage, and NumPy/Dask/Xarray interoperability. This community guide targets
Zarr-Python 3.4.0, released 2026-09-15, with Python 3.12+. The package version and
on-disk format are separate: this release reads/writes formats 2 and 3; new arrays default
to format 3. Keep downstream packages that require zarr<3 in their own environments.
Install
uv pip install "zarr==3.4.0" "numpy==2.5.3"
# Optional remote backends and migration CLI:
uv pip install "zarr[remote,cli]==3.4.0" "fsspec==2026.9.0" "s3fs==2026.9.0" "gcsfs==2026.8.1"
Commit the project's resolved lockfile. Optional integration versions exercised here: Dask 2026.8.0, Xarray 2026.9.0, h5py 3.16.0, NumCodecs 0.17.0, obstore 0.11.1. Local examples below and in the references use tiny synthetic arrays; remote snippets are illustrative and require a real authorized store. This does not establish cloud permissions, production throughput, or compatibility of every downstream reader.
Workflow
- Inspect shape, dtype, axis names, coordinates, units, missing-value convention, format, codec availability, and intended readers. Preserve sample IDs and axis order.
- Choose chunks for actual selections and a memory budget. For sharding, choose shard dimensions that are multiples of chunk dimensions. Benchmark representative data.
- Create a new destination (
overwrite=Falseormode="w-"). Usemode="r"for inspection;"a"can create a missing store and"w"destroys existing content. - Write bounded blocks. Assign one writer per stored chunk, or per shard when sharded; serialize metadata, append, and resize operations.
- Reopen read-only and compare values, dtype, shape, coordinates, units, masks and
metadata. An unwritten or missing chunk normally reads as
fill_value; a successful open alone does not prove data completeness. - For a completed group hierarchy, optionally consolidate metadata. Format-3 consolidation is experimental; refresh it after metadata changes and verify the actual consumers. Publish a completed store only after validation.
Basic array roundtrip
import numpy as np
import zarr
from zarr.codecs import BloscCodec
expected = np.arange(96, dtype="float32").reshape(12, 8)
z = zarr.create_array(
"array.zarr", shape=expected.shape, dtype=expected.dtype,
chunks=(4, 4), zarr_format=3,
compressors=BloscCodec(cname="zstd", clevel=5, shuffle="bitshuffle"),
dimension_names=("sample", "feature"),
attributes={"units": "arbitrary", "source": "synthetic example"},
)
for start in range(0, z.shape[0], 4):
z[start:start + 4] = expected[start:start + 4]
reopened = zarr.open_array("array.zarr", mode="r")
np.testing.assert_array_equal(reopened[:], expected)
assert reopened.dtype == expected.dtype
assert reopened.metadata.dimension_names == ("sample", "feature")
assert reopened.attrs["units"] == "arbitrary"
subset = reopened[2:6, 1:4] # Only this selection is materialized.
create_array takes either data= or shape= plus dtype=; do not combine data=
with explicit shape/dtype. The format-3 numeric default is a bytes serializer followed
by ZstdCodec, not Blosc. Set a codec explicitly for reproducibility.
Creation and indexing
import numpy as np
import zarr
z = zarr.create_array(None, data=np.arange(80).reshape(10, 8), chunks=(2, 4))
zeros = zarr.zeros((10, 8), chunks=(2, 4), dtype="f4")
ones = zarr.ones((10, 8), chunks=(2, 4), dtype="f4")
filled = zarr.full((10, 8), fill_value=42, chunks=(2, 4), dtype="i4")
like = zarr.zeros_like(z)
np.testing.assert_array_equal(filled[:], np.full((10, 8), 42))
# Coordinate indexing pairs corresponding coordinates; orthogonal indexing is a product.
np.testing.assert_array_equal(z.vindex[[0, 5], [2, 7]], [2, 47])
np.testing.assert_array_equal(z.get_coordinate_selection(([0, 5], [2, 7])), [2, 47])
assert z.oindex[[0, 5], [2, 7]].shape == (2, 2)
assert z.blocks[0, 0].shape == (2, 4)
z[0, :] = np.arange(8)
Negative-step slices are unsupported. Array reads return NumPy data in the default CPU
configuration. np.asarray(z), np.sum(z), z[:], or a Dask .compute() of a full array
can materialize the entire logical dataset; use bounded selections or lazy reductions.
Resize and append
import numpy as np
import zarr
…
자주 묻는 질문
'청크'란 무엇인가요?
데이터를 관리하고 접근하기 쉽도록 나눈 작은 조각이나 블록입니다.
클라우드 데이터에도 쓸 수 있나요?
네, Zarr-Python은 Amazon S3와 Google Cloud Storage 같은 클라우드 서비스의 저장소를 지원합니다.
어떤 Python 라이브러리를 사용하나요?
과학 계산에서 흔히 쓰는 NumPy, Dask, Xarray 같은 인기 라이브러리와 잘 통합됩니다.
상세 정보
작성자의 원본 설명
Stores and queries chunked N-D scientific arrays with Zarr-Python 3, including codecs, sharding, S3/GCS storage, and NumPy/Dask/Xarray integration. Use for array layout, bounded I/O, format migration, or scientific metadata preservation.
인기도
- GitHub 스타
- 51k
- 순위
- #3595
- 라이선스
- MIT
- 업데이트
- 2026. 10. 15.
댓글
- …
이 저장소의 다른 스킬
13c-metabolic-flux
51k탄소-13 동위원소 추적 데이터를 사용해 대사 흐름(플럭스)을 추정합니다. 세포 대사와 생화학 경로를 분석할 때 유용합니다.
adaptyv
51kAdaptyv API를 사용해 단백질 특성 분석 실험을 설계합니다. 비용을 추정하고, 서열을 제출하며, 실험실 결과를 확인하는 데 도움이 됩니다.
aeon
51k시계열 데이터에 대해 머신러닝 작업을 수행합니다. 순차 데이터를 분류하고, 예측하고, 이상을 탐지하고, 패턴을 찾을 때 유용합니다.
alphagenome
51k유전 변이에 대해 미리 계산된 게놈 영향을 조회합니다. 변이가 게놈에 주는 영향을 이해하도록 점수와 설명을 제공합니다.
비슷한 스킬
discrawl
394k에이전트가 저장된 로컬 Discord 메시지 보관본을 검색하고 요약하며, 최신 상태를 확인하고 다이렉트 메시지를 읽도록 돕습니다.
clickhouse-io
280k에이전트가 ClickHouse 데이터베이스의 쿼리와 스키마를 최적화하도록 돕습니다. 고성능 분석 작업의 모범 사례를 적용합니다. 분석 쿼리가 느릴 때 씁니다.
scientific-db-pubmed-database
280k생의학 분야의 과학 논문을 에이전트가 검색하도록 돕습니다. 특정 의학 정보가 필요한 연구에 유용합니다.