Pure Python generation of ICON-style triangular grids
Project description
ICON Grid Generator
Pure Python generation of ICON-style triangular grids.
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 asR02B03. - 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
netCDF4support. - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1209fd3239f874a26da4d48f3d399a8cbb94709ddb6ead01df290f71c9dafa6f
|
|
| MD5 |
c8e7d5ba3ef4507f67873cee32eab9c8
|
|
| BLAKE2b-256 |
5f5e67ff7a136c72d945600f1ae1ea8e468777cc1eb9b430f9c82cfbf84ff051
|
Provenance
The following attestation bundles were made for icon_grid_generator-0.2.0.tar.gz:
Publisher:
release.yml on ofuhrer/icon-grid-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
icon_grid_generator-0.2.0.tar.gz -
Subject digest:
1209fd3239f874a26da4d48f3d399a8cbb94709ddb6ead01df290f71c9dafa6f - Sigstore transparency entry: 2073787771
- Sigstore integration time:
-
Permalink:
ofuhrer/icon-grid-generator@c75eae06acc147aa9d5aa01ceb6b8264e2eaee4a -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ofuhrer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c75eae06acc147aa9d5aa01ceb6b8264e2eaee4a -
Trigger Event:
push
-
Statement type:
File details
Details for the file icon_grid_generator-0.2.0-py3-none-any.whl.
File metadata
- Download URL: icon_grid_generator-0.2.0-py3-none-any.whl
- Upload date:
- Size: 49.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1846a9da3fb4c262c4d3e84a51521a16bce884571fae0f2a87a554fc34054c2c
|
|
| MD5 |
22789080dd262c26d292681f7203937b
|
|
| BLAKE2b-256 |
1543ed51f86ea5d03e812caac2bd540a4015815402c820947d5d207180a20f88
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
icon_grid_generator-0.2.0-py3-none-any.whl -
Subject digest:
1846a9da3fb4c262c4d3e84a51521a16bce884571fae0f2a87a554fc34054c2c - Sigstore transparency entry: 2073787903
- Sigstore integration time:
-
Permalink:
ofuhrer/icon-grid-generator@c75eae06acc147aa9d5aa01ceb6b8264e2eaee4a -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ofuhrer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c75eae06acc147aa9d5aa01ceb6b8264e2eaee4a -
Trigger Event:
push
-
Statement type: