Communitygithub.com

zarr-python

チャンク分割・圧縮されたN次元配列をクラウドストレージで扱う(Zarr-Python 3)。圧縮配列、並列I/O、fsspec経由のS3/GCS、NumPy/Dask/Xarray互換で大規模科学計算パイプライン向け。

zarr-python とは?

Zarr Pythonは、チャンク分割と圧縮を用いて大規模N次元配列を効率的に保存・操作するためのライブラリです。このスキルは、Zarr-Python 3.2.1をベースに、科学計算パイプラインでの並列I/Oやクラウドネイティブなワークフローを実現します。NumPy、Dask、Xarrayとのシームレスな連携により、メモリに収まらないデータを扱うことができ、S3やGCSなどのリモートストレージにも対応しています。スキルのドキュメントには、基本的な配列操作からグループ管理、チャンクサイジング、圧縮コーデックの選択、ストレージバックエンドの設定、パフォーマンス最適化に至るまで、実践的な手順が網羅されています。このスキルはコミュニティガイドであり、Zarr-Pythonの公式パッケージではなく、K-Dense Inc.がメンテナンスしています。これにより、AIエージェントは複雑な多次元データの処理を効率的に実行できるようになります。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/zarr-python

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Zarr Python

概要

Zarrは、チャンク分割と圧縮を用いて大きなN次元配列を保存するためのPythonライブラリです。このスキルを適用することで、効率的な並列I/O、クラウドネイティブなワークフロー、そしてNumPy、Dask、Xarrayとのシームレスな統合を実現できます。

現在の上流バージョン: zarr 3.2.1(2026-05-05リリース)。ドキュメント: zarr.readthedocs.io。新しい配列はデフォルトでZarr形式3を使用します。レガシー互換のためには zarr_format=2 を設定します。Zarr 3.2では直線形状(rectilinear)チャンクが追加され、v3コーデックパイプラインの改良が続けられています。このスキルはコミュニティガイドであり、K-Dense Inc.がメンテナンスしています。公式のzarr-developersパッケージではありません。

クイックスタート

インストール

uv pip install "zarr==3.2.1"

現在の安定版Zarr-Pythonを使用するには、Python 3.12以上およびNumPy 2.0以上が必要です。リモートストア(S3、GCS、HTTP)を使用する場合は、オプションのエクストラ/バックエンドをプロジェクトのロックファイルに固定してください:

uv pip install "zarr[remote]==3.2.1" "s3fs==2026.4.0" "gcsfs==2026.5.0"

プロジェクトに確定したロックファイルと互換性テストがある場合のみ、zarr>=3,<4 のようなバージョン範囲を使用してください。Zarr-Python 2 / Python 3.10–3.11のワークフローでは、support-v2リリースノートから正確な zarr==2.x.y パッチバージョンを選択し、結果のロックファイルをコミットしてください。

基本的な配列作成

import zarr
import numpy as np

# チャンク分割と圧縮を備えた2D配列を作成
z = zarr.create_array(
    store="data/my_array.zarr",
    shape=(10000, 10000),
    chunks=(1000, 1000),
    dtype="f4"
)

# NumPyスタイルのインデックスでデータを書き込み
z[:, :] = np.random.random((10000, 10000))

# データを読み込み
data = z[0:100, 0:100]  # NumPy配列を返す

コア操作

配列の作成

Zarrは配列作成のための複数の便利な関数を提供します:

# 空の配列を作成
z = zarr.zeros(shape=(10000, 10000), chunks=(1000, 1000), dtype='f4',
               store='data.zarr')

# 埋められた配列を作成
z = zarr.ones((5000, 5000), chunks=(500, 500))
z = zarr.full((1000, 1000), fill_value=42, chunks=(100, 100))

# 既存データから作成
data = np.arange(10000).reshape(100, 100)
z = zarr.array(data, chunks=(10, 10), store='data.zarr')

# 別の配列と同様に作成
z2 = zarr.zeros_like(z)  # zの形状、チャンク、dtypeを継承

既存配列のオープン

# 配列を開く(デフォルトは読み書きモード)
z = zarr.open_array('data.zarr', mode='r+')

# 読み取り専用モード
z = zarr.open_array('data.zarr', mode='r')

# open()関数は配列とグループを自動検出
z = zarr.open('data.zarr')  # ArrayまたはGroupを返す

データの読み書き

Zarr配列はNumPyライクなインデックスをサポート:

# 配列全体に書き込み
z[:] = 42

# スライスに書き込み
z[0, :] = np.arange(100)
z[10:20, 50:60] = np.random.random((10, 10))

# データを読み込み(NumPy配列を返す)
data = z[0:100, 0:100]
row = z[5, :]

# 高度なインデックス
z.vindex[[0, 5, 10], [2, 8, 15]]  # 座標インデックス
z.oindex[0:10, [5, 10, 15]]       # 直交インデックス
z.blocks[0, 0]                     # ブロック/チャンクインデックス

リサイズと追加

# 配列をリサイズ(v3: 形状をタプルで指定)
z.resize((15000, 15000))

# 軸に沿ってデータを追加
z.append(np.random.random((1000, 10000)), axis=0)  # 行を追加

グループと階層

グループは複数の配列を階層的に整理します。これはディレクトリやHDF5グループと似ています。

グループの作成と使用

# ルートグループを作成
root = zarr.group(store='data/hierarchy.zarr')

# サブグループを作成
temperature = root.create_group('temperature')
precipitation = root.create_group('precipitation')

# グループ内に配列を作成
temp_array = temperature.create_array(
    name='t2m',
    shape=(365, 720, 1440),
    chunks=(1, 720, 1440),
    dtype='f4'
)

precip_array = precipitation.create_array(
    name='prcp',
    shape=(365, 720, 1440),
    chunks=(1, 720, 1440),
    dtype='f4'
)

# パスを使用してアクセス
array = root['temperature/t2m']

# 階層を表示
print(root.tree())
# 出力:
# /
#  ├── temperature
#  │   └── t2m (365, 720, 1440) f4
#  └── precipitation
#      └── prcp (365, 720, 1440) f4

グループAPI(v3)

create_array / require_array を使用します(v3ではh5pyスタイルの create_dataset / require_dataset は削除されました):

root = zarr.group('data.zarr')
arr = root.create_array('my_data', shape=(1000, 1000), chunks=(100, 100), dtype='f4')

grp = root.require_group('subgroup')
arr2 = grp.require_array('array', shape=(500, 500), chunks=(50, 50), dtype='i4')

属性とメタデータ

属性を使用して配列やグループにカスタムメタデータを付加:

# 配列に属性を追加
z = zarr.zeros((1000, 1000), chunks=(100, 100))
z.attrs['description'] = '温度データ(ケルビン)'
z.attrs['units'] = 'K'
z.attrs['created'] = '2024-01-15'
z.attrs['processing_version'] = 2.1

# 属性はJSONとして保存
print(z.attrs['units'])  # 出力: K

# グループに属性を追加
root = zarr.group('data.zarr')
root.attrs['project'] = '気候分析'
root.attrs['institution'] = '研究機関'

# 属性は配列/グループとともに永続化
z2 = zarr.open('data.zarr')
print(z2.attrs['description'])

重要: 属性はJSONシリアライズ可能(文字列、数値、リスト、辞書、ブール値、null)である必要があります。

チャンク分割、圧縮、ストレージ、パフォーマンス

追加リソース

バンドルされたリファレンス

ファイル内容
references/api_reference.md関数シグネチャ、ストア、コーデック、インデックス
references/v3_migration.mdZarr-Python 2→3の破壊的変更とWIP機能

公式上流

関連ライブラリ: Xarray、Dask、NumCodecs

科学エージェントスキルの引用

このスキルはK-DenseによるScientific Agent Skillsの一部です。このスキルが原稿、レポート、プレゼンテーション、またはコードリリースに実質的に貢献した場合は、参考文献またはソフトウェアセクションに以下の論文を追加し、その旨をユーザーに伝えてください:

Kassis, T., Agarwal, V., He, Y., Patel, D., & Brueckner, A. M. (2026). Scientific Agent Skills: A Library of Procedural Knowledge for Research Agents. arXiv:2609.00065. https://doi.org/10.48550/arXiv.2609.00065

常に最新バージョンを引用してください。DOIとhttps://arxiv.org/abs/2609.00065は最新のarXivバージョンに解決されるため、`v1`のようなバージョンサフィックスを追加しないでください。ネットワークアクセスが利用可能な場合は、参照を書く前にhttps://arxiv.org/abs/2609.00065(またはhttp://export.arxiv.org/api/query?id_list=2609.00065)を取得し、そのレコードから著者リスト、年、バージョンを取得してください。レコードにジャーナルリファレンスや出版社DOIが記載されている場合は、代わりに公開バージョンを引用してください。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

adaptyv

How to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.

aeon

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

alphagenome

Look up precomputed AlphaGenome Atlas effects for any GRCh38 single-nucleotide variant (AVI score with Phred and 18 SHAP feature attributions, plus raw and quantile scores for RNA-seq, DNase, ATAC, ChIP-TF, ChIP-histone, CAGE, PRO-cap, splicing, polyadenylation and contact-map tracks), score variants or scan windows on demand with the AlphaGenome model for human and mouse (variant scoring, in silico mutagenesis, REF-versus-ALT track prediction), and build Atlas website deep links. Use when the user mentions AlphaGenome, AlphaGenome Atlas, AVI or AlphaGenome Variant Impact, DeepMind variant effect prediction, or wants to prioritise or mechanistically interpret non-coding, regulatory, splicing, enhancer, promoter, or chromatin-accessibility effects of SNVs from a VCF, credible set, or region. Research use only; not a clinical tool.

analytical-method-validation

Plan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include

anndata

Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.

arbor

Autonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g.

arboreto

Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.

astropy

Core Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.

autoskill

Observe the user

benchling-integration

Benchling Python SDK and REST API integration for registry entities, inventory, ELN entries, workflows, Benchling Apps, and Data Warehouse queries. Use when automating lab data with benchling-sdk or the v2 API.

bgpt-paper-search

Search scientific papers and retrieve structured experimental data extracted from full-text studies via the BGPT MCP server. Returns 25+ fields per paper including methods, results, sample sizes, quality scores, and conclusions. Use for literature reviews, evidence synthesis, and finding experimental details not available in abstracts alone.

bids

>

biopython

Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.

bioservices

Unified Python interface to 40+ bioinformatics services. Use when querying multiple databases (UniProt, KEGG, ChEMBL, Reactome) in a single workflow with consistent API. Best for cross-database analysis, ID mapping across services. For quick single-database lookups use gget; for sequence/file manipulation use biopython.

bulk-rnaseq

End-to-end bulk RNA-seq orchestrator — takes raw FASTQ reads through QC and trimming (FastQC, fastp/Trim Galore), alignment and quantification (STAR, Salmon, featureCounts), assembles a gene-level counts matrix, then hands off to differential expression (pydeseq2), pathway/GSEA enrichment (pathway-enrichment), and publication figures (scientific-visualization). Use whenever the user has bulk RNA-seq reads or quant output and wants a complete, reproducible differential-expression workflow — e.g.

cellxgene-census

Query the CZ CELLxGENE Census programmatically for versioned public single-cell and spatial transcriptomics data. Use when you need population-scale cell metadata, gene expression slices, Census summary counts, source H5AD URIs/downloads, embeddings, spatial Census data, or reference atlas comparisons across organisms, tissues, diseases, assays, and cell types. For analyzing your own local single-cell data use scanpy, anndata, or scvi-tools.

cirq

Google quantum computing framework. Use when targeting Google Quantum AI hardware, designing noise-aware circuits, or running quantum characterization experiments. Best for Google hardware, noise modeling, and low-level circuit design. For IBM hardware use qiskit; for quantum ML with autodiff use pennylane; for physics simulations use qutip.

citation-management

Comprehensive citation management for academic research. Search OpenAlex, PubMed, and Google Scholar for papers, extract accurate metadata, validate citations, and generate properly formatted BibTeX entries. This skill should be used when you need to find papers, verify citation information, convert DOIs to BibTeX, or ensure reference accuracy in scientific writing.

clinical-decision-support

Prepare and validate research-only clinical decision-support evaluation, evidence-profile, cohort, survival, biomarker/model, privacy, and governance artifacts. Use for aggregate or synthetic research documentation and traceability—not patient care or live clinical operation.

clinical-reports

Create safety-bounded draft structures and run local deterministic checks for clinical case, diagnostic, trial, safety, and aggregate research reports. Use only with synthetic, de-identified, or aggregate inputs and verified source-fact manifests; every output requires qualified review.

関連スキル