PyPath is a Python implementation of the Ecopath with Ecosim (EwE) ecosystem modeling framework. It extends the R package Rpath with significant new features — including the first complete lifecycle Individual-Based Model for European smelt — while maintaining full core compatibility.
# Core package
conda install pypath-ewe -c razinka -c conda-forge
# With web dashboard
conda install pypath-ewe pypath-shiny -c razinka -c conda-forgegit clone https://github.com/razinkele/PyPath.git
cd PyPath
pip install -e "packages/pypath[all]"
pip install -e "packages/pypath-shiny[dev]"| Package | Conda | Description |
|---|---|---|
| pypath-ewe | conda install pypath-ewe -c razinka |
Core Ecopath/Ecosim/Ecospace + IBM algorithms |
| pypath-shiny | conda install pypath-shiny -c razinka |
Interactive Shiny web dashboard |
PyPath includes the first complete lifecycle IBM for European smelt (Osmerus eperlanus), bridging the early life stage model of Drewes et al. (2025) with a full juvenile-adult bioenergetics engine. Designed as a Baltic-applied tool for the Curonian Lagoon.
Egg ──── Yolk-sac ──── Feeding larva ──── Juvenile ──── Adult ──── Spawner
│ │ │ │ │ │
DD model Yolk depl. Thornton-Lessem Ontogenetic Wisconsin Per-zone
3-source Q10 + PNR + Type II → AF sigmoid bioenerg. egg deposition
mortality starvation consumption interpolation + predation
Key capabilities:
- Egg stage — Degree-day development (Keller et al. 2020: DD=149 °C·day, T₀=1.8°C), thermal/oxygen/background mortality, per-zone spawning deposition
- Yolk-sac stage — Q10-scaled basal metabolism yolk depletion, first-feeding transition with point-of-no-return (PNR) starvation, emergent Cushing match/mismatch
- Larval bioenergetics — Thornton-Lessem (Fish Bioenergetics 3.0) temperature dome for Cmax, ontogenetic sigmoid interpolation (Rs+Ra metabolism, size-dependent assimilation efficiency), consumption blending from concentration-dependent Type II to adaptive foraging
- Oxygen physiology — Full lifecycle Pcrit-based metabolic scope reduction (4.0→2.0 mg/L egg→adult), lethal thresholds, stress-accelerated yolk depletion, behavioral O2 avoidance
- Curonian Lagoon zonal model — 3-zone spatial (river spawning / lagoon nursery / coastal feeding), zone-specific environmental forcing, passive drift, ontogenetic habitat constraints, spawning migration
- Calibration framework — ELS-aware differential evolution, Latin Hypercube Sampling sensitivity analysis, Partial Rank Correlation Coefficients (PRCC)
from pypath.ibm import SmeltIBM, SmeltParams
# Enable early life stages with Baltic literature defaults
params = SmeltParams.baltic_defaults_els()
# Or with zonal spatial model
params = SmeltParams.baltic_defaults_zonal()
# Create and initialize IBM
ibm = SmeltIBM(group_index=2, n_groups=6, params=params)
ibm.initialize_from_ecosim(biomass=1.0, params={})
# Run coupled with Ecosim via apply_ibm_to_derivative()References:
- Drewes et al. (2025) Ecological Modelling 510:111313
- Keller et al. (2020) J Fish Biol 97(2):368-381
- Ecopath: Mass-balance food web modeling with multi-stanza support
- Ecosim: Dynamic simulation with foraging arena theory (RK4 + Adams-Bashforth)
- Ecospace: Spatially-explicit modeling (regular, hexagonal, irregular grids)
- Time Series Calibration: SS fitting against observed data (EwE standard workflow)
- Mediation Functions: Trophic mediation via third-party biomass
- Monte Carlo / Pedigree: Uncertainty analysis with Morris/Sobol sensitivity
- Ecotracer: Contaminant tracking through the food web
- Fleet Dynamics / MSE: Profit-driven effort, quota management
- Ecological Indicators: Ascendency, cycling index, system maturity
- Autofix: Automatic crash diagnostics and parameter repair
| Feature | Module | Status |
|---|---|---|
| Time Series & Calibration | core.timeseries, core.calibration |
Done |
| Mediation Functions | core.mediation |
Done |
| Monte Carlo / Pedigree | core.montecarlo, core.pedigree |
Done |
| Ecotracer (Contaminants) | core.ecotracer |
Done |
| Fleet Dynamics & MSE | core.fleet_dynamics |
Done |
| Advanced Ecospace (16 tables) | io.ewemdb |
Done |
| Ecological Indicators | core.indicators |
Done |
| Value Chain Economics (I/O) | io.ewemdb |
Done |
| Taxonomy Integration | io.ewemdb |
Done |
| IBM Early Life Stages | ibm.development, ibm.smelt |
Done |
conda install pypath-shiny -c razinka -c conda-forge
pypath-shiny11 professional themes, multi-file data import, real-time validation, interactive parameter editing, results visualization and export.
from pypath import create_rpath_params, rpath, rsim_scenario, rsim_run
# Create and balance a model
params = create_rpath_params(
groups=["Phytoplankton", "Zooplankton", "Fish", "Detritus"],
types=[1, 0, 0, 2],
)
# ... set biomass, PB, QB, diet matrix ...
model = rpath(params)
# Run 50-year dynamic simulation
scenario = rsim_scenario(model, params, years=range(1, 51))
output = rsim_run(scenario, method="AB")from pypath.io.ewemdb import ecosim_scenario_from_ewemdb
from pypath import rsim_run
scenario = ecosim_scenario_from_ewemdb("model.eweaccdb", scenario=16)
output = rsim_run(scenario, method="AB")from pypath.ibm import SmeltIBM, SmeltParams
from pypath.ibm.integration import apply_ibm_to_derivative
# Set up IBM with early life stages
params = SmeltParams.baltic_defaults_els()
ibm = SmeltIBM(group_index=2, n_groups=6, params=params)
ibm.initialize_from_ecosim(biomass=1.0, params={})
# IBM integrates via apply_ibm_to_derivative() in the Ecosim ODE loop
# Eggs develop, hatch, feed, grow, and recruit back into the food web| Feature | Rpath | PyPath |
|---|---|---|
| Core Ecopath/Ecosim | Yes | Yes |
| Multi-stanza groups | Yes | Yes |
| .eweaccdb import | Yes | Yes (full scenario loading) |
| Ecospace (spatial) | No | Yes |
| Individual-Based Model | No | Yes (complete lifecycle) |
| IBM early life stages | No | Yes (egg→adult, 6 packages) |
| Time series calibration | Limited | SS fitting |
| Mediation functions | No | Yes |
| Monte Carlo / Pedigree | No | Yes |
| Ecotracer | No | Yes |
| Fleet dynamics / MSE | No | Yes |
| Ecological indicators | No | Yes |
| EwE database export | No | 86% coverage |
| Comprehensive tests | Limited | 1500+ tests |
# Fast tests (excludes slow/integration)
pytest packages/pypath/tests/ -q -m "not integration and not slow" --ignore=packages/pypath/tests/scripts
# Full suite
pytest packages/pypath/tests/ -q --ignore=packages/pypath/tests/scripts
# IBM tests only (232 tests)
pytest packages/pypath/tests/test_ibm_*.py -v
# Shiny app tests
pytest packages/pypath-shiny/tests/ -q --ignore=packages/pypath-shiny/tests/uiAll features production-ready. 1500+ tests passing, 0 failures.
Completed:
- Core Ecopath/Ecosim (100% Rpath compatible)
- Ecospace spatial modeling (Dec 2025)
- Individual-Based Model (Feb 2026)
- EMODnet data integration (Mar 2026)
- EwE database 86% table coverage (Mar 2026)
- Time series calibration, mediation, Monte Carlo, Ecotracer, fleet dynamics, indicators (Mar 2026)
- Smelt IBM early life stages — complete lifecycle model (Mar 2026)
- Lucey, S. M., Gaichas, S. K., & Aydin, K. Y. (2020). Conducting reproducible ecosystem modeling using the open source mass balance model Rpath. Ecological Modelling, 427, 109057.
- Christensen, V., & Walters, C. J. (2004). Ecopath with Ecosim: Methods, capabilities and limitations. Ecological Modelling, 172(2), 109-139.
- Drewes, D., Schrum, C., Pein, J., Benkort, D. & Daewel, U. (2025). Environmental controls on the development of early life stages of European smelt in the Elbe estuary. Ecological Modelling, 510, 111313.
- Keller et al. (2020). Temperature effects on egg and larval development rate in European smelt. Journal of Fish Biology, 97(2), 368-381.
- Hanson, P. C., et al. (1997). Fish Bioenergetics 3.0. University of Wisconsin Sea Grant Institute.
@software{pypath2024,
title = {PyPath: Python Ecopath with Ecosim},
author = {Razinkovas-Baziukas, A.},
year = {2024--2026},
url = {https://github.com/razinkele/PyPath},
note = {Extends Rpath with IBM early life stages, Ecospace,
time series calibration, and EwE database I/O}
}MIT License - see LICENSE.
- Rpath: NOAA-EDAB/Rpath by Sean Lucey, Sarah Gaichas, and Kerim Aydin
- EwE: www.ecopath.org
- HORIZON EUROPE: This work was supported by the HORIZON EUROPE research programme
PyPath - Advanced Python Ecosystem Modeling
Complete lifecycle IBM for European smelt | Ecopath with Ecosim in Python