Skip to main content

DOI tests PyPI

TerraPIN

Terrapin (or TerraPIN) stands for "Terraces Put Into Numerics". It generates the terraces — both strath and fill — that a river leaves as it incises, aggrades, and planes laterally across its valley.

STARTED 09 SEPTEMBER 2013 (written by ADW)

What it is

TerraPIN models a river-valley cross-section as material polygons (Shapely/GEOS) and expresses the physics as polygon algebra: incision and lateral planation remove material, aggradation and talus add it, and eroded and deposited volumes are polygon areas — so mass is conserved by construction rather than by bookkeeping.

It is a driver-agnostic geometry and mass-balance engine. You tell it what happened — "incise to z", "plane to channel width w", "aggrade to level" — and it reports back the updated geometry, the mass balance (eroded and deposited volumes, sediment out), and the emergent valley width. It does not decide rates, erosion laws, or channel migration; those live in whatever drives it (for example GRLP for vertical change, a separate lateral-migration model, or a test).

Terraces and provenance

Each material body is a deposit that carries the age of its formation; each stranded surface carries the age of its abandonment. A terrace is an abandoned surface, so its age is the age of abandonment — and the deposit it is cut on keeps its own, separate deposition age. Terrapin.terraces() reads the benches straight from the live geometry and returns both, so a cut–fill–recut history is legible as strath and fill terraces annotated with when they formed and when the river left them behind.

A minimal run

from shapely.geometry import box
from terrapin import Terrapin

tp = Terrapin()
tp.set_bodies({"bedrock":  box(-140.0, -80.0, 0.0, -6.0),
               "alluvium": box(-140.0,  -6.0, 0.0,  0.0)})
tp.set_repose_angles({"bedrock": 75.0, "alluvium": 32.0, "colluvium": 20.0})
tp.set_channel_elevation(0.0)

tp.incise(-8.0, age=5.0)                     # cut down; strand the land surface
tp.plane_laterally(95.0)                      # plane a strath (its age is set when abandoned)
tp.set_channel_width(0.0)
tp.aggrade(-3.0, age=22.0)                    # a valley fill
tp.incise(-20.0, age=33.0)                    # re-incise; strand the fill top

for t in tp.terraces():
    print(t["kind"], "at z =", t["z"],
          "| terrace age (abandoned) =", t["age"],
          "| deposit age =", t["deposit_age"])

Install and dependencies

TerraPIN is a small pure-Python package; install it from source (pip install -e . or by putting the repository on your PYTHONPATH). The geometry engine requires Python 3, NumPy 2, Shapely (GEOS), and SciPy; Matplotlib is used for plotting. A dedicated environment keeps these consistent — for example:

conda create -n terrapin numpy shapely scipy matplotlib pytest
conda run -n terrapin python -m pytest

Learn more

  • docs/architecture.md — the model: polygon algebra, the driver-agnostic engine, the one-wall unit, symmetric vs. the standard model, and terrace/provenance tracking.
  • examples/ — worked cross-sections, including terrace_tracking.py (terraces read back and labelled by age) and symmetric_valley_terraces.py (strath, talus, and fill-terrace formation).

Citing

If you use TerraPIN, please cite it: GitHub builds a ready-made citation from CITATION.cff (the "Cite this repository" button), and every release is archived on Zenodo with a DOI.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

terrapin_valley-0.1.0.tar.gz (34.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

terrapin_valley-0.1.0-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file terrapin_valley-0.1.0.tar.gz.

File metadata

  • Download URL: terrapin_valley-0.1.0.tar.gz
  • Upload date:
  • Size: 34.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for terrapin_valley-0.1.0.tar.gz
Algorithm Hash digest
SHA256 eb0cece670b442685151c2bb21de2efbcf10572bda4dbc180d2a02e5ce3a9b92
MD5 f3acad5f86d5e67eceeb8e1a34d5901a
BLAKE2b-256 ea49d2277280e097570794f08377e904790fa51809c2b92328485de689274cf4

See more details on using hashes here.

Provenance

The following attestation bundles were made for terrapin_valley-0.1.0.tar.gz:

Publisher: publish.yml on MNiMORPH/TerraPIN

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file terrapin_valley-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: terrapin_valley-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for terrapin_valley-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6bd660589c11d40b788d6ee4ecd47a36cefa4669fce2ed4cdc1c52f055fef2ae
MD5 20c63ff37ff328969dd215bc774cce03
BLAKE2b-256 abeeef4e65e13a78987c76d426c34e469caa6f8efea0b00642ca13d18f60ce4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for terrapin_valley-0.1.0-py3-none-any.whl:

Publisher: publish.yml on MNiMORPH/TerraPIN

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page