Scenario uncertainty - #302
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a Brightway export for evaluating multiple premise scenarios from one database and one compressed bw_processing package.
array_path = ndb.write_scenario_array_db_to_brightway(
name="scenario-ensemble",
)
The method writes:
The initial LCA uses original. Each next(lca) selects the next complete scenario, with iteration wrapping to original after the final scenario.
Motivation
Writing one Brightway database per scenario is expensive and makes large scenario ensembles cumbersome. Existing superstructure exports target Activity Browser and require a scenario-difference file.
This export allows deterministic scenario enumeration directly through bw2calc.
Usage
demand, data_objs, remapping = bd.prepare_lca_inputs(
{functional_unit: 1},
method=method,
)
lca = bc.LCA(
demand,
data_objs=[*data_objs, array_path],
remapping_dicts=remapping,
use_arrays=True,
)
lca.lci()
lca.lcia()
scores = [lca.score] # original
for _ in ndb.scenarios:
next(lca)
scores.append(lca.score)
The ZIP must be appended after the database datapackages so its changing coordinates override the base database.
Implementation
The array ZIP is tied to the active Brightway project and its assigned node IDs. It must be regenerated after moving, deleting, or rewriting the database.
Documentation
The PR adds: