Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cmutel committed Jul 23, 2024
2 parents 15c6018 + c505750 commit 45bf6bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 14 additions & 1 deletion ecoinvent_migrate/data_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@


def get_change_report_filepath(version: str, release: EcoinventRelease) -> Path:
"""Get the filepath to the Excel change report file"""
"""Get the filepath to the Excel change report file.
Download a list of extra files from ecoinvent and do pattern matching."""
files = release.list_extra_files(version)
candidates = [key for key in files if "change report" in key.lower() and "annex" in key.lower()]
if not candidates:
Expand Down Expand Up @@ -59,6 +61,7 @@ def setup_project(
ecoinvent_username: Optional[str] = None,
ecoinvent_password: Optional[str] = None,
) -> None:
"""Switch to or create a Brightway project, and install the source and target databases."""
bd.projects.set_current(project_name)

if f"ecoinvent-{source_version}-{system_model}" not in bd.databases:
Expand Down Expand Up @@ -90,6 +93,16 @@ def setup_project(


def get_brightway_databases(source_version: str, target_version: str, system_model: str):
"""Get database names and process caches for source and target databases.
Returns:
* `source_db_name`: str. Standardized name for ecoinvent based on `ecoinvent_interface` standard
* `target_db_name`: str. Standardized name for ecoinvent based on `ecoinvent_interface` standard
* `source_lookup`: dict. Dictionary from attribute tuple (name, location, reference product) to `Node` object.
* `target_lookup`: dict. Dictionary from attribute tuple (name, location, reference product) to `Node` object.
"""
source_db_name = f"ecoinvent-{source_version}-{system_model}"
target_db_name = f"ecoinvent-{target_version}-{system_model}"
if source_db_name not in bd.databases:
Expand Down
4 changes: 3 additions & 1 deletion ecoinvent_migrate/wrangling.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def isnan(o: Union[str, Number]) -> bool:


def split_by_semicolon(row: dict, version: str) -> list[dict]:
"""Possible split a data row into"""
"""Turn a data `row` into one or more dictionaries.
Splits reference product and unit values by `;\n`."""
if isinstance(row[f"Activity Name - {version}"], Number) and math.isnan(
row[f"Activity Name - {version}"]
):
Expand Down

0 comments on commit 45bf6bd

Please sign in to comment.