""" Allometric equations for converting tree measurements to biomass. """ from typing import Dict def calculate_biomass(dbh: float, height: float, species_name: str, params: Dict[str, float]) -> float: """ Calculate total tree biomass using species-specific allometric equations from Zanvo et al. 2023. Args: dbh: Diameter at breast height (cm) height: Tree height (m) species_name: Name of the species ("species_A" for Rhizophora, "species_B" for Avicennia) params: Dictionary containing allometric parameters Returns: Total tree biomass (above + below ground) in kg """ base = dbh**2 * height if base <= 0: print(f"[ERROR] Non-positive base in calculate_biomass: dbh={dbh}, height={height}, base={base}, species={species_name}") # Use Zanvo et al. 2023 equations that include both DBH and height # Use Komiyama et al. 2005 generic mangrove equation for the else statement, the generic for all other mangroves # Note that Komiyama generic equation is used with the average density value of 0.71 g/cm3 found across various mangrove species if species_name == "species_A": # Rhizophora racemosa # Total = 2.0738 × (DBH² H)^0.67628 total_biomass = 2.0738 * (dbh**2 * height)**0.67628 elif species_name == "species_B": # Avicennia germinans # Total = 1.5595 × (DBH² H)^0.55864 total_biomass = 1.5595 * (dbh**2 * height)**0.55864 else: # Use a conservative generic equation if species not recognized total_biomass = 0.251 * 0.71 * (dbh**2.46) return total_biomass