Skip to content

Commit 52011cc

Browse files
committed
Start patching ecoinvent data
1 parent 45bf6bd commit 52011cc

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

ecoinvent_migrate/main.py

+10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
source_target_pair_as_bw_dict,
1717
split_replace_disaggregate,
1818
)
19+
from .patches import TECHNOSPHERE_PATCHES
1920
from . import __version__
2021

2122

@@ -145,6 +146,12 @@ def generate_technosphere_mapping(
145146
)
146147
data = split_replace_disaggregate(data=data, target_lookup=target_lookup)
147148

149+
try:
150+
for key, value in TECHNOSPHERE_PATCHES[(source_version, target_version)].items():
151+
data[key].extend(value)
152+
except KeyError:
153+
pass
154+
148155
if not data["replace"] and not data["disaggregate"]:
149156
logger.info(
150157
"It seems like there are no technosphere changes for this release. Doing nothing."
@@ -231,6 +238,9 @@ def generate_biosphere_mapping(
231238
)
232239
)
233240

241+
if not description:
242+
description = f"Data migration file from {source_db_name} to {target_db_name} generated with `ecoinvent_migrate` version {__version__}"
243+
234244
data = pd.read_excel(io=excel_filepath, sheet_name=candidates[0]).to_dict(orient="records")
235245
data = source_target_biosphere_pair(
236246
data=data,

ecoinvent_migrate/patches.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
TECHNOSPHERE_PATCHES = {
2+
("3.9.1", "3.10"): {
3+
'replace': [
4+
{
5+
'source': {
6+
'name': "modified Solvay process, Hou's process",
7+
'location': 'GLO',
8+
'reference product': 'ammonium chloride',
9+
'unit': 'kg'
10+
},
11+
'target': {
12+
'name': "soda ash production, dense, Hou's process",
13+
'location': 'GLO',
14+
'reference product': 'ammonium chloride',
15+
'unit': 'kg'
16+
}
17+
},
18+
{
19+
'source': {
20+
'name': 'Mannheim process',
21+
'location': 'RER',
22+
'reference product': 'sodium sulfate, anhydrite',
23+
'unit': 'kg'
24+
},
25+
'target': {
26+
'name': "hydrochloric acid production, Mannheim process",
27+
'location': 'RER',
28+
'reference product': 'sodium sulfate, anhydrite',
29+
'unit': 'kg'
30+
}
31+
},
32+
{
33+
'source': {
34+
'name': 'Mannheim process',
35+
'location': 'RoW',
36+
'reference product': 'sodium sulfate, anhydrite',
37+
'unit': 'kg'
38+
},
39+
'target': {
40+
'name': "hydrochloric acid production, Mannheim process",
41+
'location': 'RoW',
42+
'reference product': 'sodium sulfate, anhydrite',
43+
'unit': 'kg'
44+
}
45+
},
46+
]
47+
}
48+
}

0 commit comments

Comments
 (0)