Skip to content

Commit

Permalink
Merge pull request #189 from Cerebrovinny/documentation-improvements-…
Browse files Browse the repository at this point in the history
…locations

Update docstrings to NumPy standard `(strategies/locations)`
  • Loading branch information
michaelweinold committed Jul 19, 2023
2 parents 05897b3 + 3236253 commit c3f795a
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion bw2io/strategies/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,44 @@


def update_ecoinvent_locations(db):
"""Update old ecoinvent location codes"""
"""
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"])
Expand Down

0 comments on commit c3f795a

Please sign in to comment.