Simple Coffee Leaf Rust (CLR) Model
Created for the graduate seminar in Economics of Biodiversity at the University of Bern.
This project simulates the spread of Coffee Leaf Rust (CLR) across a patchwork landscape of coffee and non-coffee cells. It allows the user to explore how weather patterns and plant resistance parameters affect infection rates and final coffee yields.
- Neutral Landscape Generation
Uses thenlmpy
package to create a patchwork of coffee (True) and non-coffee (False) cells in a grid. - Plant and Infection Dynamics
Each coffee cell hosts a specified number of coffee plants. An initial infection starts in two adjacent coffee plants. The model then progresses day by day, allowing infection to spread within and between cells based on weather conditions and plant parameters. - Harvest and Returns
After 365 days, the model calculates the total coffee berry yield and writes outputs (including intermediate infection maps and daily infection stats) to thedata/
directory.
- nlmpy
- numpy
- pandas
- numba
- seaborn (for plotting results)
- matplotlib (for plotting results)
Note: It is often helpful to install
numba
andnumpy
via theconda-forge
channel prior to installingnlmpy
, because some dependencies may not load correctly otherwise.
-
Install Dependencies
- Recommended approach (e.g., via Conda):
conda create -n clr_env python=3.10 -y conda activate clr_env pip install numpy numby nlmpy scipy pandas pip install matplotlib seaborn
- From Requirements.txt:
conda create -n clr_env python=3.10 -y conda activate clr_env pip install -r requirements.txt
- Recommended approach (e.g., via Conda):
-
Run the Script
- Place this script in a directory with a
data/
folder (for saving outputs). - Execute:
python clr_landscape.py
- Results (CSV files for daily infection stats and final returns) will appear in the
data/
folder.
- Place this script in a directory with a
-
Analyze and Plot
- Use
seaborn
or any other plotting library to visualize outputs in Jupyter notebooks or Python scripts. - Sample figures can be found in the
figures/
folder.
- Use
A more detailed discussion of the model and results is in the accompanying paper in this repository.