Standalone numerics & geostatistics kernels: reproducible sampling, curated descriptive/weighted statistics, realization-set aggregation, and a geostatistics front-door (experimental variogram, fit, local kriging, sequential Gaussian simulation).
Project description
petekTools
Scattered-data gridding & geostatistics kernels for Rust — the numerics layer the ecosystem is missing.
Rust has excellent crates for linear algebra (faer), statistics and
distributions (statrs, rand_distr), FFT (rustfft), and spatial indexing
(kiddo, rstar). What it has lacked is a production-grade way to turn
scattered (x, y, z) observations into a regular grid — minimum-curvature
surfaces, inverse-distance weighting, nearest-neighbour fills. petekTools
fills exactly that gap, and curates the rest behind one small front-door.
If you have points and need a surface — a depth grid from well picks, a property map from samples, any scattered field on a regular lattice — this is the crate.
Documentation
The canonical docs for the whole petek family live on the petekSuite site — petekTools' pages there:
- Library guide — the petekTools guide.
- Tutorials — Synthetic data & testing · Visualization (the viewer unit ships in this wheel).
- Notebooks — executed examples: geostat tour · synthetic-data tour.
Why reach for it
- Real gridding methods, not toys. Briggs minimum-curvature (biharmonic SOR), inverse-distance weighting, and nearest-neighbour — the workhorses, with their defaults and tolerances stated and tested, not hand-waved.
- Warm-start / incremental re-gridding. Editing a surface point-by-point?
Re-solving from scratch each time is wasteful. Seed the solver from the prior
field and it converges in a fraction of the iterations — ~4–7× faster on a
typical structural edit, rising to ~114× in the near-converged incremental
limit (measured: 1.55 ms → 13.6 µs, 64 points → 40×40), converging to the same
field. A stateful [
ConvergentGridder] makes interactive, one-control-at-a-time refinement cheap. - Type-agnostic by design. Kernels speak a plain [
Lattice] +[[f64; 3]]rows and returnndarray::Array2<f64>— never a domain type. Any regular, rotatable areal lattice (the IRAP/RMS model) maps on field-for-field, so adoption is a conversion at the call site, not a rewrite. - Deterministic and honest. No RNG, no silent clamping; named, cited constants. Analytic cases are asserted as tests — a linear trend is the exact minimum-curvature solution, IDW is exact at coincident samples.
- A pure leaf. Depends only on general-purpose numeric crates. No I/O, no domain model, no heavy framework to adopt — drop it in.
- Small formula engine. Parse assignment strings, bind scalar
$params, order intra-block dependencies, and evaluate vectorized expressions over named arrays without pulling in any static-model semantics. - Shared 1-D interpolation.
interp1dcovers log-style resampling with nearest/step/linear methods and a natural cubic spline implemented in Rust. - Binding-friendly. Owned inputs, no public lifetimes on kernels; PyO3 bindings are a planned thin layer over this same surface.
Install
cargo add petektools
Quick start
use petektools::{grid, GridMethod, Lattice};
// A 100×80 grid, 25 m spacing, origin at (1000, 2000).
let lattice = Lattice::regular(1000.0, 2000.0, 25.0, 25.0, 100, 80);
// Scattered observations: [x, y, z] rows.
let points = [
[1010.0, 2008.0, 12.5],
[1240.0, 2300.0, 18.1],
[1880.0, 3100.0, 9.4],
];
// Interpolate onto the grid → an (ncol × nrow) Array2<f64>;
// undefined nodes are NaN.
let surface = grid(&points, &lattice, GridMethod::MinimumCurvature).unwrap();
Methods
GridMethod |
What it does |
|---|---|
Nearest |
Each node takes its areally-closest sample's z (blocky, exact at data). |
InverseDistance |
Global IDW, p = 2; exact at coincident samples. |
MinimumCurvature |
Briggs biharmonic SOR — smooth, honours the samples. |
Warm-start an incremental re-grid
use petektools::{grid, grid_min_curvature_seeded, GridMethod, Lattice};
let lattice = Lattice::regular(0.0, 0.0, 1.0, 1.0, 64, 64);
let points = [[1.0, 1.0, 10.0], [60.0, 60.0, 40.0]];
let cold = grid(&points, &lattice, GridMethod::MinimumCurvature).unwrap();
// Later, after nudging the data: relax from the prior field instead of
// cold-starting. A None / wrong-shape seed falls back to a cold solve.
let warm = grid_min_curvature_seeded(&points, &lattice, Some(&cold)).unwrap();
Interactive refinement with ConvergentGridder
use petektools::{ConvergentGridder, Lattice};
let lattice = Lattice::regular(0.0, 0.0, 1.0, 1.0, 64, 64);
let points = [[1.0, 1.0, 10.0], [60.0, 60.0, 40.0]];
let mut gridder = ConvergentGridder::new(&points, &lattice).unwrap();
// Pin node (32, 40) to 25.0 as a hard constraint and re-solve incrementally.
let field = gridder.add_control(32, 40, 25.0); // warm — cheap
// … add more controls; each call returns the updated field.
Geometry: Lattice
A regular, rotatable areal lattice (the IRAP/RMS model): origin, spacing,
node counts, CCW rotation, and an optional y-flip. It carries the forward map
node_xy(i, j) and its inverse xy_to_ij(x, y), plus a bbox() — everything a
kernel needs to place a sample on the grid.
Design
- One job. Scattered-data gridding / geostatistics — the gap. Everything else (linear algebra, stats, neighbour search) is curated from mature crates, never reimplemented.
- Type-agnostic kernels.
Lattice+[[f64; 3]]in,ndarrayout. No domain types, no I/O. - Numerical honesty. Deterministic, documented to a stated tolerance, with analytic tests as the safety net.
See SPEC.md for the design constitution and API.md for
the locked public contract.
Status & roadmap
The public contract — Lattice, GridMethod, grid, the warm-start entries —
is locked and analytically tested. Also shipped: ordinary kriging behind a
Gridder trait, the curated stats / sampling front-doors over statrs /
rand_distr, the units / container / formula modules, the PyO3 wheel, the
generic viewer unit, and the wheel-only synthetic asset writer/composer. On the
roadmap: RBF backends if a need appears.
License
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 Distributions
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 petektools-0.2.5.tar.gz.
File metadata
- Download URL: petektools-0.2.5.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec83c8d5155fbaf464032a81332a71580f8478da53573d75fc247889f665e571
|
|
| MD5 |
de81536f99dcb94da3a0257ba322c4ec
|
|
| BLAKE2b-256 |
137faafa88e86b6712ef0f3ee759b5925c4b2d8bea63578b858460c9e4636dfc
|
Provenance
The following attestation bundles were made for petektools-0.2.5.tar.gz:
Publisher:
release.yml on kkollsga/petektools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
petektools-0.2.5.tar.gz -
Subject digest:
ec83c8d5155fbaf464032a81332a71580f8478da53573d75fc247889f665e571 - Sigstore transparency entry: 2114144323
- Sigstore integration time:
-
Permalink:
kkollsga/petektools@202c4f98354f94e298b91df3694bd6d7cc462572 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kkollsga
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@202c4f98354f94e298b91df3694bd6d7cc462572 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file petektools-0.2.5-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: petektools-0.2.5-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 913.3 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7aa4899965f0041352e5cdc0eaecb34ea33df257391fc2a6cf766ecc46f9c531
|
|
| MD5 |
ffe17edfddcddd5bde39fbb970f49c3e
|
|
| BLAKE2b-256 |
d8db14661345e44ccdb9d5e7cb60ef1f808cea1998b0f8206dc63e63a6fe7f58
|
Provenance
The following attestation bundles were made for petektools-0.2.5-cp310-abi3-win_amd64.whl:
Publisher:
release.yml on kkollsga/petektools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
petektools-0.2.5-cp310-abi3-win_amd64.whl -
Subject digest:
7aa4899965f0041352e5cdc0eaecb34ea33df257391fc2a6cf766ecc46f9c531 - Sigstore transparency entry: 2114144673
- Sigstore integration time:
-
Permalink:
kkollsga/petektools@202c4f98354f94e298b91df3694bd6d7cc462572 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kkollsga
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@202c4f98354f94e298b91df3694bd6d7cc462572 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file petektools-0.2.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: petektools-0.2.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 990.7 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
259fb32ab8f0390a1239b9aa61eef7d6d6bf459d5a3b9b63682747f5871be0c3
|
|
| MD5 |
95fe1ed1101ad2aafb77b7c3b3688b8c
|
|
| BLAKE2b-256 |
30ae83a355fb3f0b17bef83e45b72bf6bb86bbd3cc60d0a0d0594309fc1cc8fb
|
Provenance
The following attestation bundles were made for petektools-0.2.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on kkollsga/petektools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
petektools-0.2.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
259fb32ab8f0390a1239b9aa61eef7d6d6bf459d5a3b9b63682747f5871be0c3 - Sigstore transparency entry: 2114144842
- Sigstore integration time:
-
Permalink:
kkollsga/petektools@202c4f98354f94e298b91df3694bd6d7cc462572 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kkollsga
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@202c4f98354f94e298b91df3694bd6d7cc462572 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file petektools-0.2.5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: petektools-0.2.5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 969.9 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92fb61b069065e6dba35bc439d02ef91733abc892b84ff4fc798d25fc42f718d
|
|
| MD5 |
9d018018270d6061f610a0d455bf874e
|
|
| BLAKE2b-256 |
f090d24098c7b7e06571dc143f34d5ac463b775cb1d9bcbe7ada8496aa75dd03
|
Provenance
The following attestation bundles were made for petektools-0.2.5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on kkollsga/petektools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
petektools-0.2.5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
92fb61b069065e6dba35bc439d02ef91733abc892b84ff4fc798d25fc42f718d - Sigstore transparency entry: 2114144988
- Sigstore integration time:
-
Permalink:
kkollsga/petektools@202c4f98354f94e298b91df3694bd6d7cc462572 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kkollsga
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@202c4f98354f94e298b91df3694bd6d7cc462572 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file petektools-0.2.5-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: petektools-0.2.5-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.10+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0ace1b33e5421e236093505cb8c14f48f107761d447877a2a50ffc9690ca067
|
|
| MD5 |
e1cfc04c2d515bedf36047355f90d9d5
|
|
| BLAKE2b-256 |
05a65f7c92b509f1b9646579110831b6ea367ec9c42f90f58d98aae22347f714
|
Provenance
The following attestation bundles were made for petektools-0.2.5-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:
Publisher:
release.yml on kkollsga/petektools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
petektools-0.2.5-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl -
Subject digest:
e0ace1b33e5421e236093505cb8c14f48f107761d447877a2a50ffc9690ca067 - Sigstore transparency entry: 2114144546
- Sigstore integration time:
-
Permalink:
kkollsga/petektools@202c4f98354f94e298b91df3694bd6d7cc462572 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kkollsga
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@202c4f98354f94e298b91df3694bd6d7cc462572 -
Trigger Event:
workflow_dispatch
-
Statement type: