Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ coverage.xml
# Sphinx documentation
docs/_build/
docs/_autoapi
docs/data
data

# PyBuilder
target/
Expand Down
1 change: 0 additions & 1 deletion data/donotdelete

This file was deleted.

5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"sphinx_copybutton",
"sphinx_design",
'sphinx_reredirects',
"IPython.sphinxext.ipython_directive",
"IPython.sphinxext.ipython_console_highlighting",
]

issues_github_path = "zarr-developers/zarr-python"
Expand Down Expand Up @@ -87,7 +89,8 @@
"spec/v1": 'https://zarr-specs.readthedocs.io/en/latest/v1/v1.0.html',
"spec/v2": "https://zarr-specs.readthedocs.io/en/latest/v2/v2.0.html",
"spec/v3": "https://zarr-specs.readthedocs.io/en/latest/v3/core/v3.0.html",
"license": "https://github.com/zarr-developers/zarr-python/blob/main/LICENSE.txt"
"license": "https://github.com/zarr-developers/zarr-python/blob/main/LICENSE.txt",
"tutorial": "user-guide",
}

# The language for content autogenerated by Sphinx. Refer to documentation
Expand Down
46 changes: 0 additions & 46 deletions docs/getting_started.rst

This file was deleted.

9 changes: 0 additions & 9 deletions docs/guide/index.rst

This file was deleted.

72 changes: 41 additions & 31 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,64 +8,62 @@ Zarr-Python
:maxdepth: 1
:hidden:

getting_started
tutorial
guide/index
quickstart
about
user-guide/index
api/index
release
contributing
roadmap
developers/index
developers/release

**Version**: |version|

**Download documentation**: `PDF/Zipped HTML <https://readthedocs.org/projects/zarr/downloads/>`_

**Useful links**:
`Installation <installation.html>`_ |
`Source Repository <https://github.com/zarr-developers/zarr-python>`_ |
`Issue Tracker <https://github.com/zarr-developers/zarr-python/issues>`_ |
`Zulip Chat <https://ossci.zulipchat.com/>`_ |
`Zarr specifications <https://zarr-specs.readthedocs.io>`_
Zarr is a storage format for chunked, compressed, N-dimensional arrays based on an open-source specification. Highlights include:

Zarr is a file storage format for chunked, compressed, N-dimensional arrays based on an open-source specification.
* Create N-dimensional arrays with any NumPy dtype.
* Chunk arrays along any dimension.
* Compress and/or filter chunks using any NumCodecs_ codec.
* Store arrays in memory, on disk, inside a Zip file, on S3, ...
* Read an array concurrently from multiple threads or processes.
* Write to an array concurrently from multiple threads or processes.
* Organize arrays into hierarchies via groups.

.. grid:: 2

.. grid-item-card::
:img-top: _static/index_getting_started.svg

Getting Started
^^^^^^^^^^^^^^^
Quick Start
^^^^^^^^^^^

New to Zarr? Check out the getting started guide. It contains an
New to Zarr? Check out the quick start guide. It contains a brief
introduction to Zarr's main concepts and links to additional tutorials.

+++

.. button-ref:: getting_started
.. button-ref:: quickstart
:expand:
:color: dark
:click-parent:

To the getting started guide
To the Quick Start

.. grid-item-card::
:img-top: _static/index_user_guide.svg

Tutorial
^^^^^^^^
Guide
^^^^^

The tutorial provides working examples of Zarr classes and functions.
The user guide provides a detailed guide for how to use Zarr-Python.

+++

.. button-ref:: tutorial
.. button-ref:: user-guide
:ref-type: ref
:expand:
:color: dark
:click-parent:

To the Tutorial
To the User Guide

.. grid-item-card::
:img-top: _static/index_api.svg
Expand All @@ -85,21 +83,33 @@ Zarr is a file storage format for chunked, compressed, N-dimensional arrays base
:color: dark
:click-parent:

To the api reference guide
To the API reference guide

.. grid-item-card::
:img-top: _static/index_contribute.svg

Contributor's Guide
^^^^^^^^^^^^^^^^^^^
Developer's Guide
^^^^^^^^^^^^^^^^^

Want to contribute to Zarr? We welcome contributions in the form of bug reports, bug fixes, documentation, enhancement proposals and more. The contributing guidelines will guide you through the process of improving Zarr.
Want to contribute to Zarr? We welcome contributions in the form of bug reports,
bug fixes, documentation, enhancement proposals and more. The contributing
guidelines will guide you through the process of improving Zarr.

+++

.. button-ref:: contributing
.. button-ref:: developers/index
:expand:
:color: dark
:click-parent:

To the contributor's guide
To the developers's guide

**Useful links**:
`Source Repository <https://github.com/zarr-developers/zarr-python>`_ |
`Issue Tracker <https://github.com/zarr-developers/zarr-python/issues>`_ |
`Zulip Chat <https://ossci.zulipchat.com/>`_ |
`Zarr specifications <https://zarr-specs.readthedocs.io>`_

**Download documentation**: `PDF/Zipped HTML <https://readthedocs.org/projects/zarr/downloads/>`_

.. _NumCodecs: https://numcodecs.readthedocs.io
170 changes: 170 additions & 0 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
.. ipython::
:suppress:

In [999]: rm -r data/

In [999]: import numpy as np

In [999]: np.random.seed(0)

Quickstart
==========

Welcome to the Zarr-Python Quickstart guide! This page will help you get up and running with
the Zarr library in Python to efficiently manage and analyze multi-dimensional arrays.

Zarr is a powerful library for storage of n-dimensional arrays, supporting chunking,
compression, and various backends, making it a versatile choice for scientific and
large-scale data.

Installation
------------

Zarr requires Python 3.10 or higher. You can install it via `pip`:

.. code-block:: bash

pip install zarr

or `conda`:

.. code-block:: bash

conda install --channel conda-forge zarr

Creating an Array
-----------------

To get started, you can create a simple Zarr array:

.. ipython:: python

import zarr
import numpy as np

# Create a 2D Zarr array
z = zarr.zeros(
store="data/example-1.zarr",
shape=(100, 100),
chunks=(10, 10),
dtype="f4"
)

# Assign data to the array
z[:, :] = np.random.random((100, 100))
z.info

Here, we created a 2D array of shape ``(100, 100)``, chunked into blocks of
``(10, 10)``, and filled it with random floating-point data. This array was
written to a ``LocalStore`` in the ``data/example-1.zarr`` directory.

Compression and Filters
~~~~~~~~~~~~~~~~~~~~~~~

Zarr supports data compression and filters. For example, to use Blosc compression:

.. ipython:: python

from numcodecs import Blosc

z = zarr.open(
"data/example-3.zarr",
mode="w", shape=(100, 100),
chunks=(10, 10), dtype="f4",
compressor=Blosc(cname="zstd", clevel=3, shuffle=Blosc.SHUFFLE),
zarr_format=2
)
z[:, :] = np.random.random((100, 100))

z.info

This compresses the data using the Zstandard codec with shuffle enabled for better compression.

Hierarchical Groups
-------------------

Zarr allows you to create hierarchical groups, similar to directories:

.. ipython:: python

# Create nested groups and add arrays
root = zarr.group("data/example-2.zarr")
foo = root.create_group(name="foo")
bar = root.create_array(
name="bar", shape=(100, 10), chunks=(10, 10)
)
spam = foo.create_array(name="spam", shape=(10,), dtype="i4")

# Assign values
bar[:, :] = np.random.random((100, 10))
spam[:] = np.arange(10)

# print the hierarchy
root.tree()

This creates a group with two datasets: ``foo`` and ``bar``.

Persistent Storage
------------------

Zarr supports persistent storage to disk or cloud-compatible backends. While examples above
utilized a :class:`zarr.storage.LocalStore`, a number of other storage options are available,
including the :class:`zarr.storage.ZipStore` and :class:`zarr.storage.FsspecStore`.

.. ipython:: python

# Store the array in a ZIP file
store = zarr.storage.ZipStore("data/example-3.zip", mode='w')

z = zarr.open(
store=store,
mode="w",
shape=(100, 100),
chunks=(10, 10),
dtype="f4"
)

# write to the array
z[:, :] = np.random.random((100, 100))

# the ZipStore must be explicitly closed
store.close()

To open an existing array:

.. ipython:: python

# Open the ZipStore in read-only mode
store = zarr.storage.ZipStore("data/example-3.zip", read_only=True)

z = zarr.open(store, mode='r')

# read the data as a NumPy Array
z[:]

Cloud Storage Backends
~~~~~~~~~~~~~~~~~~~~~~

Zarr integrates seamlessly with cloud storage such as Amazon S3 and Google Cloud Storage
using external libraries like `s3fs <https://s3fs.readthedocs.io>`_ or
`gcsfs <https://gcsfs.readthedocs.io>`_.

For example, to use S3:

.. ipython:: python
:verbatim:

import s3fs

z = zarr.open("s3://example-bucket/foo", mode="w", shape=(100, 100), chunks=(10, 10))
z[:, :] = np.random.random((100, 100))

Read more about Zarr's :ref:`tutorial_storage` options in the User Guide.

Next Steps
----------

Now that you're familiar with the basics, explore the following resources:

- `User Guide <user-guide>`_
- `API Reference <api>`_
Loading
Loading