Skip to content

Commit

Permalink
check biosphere before import
Browse files Browse the repository at this point in the history
  • Loading branch information
pjamesjoyce committed Jan 15, 2020
1 parent 4ff015e commit 1b39d5c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions futura/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import brightway2 as bw2

from bw2data import projects, databases
from bw2io import ExcelImporter, SingleOutputEcospold2Importer, bw2setup, create_core_migrations, migrations
from bw2io import ExcelImporter, SingleOutputEcospold2Importer, bw2setup, create_core_migrations, migrations, create_default_biosphere3

from .utils import *
from .storage import storage
Expand Down Expand Up @@ -79,6 +79,10 @@ def extract_excel_data(self, excelfilepath):
if not migrations:
create_core_migrations()

if 'biosphere3' not in databases:
create_default_biosphere3()


# link the biosphere exchanges
sp.apply_strategies(verbose=False)

Expand Down Expand Up @@ -116,7 +120,7 @@ def extract_excel_data(self, excelfilepath):
for x in still_unlinked:
for exc in x.get('exchanges', []):
if not exc.get("input"):
if exc['location'] == 'RoW':
if exc.get('location') == 'RoW':
exc['location'] = 'GLO'

still_unlinked = link_iterable_by_fields(still_unlinked, self.db, fields=["name", "unit", "location"])
Expand Down

0 comments on commit 1b39d5c

Please sign in to comment.