Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Aug 22, 2024
2 parents e8ba1dd + 92981e2 commit 5d078cb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
20 changes: 13 additions & 7 deletions premise_gwp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@

DATA_DIR = Path(__file__).resolve().parent / "data"

import bw2io, bw2data
import bw2data
import bw2io
from bw2io import ExcelLCIAImporter

from .biosphere import check_biosphere_database, check_biosphere_version, load_ei310_mapping
from .biosphere import (
check_biosphere_database,
check_biosphere_version,
load_ei310_mapping,
)
from .version import version as __version__


Expand Down Expand Up @@ -96,17 +101,15 @@ def add_premise_gwp():
for flow in method["exchanges"]:
flow["name"] = mapping.get(flow["name"], flow["name"])



# apply formatting strategies
category.apply_strategies()


# check that no flow is unlinked
if len(list(category.unlinked)) > 0:
if bw2io_version == (0, 8, 12):
if all(
flow["categories"] == ('air', 'lower stratosphere + upper troposphere')
flow["categories"]
== ("air", "lower stratosphere + upper troposphere")
for flow in category.unlinked
):
category.drop_unlinked()
Expand All @@ -120,7 +123,10 @@ def add_premise_gwp():

# write method
category.name = c[0]
category.write_methods(overwrite=True, verbose=True,)
category.write_methods(
overwrite=True,
verbose=True,
)
method = [m for m in bw2data.methods if m == c[0]][0]
m = bw2data.Method(method)
m.metadata["name"] = c[0]
4 changes: 3 additions & 1 deletion premise_gwp/biosphere.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import bw2data as bd
from pathlib import Path

import bw2data as bd
import yaml

DATA_DIR = Path(__file__).resolve().parent / "data"
Expand All @@ -10,6 +11,7 @@ def load_ei310_mapping():
mappings = yaml.safe_load(stream)
return mappings


def check_presence_biosphere_database(biosphere_name: str) -> str:
"""
Check that the biosphere database is present in the current project.
Expand Down

0 comments on commit 5d078cb

Please sign in to comment.