er-model / README.md
Natalie
Updated allometric equations (incl. generic mangrove ELSE option), planting schedule defaults, and documentation
1524dc6

A newer version of the Gradio SDK is available: 6.14.0

Upgrade
metadata
title: Mangrove ER Model Dashboard
emoji: 🌱
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 5.29.0
app_file: dashboard/app.py
pinned: false

Mangrove Emissions Reduction Model & Dashboard

This project implements a flexible, modular dashboard for mangrove carbon sequestration and emissions reduction, supporting multiple growth models. Currently, only the Declining Increment model is active; all other models are archived for reference.

Features

  • Interactive Gradio dashboard for project simulation and analysis
  • Updated: grouped accordions, tooltips as labels, reset-to-defaults button, and compact two-column mortality layout
  • Modular growth model architecture (see er_model_core/growth_models/)
  • All dashboard tables and plots are driven by model outputs (no redundant calculations)
  • Editable planting schedule and all model parameters for Declining Increment model
  • Robust, transparent, and reproducible calculations

Usage

  1. Access the Dashboard (Recommended):

  2. (Optional) Run Locally for Development:

    # Using conda (recommended)
    conda env create -f environment.yml
    conda activate er-model
    python dashboard/app.py
    
    • To stop the local server, press Ctrl+C in the terminal.

Growth Models

  • Declining Increment (ACTIVE):
    • Annual increment declines linearly to zero; total size is the sum of non-negative increments (never decreases or goes negative).
    • Both discrete and continuous versions are available (toggle via config).
  • Archived Models:
    • Chapman-Richards (see er_model_core/growth_models/chapman_richards.py)
    • Simple Linear (see er_model_core/growth_models/linear.py)
    • Linear Plateau (see er_model_core/growth_models/linear.py)
    • Jimenez-Lugo (see models/jimenez_lugo/README.md)

File Structure

  • dashboard/app.py β€” Gradio dashboard UI and logic (now model-driven, with grouped accordions and tooltips)
  • er_model_core/er_model.py β€” Core model logic, growth model selection, and all calculations
  • er_model_core/growth_models/ β€” Modular growth model implementations (active and archived)
  • er_model_core/types.py β€” Shared dataclasses for model config
  • er_model_core/config_loader.py β€” Config loading and parsing
  • configs/ β€” Model configuration YAMLs
  • models/ β€” Reference model folders and documentation
  • tests/ β€” Unit tests for model logic and outputs

Model-Driven Dashboard

  • All per-year, per-species metrics (surviving trees, DBH, height, biomass per tree, total biomass) are calculated and stored in the model (model.species_metrics).
  • Dashboard tables and plots read directly from model outputs for speed, consistency, and maintainability.
  • No redundant calculations in the dashboard.

Adding or Re-enabling Models

  1. To add a new model:
    • Implement the growth function in er_model_core/growth_models/.
    • Add a config YAML to configs/.
    • Add a tab/entry in dashboard/app.py (if you want it visible in the UI).
  2. To re-enable an archived model:
    • Uncomment the relevant import and config entry.
    • Ensure the model is listed in MODEL_CONFIGS in dashboard/app.py.
    • Add or update documentation in models/ as needed.

Directory Structure

er-chapman-richards/
β”œβ”€β”€ README.md                # This file
β”œβ”€β”€ environment.yml          # Conda environment
β”œβ”€β”€ dashboard/               # Gradio dashboard app
β”œβ”€β”€ er_model_core/           # Core model code
β”‚   β”œβ”€β”€ er_model.py
β”‚   β”œβ”€β”€ growth_models/
β”‚   β”œβ”€β”€ types.py
β”‚   └── config_loader.py
β”œβ”€β”€ configs/                 # Model parameter YAMLs
β”œβ”€β”€ models/                  # Model-specific docs
β”‚   β”œβ”€β”€ original/README.md   # Archived
β”‚   β”œβ”€β”€ jimenez_lugo/README.md # Archived
β”‚   └── declining_increment/README.md # Active
β”œβ”€β”€ tests/                   # Pytest suite
└── ...

Development & Testing

  • Code style: black, isort
  • Type hints required for all public functions
  • Run tests with:
    pytest
    
  • Pre-commit hooks ensure code quality

References

  • Chapman-Richards growth model literature
  • Jimenez, J.A. & Lugo, A.E. (1985, 1987)
  • Zanvo et al. (2023) for allometric equations
  • Field data from Nigeria mangrove sites (2024)