Skip to content

Instantly share code, notes, and snippets.

@cmutel
Created June 6, 2023 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmutel/f81ba6d0a3018edfec44e8aa45368376 to your computer and use it in GitHub Desktop.
Save cmutel/f81ba6d0a3018edfec44e8aa45368376 to your computer and use it in GitHub Desktop.
import bw2data as bd
import bw2calc as bc
bd.projects.set_current("ghg-scores")
db = bd.Database("eg")
db.register()
a = db.new_node(code="a", name="a")
a.save()
b = db.new_node(code="b", name="b")
b.save()
ghg_flow = db.new_node(code="ghgs", name="GHG score", unit="kg CO2-eq.", type="emission")
ghg_flow.save()
a.new_edge(input=b, amount=1, type="technosphere").save()
b.new_edge(input=ghg_flow, amount=7, type="biosphere").save()
only_ghg_flows_lcia_method = bd.Method(("GHG scores", "direct"))
only_ghg_flows_lcia_method.write([(ghg_flow.key, 1)])
lca = bc.LCA({a: 1}, ("GHG scores", "direct"))
lca.lci()
lca.lcia()
lca.score
>>> 7.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment