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 spring-relaxed global grids for improved metric quality.
  • 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': 5120, 'vertex': 2562, 'edge': 7680}

Generate a spring-relaxed global grid:

grid = generate_grid("R2B3", options={"max_cells": None, "global_optimization": "spring"})
print(grid.metadata["global_optimization"])

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.1.tar.gz (998.3 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.1-py3-none-any.whl (50.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: icon_grid_generator-0.2.1.tar.gz
  • Upload date:
  • Size: 998.3 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.1.tar.gz
Algorithm Hash digest
SHA256 6cbe1f75d7f14ca8edc6aca7f8686aa4117faf4ec14613f2d8a88bf40d47242d
MD5 9adb380349789f53e4cf4788e1b52879
BLAKE2b-256 d1d51fa1397c043719b388535b70b1097fcd901852b942c2272344c947d36370

See more details on using hashes here.

Provenance

The following attestation bundles were made for icon_grid_generator-0.2.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for icon_grid_generator-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 685b9ea293f9e209d6645de3678ffab359b61e6def20ef6fb3adcbf1abff69df
MD5 3f3b43c70dcb0d4c960dd9a95660bc40
BLAKE2b-256 1f3152d26995fa5f4826cf0934ba6d9d7adc8deaba85b27667d386d5f4ec0bc1

See more details on using hashes here.

Provenance

The following attestation bundles were made for icon_grid_generator-0.2.1-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