Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Jun 22, 2023
2 parents ec00e34 + 1f2ae79 commit 2b153ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
5 changes: 3 additions & 2 deletions premise/ecoinvent_modification.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@
FILEPATH_HYDROGEN_DISTRI_INVENTORIES = INVENTORY_DIR / "lci-hydrogen-distribution.xlsx"

FILEPATH_HYDROGEN_INVENTORIES = INVENTORY_DIR / "lci-hydrogen-electrolysis.xlsx"
FILEPATH_HYDROGEN_SOLAR_INVENTORIES = INVENTORY_DIR / "lci-hydrogen-thermochemical-water-splitting.xlsx"
FILEPATH_HYDROGEN_SOLAR_INVENTORIES = (
INVENTORY_DIR / "lci-hydrogen-thermochemical-water-splitting.xlsx"
)
FILEPATH_HYDROGEN_PYROLYSIS_INVENTORIES = INVENTORY_DIR / "lci-hydrogen-pyrolysis.xlsx"

FILEPATH_HYDROGEN_BIOGAS_INVENTORIES = (
Expand Down Expand Up @@ -1336,7 +1338,6 @@ def write_datapackage(self, name: str = f"datapackage_{date.today()}"):
cache_fp = DATA_DIR / "cache" / f"cached_{self.source}_inventories.pickle"
raise ValueError(f"No cached inventories found at {cache_fp}.")


cache = {}
for scen, scenario in enumerate(self.scenarios):
print(f"Prepare database {scen + 1}.")
Expand Down
7 changes: 4 additions & 3 deletions premise/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@

from . import DATA_DIR, __version__
from .data_collection import get_delimiter
from .inventory_imports import get_correspondence_bio_flows
from .transformation import BaseTransformation
from .utils import check_database_name
from .inventory_imports import get_correspondence_bio_flows

FILEPATH_SIMAPRO_UNITS = DATA_DIR / "utils" / "export" / "simapro_units.yml"
FILEPATH_SIMAPRO_COMPARTMENTS = (
DATA_DIR / "utils" / "export" / "simapro_compartments.yml"
)
CORRESPONDENCE_BIO_FLOWS = DATA_DIR / "utils" / "export" / "correspondence_biosphere_flows.yaml"
CORRESPONDENCE_BIO_FLOWS = (
DATA_DIR / "utils" / "export" / "correspondence_biosphere_flows.yaml"
)

# current working directory
DIR_DATAPACKAGE = Path.cwd() / "export" / "datapackage"
Expand Down Expand Up @@ -437,7 +439,6 @@ def get_exchange(ind, acts_ind, db_name, version, amount=1.0):
}



def write_formatted_data(name, data, filepath):
"""
Adapted from bw2io.export.csv
Expand Down
13 changes: 9 additions & 4 deletions premise/inventory_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from functools import lru_cache
from pathlib import Path
from typing import Dict, List, Union
import numpy as np

import bw2io
import numpy as np
import requests
import yaml
from bw2io import CSVImporter, ExcelImporter, Migration
Expand All @@ -26,7 +26,9 @@

FILEPATH_MIGRATION_MAP = INVENTORY_DIR / "migration_map.csv"
FILEPATH_CONSEQUENTIAL_BLACKLIST = DATA_DIR / "consequential" / "blacklist.yaml"
CORRESPONDENCE_BIO_FLOWS = DATA_DIR / "utils" / "export" / "correspondence_biosphere_flows.yaml"
CORRESPONDENCE_BIO_FLOWS = (
DATA_DIR / "utils" / "export" / "correspondence_biosphere_flows.yaml"
)


def get_correspondence_bio_flows():
Expand Down Expand Up @@ -201,6 +203,7 @@ def check_for_datasets_compliance_with_consequential_database(

return datasets


def check_amount_format(database: list) -> list:
"""
Check that the `amount` field is of type `float`.
Expand Down Expand Up @@ -229,6 +232,7 @@ def check_amount_format(database: list) -> list:

return database


class BaseInventoryImport:
"""
Base class for inventories that are to be merged with the wurst database.
Expand Down Expand Up @@ -552,7 +556,9 @@ def add_biosphere_links(self, delete_missing: bool = False) -> None:
new_key = list(key)
new_key[0] = self.correspondence_bio_flows[key[1]][key[0]]
key = tuple(new_key)
assert key in self.biosphere_dict, f"Could not find a biosphere flow for {key}."
assert (
key in self.biosphere_dict
), f"Could not find a biosphere flow for {key}."
else:
print(key)
continue
Expand All @@ -562,7 +568,6 @@ def add_biosphere_links(self, delete_missing: bool = False) -> None:
self.biosphere_dict[key],
)


def remove_ds_and_modifiy_exchanges(self, name: str, ex_data: dict) -> None:
"""
Remove an activity dataset from :attr:`import_db` and replace the corresponding
Expand Down

0 comments on commit 2b153ee

Please sign in to comment.