Skip to main content

rHEALPixDGGS

PyPI conda-forge Documentation Tests codecov manaakiwhenua-standards

Introduction

rHEALPixDGGS is a Python package that implements the rHEALPix Discrete Global Grid System (DGGS). rHEALPix stands for rearranged Hierarchical Equal Area isoLatitude Pixelization. HEALPix is an equal-area pixelization of the sphere from astronomy whose pixel centres lie on rings of constant latitude. rHEALPix rearranges its planar projection so that the globe unfolds into six equal squares.

The projection maps points between the ellipsoid and the plane. The grid system is built on top of it. Each square is divided into N_side × N_side equal children, and so on recursively, so every point on Earth lies in one cell at each resolution and all cells of a resolution have the same area. A cell is named by an identifier such as P40: a letter for its base square and one digit per level. Parents, children, neighbours and the topological relations between cells are computed from these identifiers. The projection is implemented in rhealpixdggs.pj_rhealpix; the grid system is rhealpixdggs.dggs.RHEALPixDGGS, with parameters N_side, the placement of the polar squares and the ellipsoid's central meridian.

Standards conformance

rHEALPixDGGS implements code to both define an rHEALPix DGGS Reference System and to perform topological queries on its identifiers. Our roadmap is for v1.0 to be fully compliant with OGC Topic 21 v2.0 / ISO 19170-1:2020. The requirement-by-requirement status is maintained in docs/source/conformance.rst.

Release Notes

This package was originally authored by Alexander Raichev in 2013 and is actively maintained. See CHANGES.rst for the release history, including explicit callouts of any breaking changes.

Error Budget

rHEALPix is a theoretically equal-area projection: all cells at a given resolution have the same area by construction. In practice, floating-point arithmetic introduces a small rounding error when computing cell areas. The RHEALPixDGGS.area_error_budget() method returns these values analytically for the default WGS84-based DGGS (WGS84_003, N_side=3, max_areal_resolution=1 m²):

Resolution Cell area (m²) Cell area (km²) Abs. tolerance (m²)
0 8.501 × 10¹³ 85,010,937 0.189
1 9.446 × 10¹² 9,445,660 0.021
2 1.050 × 10¹² 1,049,518 0.0023
3 1.166 × 10¹¹ 116,613 2.59 × 10⁻⁴
4 1.296 × 10¹⁰ 12,957 2.88 × 10⁻⁵
5 1.440 × 10⁹ 1,440 3.20 × 10⁻⁶
6 1.600 × 10⁸ 160 3.55 × 10⁻⁷
7 1.777 × 10⁷ 17.8 3.95 × 10⁻⁸
8 1.975 × 10⁶ 1.97 4.39 × 10⁻⁹
9 2.194 × 10⁵ 0.219 4.87 × 10⁻¹⁰
10 2.438 × 10⁴ 0.0244 5.41 × 10⁻¹¹
11 2,709 0.00271 6.02 × 10⁻¹²
12 301 3.01 × 10⁻⁴ 6.68 × 10⁻¹³
13 33.4 3.34 × 10⁻⁵ 7.43 × 10⁻¹⁴
14 3.72 3.72 × 10⁻⁶ 8.25 × 10⁻¹⁵
15 0.413 4.13 × 10⁻⁷ 9.17 × 10⁻¹⁶

The absolute tolerance answers the question: "how different can two computed cell areas be before we should conclude they are genuinely different, rather than just floating-point noise?" For example, at resolution 9 the tolerance is ~5 × 10⁻¹⁰ m² — if two cells' computed areas differ by less than half a nanometre squared, they should be treated as equal-area.

The relative tolerance is constant at 2.22 × 10⁻¹⁵ (10 × machine epsilon) for all resolutions, reflecting the fixed number of floating-point operations in the area formula. The absolute tolerance shrinks proportionally with cell area as resolution increases. Resolution 15 is the finest level supported by the default configuration (cells of approximately 0.41 m²).

Requirements

Dependencies are declared in pyproject.toml (this project is managed with Poetry; development dependencies are declared there too, under tool.poetry.group.dev.dependencies):

Installation

This package is available on PyPI, the Python Package Index from where it can be installed as follows:

pip install rhealpixdggs

Spherical harmonic transforms on the grid (rhealpixdggs.harmonics) need ducc0, which the harmonics extra brings:

pip install "rhealpixdggs[harmonics]"

rHEALPixDGGS is also available for download from the GitHub repository https://github.com/manaakiwhenua/rhealpixdggs-py from where the latest version can be cloned.

You can install from source using Poetry in a virtual environment (MacOS and Linux, assuming Poetry is already installed on your system):

python3 -m venv rhealpixdggs
source rhealpixdggs/bin/activate
python -m pip install --upgrade pip
poetry install

Or on Windows:

python3 -m venv rhealpixdggs
rhealpixdggs\Scripts\activate
python -m pip install --upgrade pip
poetry install

For development:

poetry shell
poetry install

Tests

The files in the tests directory test the rHEALPixDGGS modules. These files are plain unittest files (the Python testing framework contained within the standard distribution), and the examples embedded in docstrings are tested with doctest (also part of the standard distribution).

Two UNIX shell scripts are included in this repository to run all unit and doc tests:

  • scripts/run_doctests.sh
  • scripts/run_unittests.sh

Running the command python tests/test_<foo>.py performs a sequence of automated tests of <foo>.py.

For example, tests/test_cell.py automatically tests cell.py.

If you update a module, then update its test file to test the changes you made!

Test early, test often, test automatically!

There are a couple of files in the main package directory that can be used to run all tests, starting run_....

Documentation

The manual for the current master branch is published at https://manaakiwhenua.github.io/rhealpixdggs-py/. It is built with Sphinx from docs/source and the package docstrings, and redeployed by the Docs workflow on every push to master.

To build it yourself, with Sphinx and the furo theme installed (both are in the dev dependency group), run make html from the docs directory, or make latexpdf for the PDF manual, which also needs LaTeX. The output lands in docs/build.

The system itself is described in The rHEALPix Discrete Global Grid System.

License

This code is dual-licensed. You may choose to use it under either:

See the file LICENSE for more information about the dual licensing arrangement.

This dual licensing approach allows the software to be used in contexts where LGPL may not be permitted (such as certain corporate environments or standards bodies like the OGC) while still maintaining a copyleft option for those who prefer it.

Releasing

See RELEASING.md for the release process. Note that working with this repository's packaging (poetry install, poetry build, ...) requires Poetry version 2.0 or later.

A conda package rhealpixdggs is also maintained at conda-forge.

Contact

Maintainer:
Richard Law
Bioeconomy Science Institute
lawr@landcareresearch.co.nz

Release Manager:
Dr Nicholas J. Car
SURROUND Australia Pty Ltd
nicholas.car@surroundaustralia.com

Original author:
Alexander Raichev
https://raichev.net/
alex@raichev.net

Former Maintainer:
Robert Gibb
Manaaki Whenua – Landcare Research
gibbr@landcareresearch.co.nz

Metadata

Release files for rHEALPixDGGS 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rHEALPixDGGS 0.9.0
File Size Uploaded
rhealpixdggs-0.9.0.tar.gz 3.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for rHEALPixDGGS 0.9.0
File Interpreter ABI Platform
rhealpixdggs-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 3.9 MB

Release files / rhealpixdggs-0.9.0.tar.gz

Download URL rhealpixdggs-0.9.0.tar.gz
Size 3.8 MB
Tags Source
SHA-256 checksum
How to use checksums
a2815c4366b5a325ccd929087ec41d40d474545dfe2f79b60e356065481fcc5c
BLAKE2b-256 checksum
How to use checksums
264fedb18892c224d8460c482cf77e25babdccee1c75adad1744c7f431634e5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.2 CPython/3.11.12 Linux/5.15.0-171-generic

Release files / rhealpixdggs-0.9.0-py3-none-any.whl

Download URL rhealpixdggs-0.9.0-py3-none-any.whl
Size 120.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed1104f3babda84615a1d994fd1eab3320624a7c3afbd9ea19442cf6c9a0eaa8
BLAKE2b-256 checksum
How to use checksums
d2c7c1406d3484508f3b2c4ddb3b6687afe8b4553b669920ad64fb146062f708
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.2 CPython/3.11.12 Linux/5.15.0-171-generic

Release history Release notifications | RSS feed

0.11.0

2 release files

0.10.0

2 release files

This release

0.9.0 This release

2 release files

0.8.6

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.13

2 release files

0.5.12

2 release files

0.5.10

2 release files

0.5.9

2 release files

0.5.8

1 release file

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page