Metadata-Version: 2.4
Name: moczarr
Version: 0.3.0
Summary: Sparse-DGGS xarray reader for morton-hive zarr stores (MOC domain, lazy dense views)
Project-URL: Homepage, https://github.com/espg/moczarr
Project-URL: Documentation, https://espg.github.io/moczarr/
Project-URL: Repository, https://github.com/espg/moczarr
Project-URL: Issues, https://github.com/espg/moczarr/issues
Project-URL: Changelog, https://github.com/espg/moczarr/blob/main/CHANGELOG.md
Author-email: Shane Grigsby <refuge@rocktalus.com>
License: MIT License
        
        Copyright (c) 2026 Shane
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: GIS
Requires-Python: >=3.12
Requires-Dist: mortie>=0.9.3
Requires-Dist: numcodecs>=0.14
Requires-Dist: numpy>=2.0
Requires-Dist: obstore>=0.8.2
Requires-Dist: pandas
Requires-Dist: xarray>=2026.01.0
Requires-Dist: zarr>=3.1.5
Provides-Extra: test
Requires-Dist: pytest-cov; extra == 'test'
Requires-Dist: pytest>=8.0; extra == 'test'
Provides-Extra: xdggs
Requires-Dist: shapely; extra == 'xdggs'
Requires-Dist: xdggs>=0.6; extra == 'xdggs'
Provides-Extra: zagg
Requires-Dist: zagg>=0.40; extra == 'zagg'
Description-Content-Type: text/markdown

# moczarr

[![Docs](https://github.com/espg/moczarr/actions/workflows/docs.yml/badge.svg)](https://espg.github.io/moczarr/)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/espg/moczarr/main?labpath=docs%2Fexamples%2Fquickstart.ipynb)

Sparse-DGGS xarray reader for **morton-hive** zarr stores: MOC-declared
domains, arithmetic shard paths, lazy dense views.

`moczarr` opens stores written by [zagg](https://github.com/englacial/zagg)
under the morton-hive layout convention: a digit tree of self-describing
zarr v3 leaves keyed by morton decimal ids, with a static manifest and
hierarchical coverage MOCs declaring where data exists — so a reader
intersects an area of interest *arithmetically* instead of listing objects
or materializing a global grid.

```python
import moczarr

ds = moczarr.open_hive("s3://bucket/prefix", aoi=["433142"], anonymous=True)
```

## Features

- **`open_hive()`** — one call from store root (local path or
  `s3://bucket/prefix`) to a lazy `xarray.Dataset`; AOI covers (packed
  morton words or decimal strings, mixed orders) and time-window scoping
  resolve through coverage metadata, not object listings. An AOI over no
  coverage is a data answer: a schema-correct empty dataset, not an error.
- **A MOC-backed lazy index** (the default) — the row domain held as a
  rank-space interval set built from the same coverage arithmetic that
  selected the leaves; the on-disk cell arrays are never read, and the
  `morton` coordinate is fabricated on demand (`sel`/`isel`/alignment as
  interval arithmetic; `index_kind="pandas"` materializes instead).
- **Exact NESTED fabrication** — HEALPix NESTED `cell_ids` derived exactly
  from the packed morton words ("NESTED is fabricated, never stored").
- **Cross-resolution joins** — morton truncation makes coarse↔fine work a
  vectorized lookup: `parent_cells` for fine→coarse groupby aggregation,
  `join_coarse` for the coarse→fine broadcast, no I/O.
- **xdggs integration** (`moczarr[xdggs]`) — a registered `"morton"` grid,
  so `ds.dggs.sel_latlon`, `cell_boundaries`, `zoom_to` work on any
  `open_hive` result.

Docs: [espg.github.io/moczarr](https://espg.github.io/moczarr/) —
quickstart, concepts, API reference, and the
[example notebook](https://espg.github.io/moczarr/examples/quickstart/)
(runnable on binder via the badge above).

## Install

```sh
pip install moczarr            # core reader
pip install 'moczarr[xdggs]'   # + the ds.dggs accessor integration
```

Until the first PyPI release lands, install from git:

```sh
pip install 'moczarr[xdggs] @ git+https://github.com/espg/moczarr'
```

Development (uses [uv](https://docs.astral.sh/uv/)):

```sh
uv sync --extra test --extra xdggs
uv run pytest -v
```

## The convention

moczarr is the read side of a convention owned elsewhere: the morton-hive
layout and morton decimal ids are specified in the
[mortie specification](https://github.com/espg/mortie/blob/main/docs/specification.md),
and the coverage tiers, commit-stamp semantics, and reader architecture in
[zagg's `sparse_coverage.md`](https://github.com/englacial/zagg/blob/main/docs/design/sparse_coverage.md)
(§4 coverage, §5 reader, §6 xarray extension). Plan and progress:
[espg/moczarr#1](https://github.com/espg/moczarr/issues/1).

## License

MIT
