-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/pathways' into pathways
# Conflicts: # docs/transform.rst # premise/__init__.py # premise/data/additional_inventories/lci-pass_cars.xlsx # premise/data/additional_inventories/lci-trucks.xlsx # premise/data/consequential/leadtimes.yaml # premise/data/transport/vehicles_map.yaml # premise/data/utils/export/simapro_categories.csv
- Loading branch information
Showing
14 changed files
with
8,817 additions
and
8,096 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file modified
BIN
+2.81 KB
(100%)
premise/data/additional_inventories/lci-batteries-vanadium.xlsx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15,724 changes: 7,862 additions & 7,862 deletions
15,724
premise/data/electricity/coal_power_emissions_2012_v1.csv
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
525 changes: 508 additions & 17 deletions
525
premise/data/metals/post-allocation correction/corrections.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import gc | ||
import os | ||
|
||
import bw2calc | ||
import bw2data | ||
import bw2io | ||
import pytest | ||
from dotenv import load_dotenv | ||
|
||
from premise import NewDatabase, clear_inventory_cache | ||
from premise.utils import delete_all_pickles | ||
|
||
load_dotenv() | ||
|
||
|
||
ei_user = os.environ["EI_USERNAME"] | ||
ei_pass = os.environ["EI_PASSWORD"] | ||
key = os.environ["IAM_FILES_KEY"] | ||
# convert to bytes | ||
key = key.encode() | ||
|
||
ei_version = "3.8" | ||
system_model = "consequential" | ||
|
||
|
||
scenarios = [ | ||
{"model": "remind", "pathway": "SSP2-Base", "year": 2050}, | ||
{"model": "image", "pathway": "SSP2-RCP19", "year": 2050}, | ||
] | ||
|
||
|
||
@pytest.mark.slow | ||
def test_brightway(): | ||
|
||
bw2data.projects.set_current(f"ecoinvent-{ei_version}-{system_model}") | ||
|
||
clear_inventory_cache() | ||
|
||
if f"ecoinvent-{ei_version}-{system_model}" not in bw2data.databases: | ||
bw2io.import_ecoinvent_release( | ||
version=ei_version, | ||
system_model=system_model, | ||
username=ei_user, | ||
password=ei_pass, | ||
) | ||
|
||
ndb = NewDatabase( | ||
scenarios=scenarios, | ||
source_db=f"ecoinvent-{ei_version}-{system_model}", | ||
source_version=ei_version, | ||
key=key, | ||
system_model=system_model, | ||
biosphere_name=f"ecoinvent-{ei_version}-biosphere", | ||
) | ||
|
||
ndb.update() | ||
|
||
if "test1" in bw2data.databases: | ||
del bw2data.databases["test1"] | ||
if "test2" in bw2data.databases: | ||
del bw2data.databases["test2"] | ||
|
||
ndb.write_db_to_brightway( | ||
[ | ||
"test1", | ||
"test2", | ||
] | ||
) | ||
|
||
method = [m for m in bw2data.methods if "IPCC" in m[0]][0] | ||
|
||
lca = bw2calc.LCA({bw2data.Database("test1").random(): 1}, method) | ||
lca.lci() | ||
lca.lcia() | ||
assert isinstance(lca.score, float) | ||
print(lca.score) | ||
|
||
# destroy all objects | ||
del ndb | ||
del lca | ||
gc.collect() | ||
delete_all_pickles() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import gc | ||
import os | ||
|
||
import bw2calc | ||
import bw2data | ||
import bw2io | ||
import pytest | ||
from dotenv import load_dotenv | ||
|
||
from premise import NewDatabase, clear_inventory_cache | ||
from premise.utils import delete_all_pickles | ||
|
||
load_dotenv() | ||
|
||
|
||
ei_user = os.environ["EI_USERNAME"] | ||
ei_pass = os.environ["EI_PASSWORD"] | ||
key = os.environ["IAM_FILES_KEY"] | ||
# convert to bytes | ||
key = key.encode() | ||
|
||
ei_version = "3.8" | ||
system_model = "cutoff" | ||
|
||
|
||
scenarios = [ | ||
{"model": "remind", "pathway": "SSP2-Base", "year": 2050}, | ||
{"model": "image", "pathway": "SSP2-RCP19", "year": 2050}, | ||
] | ||
|
||
|
||
@pytest.mark.slow | ||
def test_brightway(): | ||
|
||
bw2data.projects.set_current(f"ecoinvent-{ei_version}-{system_model}") | ||
clear_inventory_cache() | ||
|
||
if f"ecoinvent-{ei_version}-{system_model}" not in bw2data.databases: | ||
bw2io.import_ecoinvent_release( | ||
version=ei_version, | ||
system_model=system_model, | ||
username=ei_user, | ||
password=ei_pass, | ||
) | ||
|
||
ndb = NewDatabase( | ||
scenarios=scenarios, | ||
source_db=f"ecoinvent-{ei_version}-{system_model}", | ||
source_version=ei_version, | ||
key=key, | ||
system_model=system_model, | ||
biosphere_name=f"ecoinvent-{ei_version}-biosphere", | ||
) | ||
|
||
ndb.update() | ||
|
||
if "test1" in bw2data.databases: | ||
del bw2data.databases["test1"] | ||
if "test2" in bw2data.databases: | ||
del bw2data.databases["test2"] | ||
|
||
ndb.write_db_to_brightway( | ||
[ | ||
"test1", | ||
"test2", | ||
] | ||
) | ||
|
||
method = [m for m in bw2data.methods if "IPCC" in m[0]][0] | ||
|
||
lca = bw2calc.LCA({bw2data.Database("test1").random(): 1}, method) | ||
lca.lci() | ||
lca.lcia() | ||
assert isinstance(lca.score, float) | ||
print(lca.score) | ||
|
||
# destroy all objects | ||
del ndb | ||
del lca | ||
gc.collect() | ||
delete_all_pickles() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import gc | ||
import os | ||
|
||
import bw2calc | ||
import bw2data | ||
import bw2io | ||
import pytest | ||
from dotenv import load_dotenv | ||
|
||
from premise import NewDatabase, clear_inventory_cache | ||
from premise.utils import delete_all_pickles | ||
|
||
load_dotenv() | ||
|
||
|
||
ei_user = os.environ["EI_USERNAME"] | ||
ei_pass = os.environ["EI_PASSWORD"] | ||
key = os.environ["IAM_FILES_KEY"] | ||
# convert to bytes | ||
key = key.encode() | ||
|
||
ei_version = "3.9.1" | ||
system_model = "consequential" | ||
|
||
|
||
scenarios = [ | ||
{"model": "remind", "pathway": "SSP2-Base", "year": 2050}, | ||
{"model": "image", "pathway": "SSP2-RCP19", "year": 2050}, | ||
] | ||
|
||
|
||
@pytest.mark.slow | ||
def test_brightway(): | ||
|
||
bw2data.projects.set_current(f"ecoinvent-{ei_version}-{system_model}") | ||
|
||
clear_inventory_cache() | ||
|
||
if f"ecoinvent-{ei_version}-{system_model}" not in bw2data.databases: | ||
bw2io.import_ecoinvent_release( | ||
version=ei_version, | ||
system_model=system_model, | ||
username=ei_user, | ||
password=ei_pass, | ||
) | ||
|
||
ndb = NewDatabase( | ||
scenarios=scenarios, | ||
source_db=f"ecoinvent-{ei_version}-{system_model}", | ||
source_version=ei_version, | ||
key=key, | ||
system_model=system_model, | ||
biosphere_name=f"ecoinvent-{ei_version}-biosphere", | ||
) | ||
|
||
ndb.update() | ||
|
||
if "test1" in bw2data.databases: | ||
del bw2data.databases["test1"] | ||
if "test2" in bw2data.databases: | ||
del bw2data.databases["test2"] | ||
|
||
ndb.write_db_to_brightway( | ||
[ | ||
"test1", | ||
"test2", | ||
] | ||
) | ||
|
||
method = [m for m in bw2data.methods if "IPCC" in m[0]][0] | ||
|
||
lca = bw2calc.LCA({bw2data.Database("test1").random(): 1}, method) | ||
lca.lci() | ||
lca.lcia() | ||
assert isinstance(lca.score, float) | ||
print(lca.score) | ||
|
||
# destroy all objects | ||
del ndb | ||
del lca | ||
gc.collect() | ||
delete_all_pickles() |