5. Tree carbon never reaches soil carbon

biomass_calculation() returns a data frame with a c_increase_soc column. soil_organic_carbon() looks for an element called trees_non_feed_biomass inside it (R/soc.R:234), which doesn't exist. So tree carbon always contributes 0.

Tree carbon added Current change in SOC total Fixed change in SOC total
2.5 0.00 2.50
--- a/R/soc.R	2026-09-29 10:31:31
+++ b/R/soc.R	2026-09-29 10:31:31
@@ -231,7 +231,7 @@
   
   annual_change_carbon_stocks_trees_non_feed <- data.frame(type = "trees_non_feed") %>%
     dplyr::mutate(
-      biomass = sum(biomass[["trees_non_feed_biomass"]]$c_increase_soc),
+      biomass = sum(biomass$c_increase_soc, na.rm = TRUE),
       below_ground = biomass,
       annual_change_carbon_stocks = below_ground
     )
@@ -248,4 +248,4 @@
   )
   
   return(results)
-}
+}
Reproduce this Open in Colab (R runtime; section 5)
Rscript reproduce_critical_issues.R 5 using reproduce_critical_issues.R (installs what it needs into its own library and cleaned @ 800d53a). Add CLEANED_FIXES=proposed_fixes.R with proposed_fixes.R for the fixed column.
Test: test-critical-05-tree-soc.R · Proposed change: F05.diff · Open an issue in CIAT/cleaned

Comments

Comments are GitHub Discussions on peetmate/cleaned-review; sign in with GitHub to post.