Skip to main content

Pure Python generation of ICON-style triangular grids

Project description

ICON Grid Generator

Tests Docs PyPI Python License

Pure Python generation of ICON-style triangular grids.

Global ICON grid resolutions

ICON Grid Generator creates spherical ICON R<n>B<k> grids, planar triangular grids, limited-area extracts, and ICON-style NetCDF files without depending on ICON model runtimes or stencil frameworks.

Features

  • Generate global spherical ICON grids from names such as R2B3, canonicalized to zero-padded names such as R02B03.
  • Generate planar doubly periodic torus grids and additional planar variants.
  • Extract limited-area grids from generated global parent grids.
  • Export ICON-style NetCDF grid files with optional netCDF4 support.
  • Inspect in-memory topology, connectivity, geometry, refinement, and metadata arrays for plotting or downstream conversion.
  • Run lightweight diagnostics and deterministic geometry postprocessing.

Installation

From a local checkout:

python -m pip install -e .

Install optional NetCDF and xarray support with:

python -m pip install -e ".[netcdf,xarray]"

Install optional Numba acceleration support with:

python -m pip install -e ".[accelerate]"

Install development dependencies with:

python -m pip install -e ".[test,docs]"

Grid Naming

The ICON documentation describes grid file names with the generic nomenclature R<n>B<k>, where n is the number of root divisions and k is the number of subsequent bisections. ICON examples also commonly use zero-padded grid file names such as R02B06. This package accepts both compact names (R2B6) and zero-padded names (R02B06), then stores labels and metadata in the zero-padded form.

Quick Start

Generate a global spherical grid:

from grid_generator import generate_grid

grid = generate_grid("R2B3")
print(grid.name)
print(grid.dims)

Example output:

R02B03
{'cell': 1280, 'vertex': 642, 'edge': 1920}

Generate a planar torus grid:

from grid_generator import TorusGridSpec, generate_grid

grid = generate_grid(TorusGridSpec(nx=32, ny=16, edge_length=1_000.0))
print(grid.metadata["grid_geometry"])
print(grid.metadata["domain_length"])

Extract a limited-area grid from a generated global parent:

from grid_generator import LimitedAreaGridSpec, generate_grid

spec = LimitedAreaGridSpec(
    "R02B03",
    lon_min=-20.0,
    lon_max=20.0,
    lat_min=35.0,
    lat_max=60.0,
    boundary_depth=2,
)
grid = generate_grid(spec, options={"max_cells": None})
print(grid.dims)

Write an ICON-style NetCDF file:

grid.to_netcdf("grid.nc")

NetCDF export requires the netcdf optional extra.

Documentation

The minimal documentation lives in docs:

To preview the docs locally:

mkdocs serve

Development

See CONTRIBUTING.md for contribution guidelines, review expectations, and domain-specific requirements for grid math and NetCDF changes.

Run the checks used by CI:

python -m ruff check .
python -m pytest

The package is laid out as a standalone Python project. If this directory is split out of a larger checkout, keep .github/, docs/, CITATION.cff, CHANGELOG.md, LICENSE, README.md, mkdocs.yml, pyproject.toml, src/, and tests/ at the new repository root.

Citation

If you use ICON Grid Generator in published work, cite it using CITATION.cff. For research releases, connect the public GitHub repository to Zenodo before creating a GitHub Release so a DOI can be minted.

Release History

See CHANGELOG.md.

License

ICON Grid Generator is distributed under the BSD 3-Clause License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

icon_grid_generator-0.2.0.tar.gz (995.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

icon_grid_generator-0.2.0-py3-none-any.whl (49.1 kB view details)

Uploaded Python 3

File details

Details for the file icon_grid_generator-0.2.0.tar.gz.

File metadata

  • Download URL: icon_grid_generator-0.2.0.tar.gz
  • Upload date:
  • Size: 995.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for icon_grid_generator-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1209fd3239f874a26da4d48f3d399a8cbb94709ddb6ead01df290f71c9dafa6f
MD5 c8e7d5ba3ef4507f67873cee32eab9c8
BLAKE2b-256 5f5e67ff7a136c72d945600f1ae1ea8e468777cc1eb9b430f9c82cfbf84ff051

See more details on using hashes here.

Provenance

The following attestation bundles were made for icon_grid_generator-0.2.0.tar.gz:

Publisher: release.yml on ofuhrer/icon-grid-generator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file icon_grid_generator-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for icon_grid_generator-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1846a9da3fb4c262c4d3e84a51521a16bce884571fae0f2a87a554fc34054c2c
MD5 22789080dd262c26d292681f7203937b
BLAKE2b-256 1543ed51f86ea5d03e812caac2bd540a4015815402c820947d5d207180a20f88

See more details on using hashes here.

Provenance

The following attestation bundles were made for icon_grid_generator-0.2.0-py3-none-any.whl:

Publisher: release.yml on ofuhrer/icon-grid-generator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page