[docs]
GEO_UPDATE = {
"Al producing Area 2, North America": "IAI Area, North America",
"IAI Area 2, North America": "IAI Area, North America",
"IAI Area, North America, without Quebec": "IAI Area, North America, without Quebec",
"IAI Area 1": "IAI Area, Africa",
"IAI Area 3": "IAI Area, South America",
"IAI Area 4&5 without China": "IAI Area, Asia, without China and GCC",
"IAI Area 6A": "IAI Area, West Europe",
"IAI Area, Europe outside EU & EFTA": "IAI Area, Russia & RER w/o EU27 & EFTA",
"IAI Area 8": "IAI Area, Gulf Cooperation Council",
"Ashmore and Cartier Islands": "AUS-AC",
"Indian Ocean Territories": "AUS-IOT",
"CC": "AUS-IOT",
"CX": "AUS-IOT",
"ROC": "Canada without Quebec",
"MRO, US only": "US-MRO",
"NPCC, US only": "US-NPCC",
"WECC, US only": "US-WECC",
"CSG": "CN-CSG",
"SGCC": "CN-SGCC",
"FRCC": "US-FRCC",
"HICC": "US-HICC",
"RFC": "US-RFC",
"SERC": "US-SERC",
"SPP": "US-SPP",
"TRE": "US-TRE",
"ASCC": "US-ASCC",
}
[docs]
def update_ecoinvent_locations(db):
"""
Update location names in ecoinvent database to fix inconsistencies and standardize naming.
Maps the old location names to the updated ones based on a predefined dictionary (GEO_UPDATE).
Parameters
----------
db : list
A list of dictionaries representing ecoinvent processes with exchanges.
Returns
-------
list
A list of dictionaries representing the ecoinvent processes with updated location names.
Examples
--------
>>> db = [
... {
... "name": "Process 1",
... "location": "IAI Area 2, North America",
... "exchanges": [{"name": "Flow 1", "location": "IAI Area 2, North America"}],
... }
... ]
>>> update_ecoinvent_locations(db)
[
{
"name": "Process 1",
"location": "IAI Area, North America",
"exchanges": [{"name": "Flow 1", "location": "IAI Area, North America"}],
}
]
Notes
-----
Includes a hardcoded mapping (GEO_UPDATE) to fix known inconsistencies in location names. This may not
cover all possible inconsistencies and might need to be updated in the future.
"""
for ds in db:
if "location" in ds:
ds["location"] = GEO_UPDATE.get(ds["location"], ds["location"])
for exc in ds.get("exchanges", []):
if "location" in exc:
exc["location"] = GEO_UPDATE.get(exc["location"], exc["location"])
return db