Natalie commited on
Commit
1524dc6
·
1 Parent(s): efb9a96

Updated allometric equations (incl. generic mangrove ELSE option), planting schedule defaults, and documentation

Browse files
README.md CHANGED
@@ -23,21 +23,18 @@ This project implements a flexible, modular dashboard for mangrove carbon seques
23
 
24
  ## Usage
25
 
26
- 1. **Install dependencies:**
 
 
 
 
27
  ```bash
28
- # Method 1: Using conda (recommended)
29
  conda env create -f environment.yml
30
  conda activate er-model
31
-
32
- # Method 2: Using pip in existing environment
33
- pip install -r requirements.txt
34
- ```
35
- 2. **Run the dashboard:**
36
- ```bash
37
- conda activate er-model # if using conda
38
  python dashboard/app.py
39
  ```
40
- The terminal will display a public share link.
41
 
42
  ## Growth Models
43
  - **Declining Increment (ACTIVE):**
 
23
 
24
  ## Usage
25
 
26
+ 1. **Access the Dashboard (Recommended):**
27
+ - The Mangrove ER Model Dashboard is hosted online.
28
+ - **Access it here:** [https://huggingface.co/spaces/mowcom/er-model](https://huggingface.co/spaces/mowcom/er-model)
29
+
30
+ 2. **(Optional) Run Locally for Development:**
31
  ```bash
32
+ # Using conda (recommended)
33
  conda env create -f environment.yml
34
  conda activate er-model
 
 
 
 
 
 
 
35
  python dashboard/app.py
36
  ```
37
+ - To stop the local server, press `Ctrl+C` in the terminal.
38
 
39
  ## Growth Models
40
  - **Declining Increment (ACTIVE):**
configs/declining_increment.yaml CHANGED
@@ -24,7 +24,7 @@ species:
24
  r0: 0.43 # m/yr
25
  T_m: 40 # years
26
  allometry:
27
- equation: "Zanvo et al. 2023: Total = 1.938 × (DBH² H)^0.67628"
28
  initial_values:
29
  dbh: 0.1 # cm
30
  height: 0.2 # m
@@ -51,7 +51,7 @@ species:
51
  r0: 0.46 # m/yr
52
  T_m: 40
53
  allometry:
54
- equation: "Zanvo et al. 2023: Total = 1.486 × (DBH² H)^0.55864"
55
  initial_values:
56
  dbh: 0.1 # cm
57
  height: 0.2 # m
@@ -59,11 +59,11 @@ species:
59
  project:
60
  duration_years: 30 # matches project_years
61
  planting_schedule:
62
- year_1: 2500 # ha
63
- year_2: 2500 # ha
64
- year_3: 0 # ha
65
- year_4: 0 # ha
66
- year_5: 0 # ha
67
 
68
  carbon:
69
  biomass_to_carbon: 0.47 # IPCC default
 
24
  r0: 0.43 # m/yr
25
  T_m: 40 # years
26
  allometry:
27
+ equation: "Zanvo et al. 2023: Total = 2.0738 × (DBH² H)^0.67628"
28
  initial_values:
29
  dbh: 0.1 # cm
30
  height: 0.2 # m
 
51
  r0: 0.46 # m/yr
52
  T_m: 40
53
  allometry:
54
+ equation: "Zanvo et al. 2023: Total = 1.5595 × (DBH² H)^0.55864"
55
  initial_values:
56
  dbh: 0.1 # cm
57
  height: 0.2 # m
 
59
  project:
60
  duration_years: 30 # matches project_years
61
  planting_schedule:
62
+ year_1: 500
63
+ year_2: 1500
64
+ year_3: 1500
65
+ year_4: 1500
66
+ year_5: 0
67
 
68
  carbon:
69
  biomass_to_carbon: 0.47 # IPCC default
dashboard/app.py CHANGED
@@ -276,11 +276,11 @@ The model follows these steps to estimate net CO2 emission reductions:
276
  **1. Biomass Calculation:** Total above-ground and below-ground biomass per tree is calculated using allometric equations, which typically relate DBH and Height to biomass. For example, using equations from Zanvo et al. (2023):
277
  - For *Rhizophora spp.* (Species A):
278
  $$
279
- \mathrm{Biomass}_{\mathrm{total}} = 1.938 \times (\mathrm{DBH}^2 \cdot H)^{0.67628}
280
  $$
281
  - For *Avicennia germinans* (Species B):
282
  $$
283
- \mathrm{Biomass}_{\mathrm{total}} = 1.486 \times (\mathrm{DBH}^2 \cdot H)^{0.55864}
284
  $$
285
  *(Note: The specific equations are defined in the model configuration.)*
286
 
 
276
  **1. Biomass Calculation:** Total above-ground and below-ground biomass per tree is calculated using allometric equations, which typically relate DBH and Height to biomass. For example, using equations from Zanvo et al. (2023):
277
  - For *Rhizophora spp.* (Species A):
278
  $$
279
+ \mathrm{Biomass}_{\mathrm{total}} = 2.0738 \times (\mathrm{DBH}^2 \cdot H)^{0.67628}
280
  $$
281
  - For *Avicennia germinans* (Species B):
282
  $$
283
+ \mathrm{Biomass}_{\mathrm{total}} = 1.5595 \times (\mathrm{DBH}^2 \cdot H)^{0.55864}
284
  $$
285
  *(Note: The specific equations are defined in the model configuration.)*
286
 
er_model_core/allometry.py CHANGED
@@ -21,14 +21,16 @@ def calculate_biomass(dbh: float, height: float, species_name: str, params: Dict
21
  if base <= 0:
22
  print(f"[ERROR] Non-positive base in calculate_biomass: dbh={dbh}, height={height}, base={base}, species={species_name}")
23
  # Use Zanvo et al. 2023 equations that include both DBH and height
 
 
24
  if species_name == "species_A": # Rhizophora
25
- # Total = 1.938 × (DBH² H)^0.67628
26
- total_biomass = 1.938 * (dbh**2 * height)**0.67628
27
  elif species_name == "species_B": # Avicennia
28
- # Total = 1.486 × (DBH² H)^0.55864
29
- total_biomass = 1.486 * (dbh**2 * height)**0.55864
30
  else:
31
  # Use a conservative generic equation if species not recognized
32
- total_biomass = 1.712 * (dbh**2 * height)**0.61746
33
 
34
  return total_biomass
 
21
  if base <= 0:
22
  print(f"[ERROR] Non-positive base in calculate_biomass: dbh={dbh}, height={height}, base={base}, species={species_name}")
23
  # Use Zanvo et al. 2023 equations that include both DBH and height
24
+ # Use Komiyama et al. 2005 generic mangrove equation for the else statement, the generic for all other mangroves
25
+ # Note that Komiyama generic equation is used with the average density value of 0.71 g/cm3 found across various mangrove species
26
  if species_name == "species_A": # Rhizophora
27
+ # Total = 2.0738 × (DBH² H)^0.67628
28
+ total_biomass = 2.0738 * (dbh**2 * height)**0.67628
29
  elif species_name == "species_B": # Avicennia
30
+ # Total = 1.5595 × (DBH² H)^0.55864
31
+ total_biomass = 1.5595 * (dbh**2 * height)**0.55864
32
  else:
33
  # Use a conservative generic equation if species not recognized
34
+ total_biomass = 0.251 * 0.71 * (dbh**2.46)
35
 
36
  return total_biomass
tests/test_er_model.py CHANGED
@@ -177,11 +177,11 @@ def test_allometric_equation_species_A_B():
177
  dbh = 10.0 # cm
178
  height = 5.0 # m
179
  # species_A (Rhizophora spp.)
180
- expected_A = 1.938 * (dbh**2 * height)**0.67628
181
  result_A = calculate_biomass(dbh, height, "species_A", {})
182
  assert np.isclose(result_A, expected_A, rtol=1e-6), f"species_A: got {result_A}, expected {expected_A}"
183
  # species_B (Avicennia germinans)
184
- expected_B = 1.486 * (dbh**2 * height)**0.55864
185
  result_B = calculate_biomass(dbh, height, "species_B", {})
186
  assert np.isclose(result_B, expected_B, rtol=1e-6), f"species_B: got {result_B}, expected {expected_B}"
187
 
 
177
  dbh = 10.0 # cm
178
  height = 5.0 # m
179
  # species_A (Rhizophora spp.)
180
+ expected_A = 2.0738 * (dbh**2 * height)**0.67628
181
  result_A = calculate_biomass(dbh, height, "species_A", {})
182
  assert np.isclose(result_A, expected_A, rtol=1e-6), f"species_A: got {result_A}, expected {expected_A}"
183
  # species_B (Avicennia germinans)
184
+ expected_B = 1.5595 * (dbh**2 * height)**0.55864
185
  result_B = calculate_biomass(dbh, height, "species_B", {})
186
  assert np.isclose(result_B, expected_B, rtol=1e-6), f"species_B: got {result_B}, expected {expected_B}"
187