Closed cswh closed 1 year ago
Hestia is currently working on including ecoinvent process names in Hestia datasets directly, which then are easily accessible via the API.
For now, we use the following approach, which unfortunately requires some manual adaptions of the mappings: For each term type, Hestia provides mappings from term.ids to ecoinvent activity names. They areavailable via the API:
import requests
import pandas as pd
from io import StringIO
def fetch_ecoinvent_mappings(term_type):
URL = f"https://www.hestia.earth/glossary/lookups/{term_type}.csv"
response = requests.get(URL)
data = StringIO(response.text)
ecoinvent_mappings= (
pd.read_csv(data)[["term.id", "ecoinventMapping"]]
.set_index("term.id")
.dropna()
)
return ecoinvent_mappings
However, the names of the ecoinvent activities (as provided by Hestia) are inconsistent with ecoinvent. Some general rules can be applied to improve this, e.g.:
# remove everything before "market"
ecoinvent_mappings.str.replace(r"^.*?(?=market)", "", regex=True)
# remove everything after ":"
ecoinvent_mappings.str.replace(r":.*$", "", regex=True)
# remove everything before "electricity
ecoinvent_mappings.str.replace(r"^.*?(?=electricity production)", "", regex=True) production"
Unfortunately, some inconsistencies remain. Some Hestia-Mappings base on outdated ecoinvent names and have to be adapted manually. Thus, we use an updated static mapping via a .csv file (ecoinvent_mappings.csv) for now.
The Script to generate the mapping file was added to the /dev folder: https://github.com/brightway-lca/bw_hestia_bridge/commit/9e682e021d18e19fea3bd49737bf76b9e3fd9f75
Mapping is available in csv files: https://www.hestia.earth/glossary/Emissions%20&%20Resource%20Use/emission.csv
They can be adressed via the API as well.