Natalie
Updated allometric equations (incl. generic mangrove ELSE option), planting schedule defaults, and documentation
1524dc6 | 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):** | |
| - The Mangrove ER Model Dashboard is hosted online. | |
| - **Access it here:** [https://huggingface.co/spaces/mowcom/er-model](https://huggingface.co/spaces/mowcom/er-model) | |
| 2. **(Optional) Run Locally for Development:** | |
| ```bash | |
| # 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](https://black.readthedocs.io/), [isort](https://pycqa.github.io/isort/) | |
| - Type hints required for all public functions | |
| - Run tests with: | |
| ```bash | |
| 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) | |