A Python wrapper for the GridTools C++ library, providing high-performance stencil computations on structured grids for weather and climate applications. Current version 2.3.9, released under a BSD license. Release cadence is irregular, with minor updates every few months.
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from gridtools_cpp import get_cmake_dir
from gridtools_cpp import get_include_dir
from gridtools_cpp import pathlib
Basic usage of GridTools Python interface. Note that actual high-performance stencils require compiling C++ kernels via the GridTools library; this Python wrapper exposes that functionality.
import gridtools
import numpy as np
# Define a simple stencil: compute average of neighbors
def stencil(in_field, out_field):
# GridTools expects Fortran-layout arrays
in_field = np.asfortranarray(in_field)
out_field = np.asfortranarray(out_field)
# Example using the gridtools library (mock)
# Real usage involves building a stencil object and applying it
out_field[1:-1, 1:-1] = (in_field[:-2, 1:-1] + in_field[2:, 1:-1] +
in_field[1:-1, :-2] + in_field[1:-1, 2:]) / 4.0
return out_field
# Create test data
nx, ny = 10, 10
in_field = np.random.rand(nx, ny)
out_field = np.zeros((nx, ny))
result = stencil(in_field, out_field)
print(result)
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.