Skip to content

Instantly share code, notes, and snippets.

@phargogh
Created October 28, 2020 01:38
Show Gist options
  • Save phargogh/7fac8ae8d7bbaa206ddf1a62a65fd9aa to your computer and use it in GitHub Desktop.
Save phargogh/7fac8ae8d7bbaa206ddf1a62a65fd9aa to your computer and use it in GitHub Desktop.
InVEST Coastal Blue Carbon's emissions math expermient
# Related to the discussion at https://community.naturalcapitalproject.org/t/coastal-blue-carbon-zero-net-c-sequestration-in-disturbed-blue-carbon-habitats/1398/9
# Note that this is intended to simply recreate the math used in the CBC model,
# which is just a Riemann Sum of the emissions equation. It would be far
# faster (and should be more numerically correct) to simply use the fundamental
# theorem of calculus and evaluate the function directly for each transition period.
# d = 0.0001997
d = 0.00020075
# found_emissions = 0.0000133733
# h = 2
h = 10
d_sum = 0
total_percent = 0
for i in range(1, 15):
fractional_emissions = (d * (0.5**((i-1)/h) - (0.5**(i/h))))
percent_of_total = (fractional_emissions/d)
total_percent += percent_of_total
print(f"{i} {fractional_emissions} {percent_of_total:.4}")
d_sum += fractional_emissions
print("Sum: %.10f" % d_sum)
print(f"Which is {round((d_sum / d)*100, 2)}% of d")
print(f"{total_percent}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment