Simulates Coffee Leaf Rust (CLR) spread across neutral landscapes. Built for a graduate seminar in Economics of Biodiversity at the University of Bern.
- Landscape generation - Creates a patchwork of coffee and non-coffee cells using neutral landscape models (
nlmpy). - Infection dynamics - Coffee plants are infected by CLR, which spreads within cells, to neighbors, and globally depending on weather.
- Harvest calculation - After the simulation period, total coffee berry yield is computed based on infection levels.
# Create environment
mamba env create -f environment.yml
mamba activate clr-landscape
# Install package
pip install -e .# Run simulation with defaults (40x40 grid, 10 runs, 365 days)
clr-landscape run
# Custom parameters
clr-landscape run --size 40 --cluster 0.4 --proportions 0.4 0.6 --num-runs 5
# Generate plots (reads config.json from data dir)
clr-landscape plot
# Use a different data directory
clr-landscape plot --data-dir results/experiment2from clr_landscape import SimulationConfig, run_simulation
config = SimulationConfig(size=30, num_runs=3, num_days=180)
run_simulation(config)Results are saved to data/ by default:
config.json- Simulation parameters (loaded automatically by plotting)results-{run}-{proportions}-{cluster}.csv- Daily infection metricsmap-{day}-{run}-{proportions}-{cluster}.csv- Intermediate infection mapsreturns-{proportions}-{cluster}.csv- Final coffee berry yields
Figures are saved to figures/.
MIT