Python interface to the high-performance, MPI-Parallelized C executable `gcn10` for generating high-resolution Global Curve Number 10m rasters
Project description
1. GCN10Py
GCN10py is a Python interface to the high-performance C-based gcn10
executable for generating high-resolution (10m) Global Curve Number (GCN) rasters using MPI.
It enables block-based, parallel generation of CN maps from global soil and land cover datasets.
2. Installation
2.1.Prerequisites
Ensure the following dependencies are installed and available in your system PATH:
gcn10(compiled C executable with MPI and GDAL)- MPI implementation (e.g., MPICH, OpenMPI)
- GDAL runtime libraries (CLI + C bindings)
2.2. pip
Install via pip:
pip install gcn10py
Note: This package requires a working build of the
gcn10executable, compiled with MPI and GDAL support.
2.3. Building from Source
-
Compile the C binary (following the instructions here) and add it to your PATH.
src/gcn10py/gcn10 # or gcn10.exe on Windows -
Install the build tools:
pip install hatchling
-
Build the wheel package:
python -m build
-
Install locally for testing:
pip install dist/gcn10py-0.1.1-py3-none-any.whl
3. Usage
3.1. command-line (required -c, optional -l and -o)
-c <path>: required. path to theconfig.txtused by the C backend.-l <path>: optional. text file containing block ids (one per line).-o: optional. overwrite existing outputs.
basic examples:
# minimal: run using config only
gcn10py -c config.txt
# run and overwrite any existing outputs
gcn10py -c config.txt -o
# run a specific block list
gcn10py -c config.txt -l blocks.txt
# run a specific block list and overwrite outputs
gcn10py -c config.txt -l blocks.txt -o
mpi examples:
# 10 mpi processes, config only
mpirun -n 10 gcn10py -c config.txt
# 10 mpi processes, block list + overwrite
mpirun -n 10 gcn10py -c config.txt -l blocks.txt -o
(optional) call the C binary directly:
mpirun -n 10 ./gcn10 -c config.txt -l blocks.txt -o
3.2. Python API
from gcn10py import run
# run with config only
run(["-c", "config.txt"])
# run with overwrite
run(["-c", "config.txt", "-o"])
# run with a block list
run(["-c", "config.txt", "-l", "blocks.txt"])
# run with a block list and overwrite
run(["-c", "config.txt", "-l", "blocks.txt", "-o"])
you can wrap this in your own scripts, add logging, or integrate with job schedulers.
4. Application
The CN rasters are usually required and analysed on a watershed scale.
A ready-to-use driver and example config live in the testing/ directory:
testing/gcn10_driver.py— orchestrates the full pipeline (discover blocks for your aoi, launch mpi, mosaic, clip)testing/config.yaml— example configuration (aoi, blocks, mpi settings, mosaic patterns, gdal options)- test data under
testing/for quick validation
4.1 Run for a Vector Area of Interest (yaml-driven execution)
run it like this:
# from the project root
cd testing
python gcn10_driver.py -y config.yaml
# or make it executable
chmod a+x gcn10_driver.py
./gcn10_driver.py -y testing/config.yaml
what it does:
- reads your aoi (gpkg/shp)
- finds intersecting block ids from
esa_extent_blocks.shp(or uses a provided list) - launches
gcn10via mpi (or uses the python api) to generate per-block cn rasters - mosaics each of the 18 combinations (hc × arc × drainage) and clips to the aoi
- writes all 18 final geotiffs to the output directory defined in the yaml
notes:
- the driver normalizes paths to absolute and runs with
cwdset to the directory ofconfig.txtso relative paths inside the config resolve consistently - set
run.cli_cmd: gcn10or copy thegcn10intesting/config.yamlif you prefer calling the C binary directly
5. About the Package
5.1 Project Structure
gcn10py/
├── LICENSE
├── README.md
├── pyproject.toml
├── src/
│ └── gcn10py/
│ ├── __init__.py
│ ├── cli.py
│ └── gcn10 # compiled C executable (excluded from repo)
└── testing/
└── gcn10_driver.py
5.2. Testing & Benchmarks
- functional check:
- edit
testing/config.yamlto point to your AOI and inputs - run
testing/gcn10_driver.py -y testing/config.yaml - verify 18 outputs appear in
io.output_dir
- edit
measured on:
OS: Slackware 15.0+, x86_64
Kernel: 6.12.39
CPU: Intel(R) Core(TM) Ultra 7 165U
CPU(s): 14
Memory: 64 GiB
gcn10C binary: 4 blocks, 4 MPI processes: 4 min 15 sgcn10pyCLI (python wrapper only): same 4 blocks: 5 min 40 s- YAML driver (same 4 blocks) + build VRTs + 18 mosaics clipped to AOI: 6 min 34 s
(GDAL threads:GDAL_NUM_THREADS=ALL_CPUS, creation options:TILED=YES, COMPRESS=LZW, BIGTIFF=YES)
performance will vary with I/O bandwidth, MPI binding, GDAL config, OS and most importantly internet connection. For best performance, use linux native utilities.
5.3. License
Copyright (C) 2025
Abdullah Azzam (mabdazzam)
Released under the GNU General Public License v3.0.
See the LICENSE file for full terms.
5.4. Contact
Questions, bug reports, or contributions? Open an issue or pull request on GitHub.
Project details
Release history Release notifications | RSS feed
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 gcn10py-0.1.1.tar.gz.
File metadata
- Download URL: gcn10py-0.1.1.tar.gz
- Upload date:
- Size: 164.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
965690587aea7a3bc55522d6033b0333655f716ee32bebc498cec84995782cff
|
|
| MD5 |
2b4a3a7939c78cc38fce1a9b727a08ac
|
|
| BLAKE2b-256 |
8afc969638e7994ff3d32344cc28809ca9d73baee5a03e95d34f1526ebb9e92c
|
File details
Details for the file gcn10py-0.1.1-py3-none-any.whl.
File metadata
- Download URL: gcn10py-0.1.1-py3-none-any.whl
- Upload date:
- Size: 43.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
566f4f5041dd394f991cb0db5eb6c5a03b3f88f805eba84f519d054b0f1c8dca
|
|
| MD5 |
5d808a8cdd130e9a2ef32d328c445c0f
|
|
| BLAKE2b-256 |
8afdd0ba8a12f518498a233ef41c513432e79342268150a1c5352a3685b9c778
|