Skip to content

Commit

Permalink
feat: Intégration Laine woolmark (#831)
Browse files Browse the repository at this point in the history
## 🔧 Problem

We got new more robust LCI data for wool.

## 🍰 Solution

Implement the new wool data: import into brightway, generate an export
(still using simapro data)

There is a new `external_db` option is the toplevel
`common.import_.import_simapro_csv` function to link the new activities
to an existing db. It's transmitted as is to the
`link_technosphere_by_activity_hash` strategy. This is because the new
wool data is created using EI 3.10 as a library in SimaPro, so we have
to import EI3.10 first then link to it.

## 🏝️ How to test

Get the new `wool.CSV.zip data`, import the wool using `make
import_ecoivent` then rebuild the image `make image` and do an export
with `make export_textile` and check there is no diff.
Check the new cool is one third below the previous one in terms of
impacts.

ecobalyse-data: laine_woolmark
  • Loading branch information
ccomb authored Nov 18, 2024
1 parent 4e2fb1e commit ca8a987
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 32 deletions.
4 changes: 3 additions & 1 deletion data/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def normalization_factors(impact_defs):


def spproject(activity):
"""return the current simapro project for an activity"""
"""return the current simapro project for an activity source database"""
match activity.get("database"):
case "Ginko":
return "Ginko w/o azadirachtin"
Expand All @@ -26,6 +26,8 @@ def spproject(activity):
return "EcobalyseIsNotASimaProProject"
case "Ecoinvent 3.9.1":
return "ADEME UPR"
case "Woolmark":
return "Woolmark"
case _:
return "AGB3.1.1 2023-03-06"

Expand Down
7 changes: 6 additions & 1 deletion data/common/import_.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def add_variant_activity(activity_data, dbname):
def import_simapro_csv(
datapath,
dbname,
external_db=None,
biosphere="biosphere3",
migrations=[],
first_strategies=[],
Expand Down Expand Up @@ -236,7 +237,11 @@ def import_simapro_csv(
database.statistics()
# try to link remaining unlinked technosphere activities
database.apply_strategy(
functools.partial(link_technosphere_by_activity_hash, fields=("name", "unit"))
functools.partial(
link_technosphere_by_activity_hash,
external_db_name=external_db,
fields=("name", "unit"),
)
)
database.apply_strategy(
functools.partial(
Expand Down
2 changes: 1 addition & 1 deletion data/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN mkdir -p /home/$NB_USER/data \

# keep in sync with requirements.txt
# allow to update the image if the source repo is updated
ADD https://api.github.com/repos/ccomb/brightway2-io/git/refs/tags/ccomb-5 bw2-io.json
ADD https://api.github.com/repos/ccomb/brightway2-io/git/refs/tags/ccomb-6 bw2-io.json
ADD https://api.github.com/repos/brightway-lca/brightway2-parameters/git/refs/tags/1.1.0 bw2-parameters.json
ADD https://api.github.com/repos/brightway-lca/brightway2-data/git/refs/tags/4.0.dev42 bw2-data.json
ADD https://api.github.com/repos/brightway-lca/brightway2-calc/git/refs/tags/2.0.dev17 bw2-calc.json
Expand Down
2 changes: 1 addition & 1 deletion data/docker/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ git+https://github.com/brightway-lca/[email protected]
git+https://github.com/brightway-lca/[email protected]
git+https://github.com/brightway-lca/[email protected]
git+https://github.com/brightway-lca/[email protected]
git+https://github.com/ccomb/brightway2-io@ccomb-5
git+https://github.com/ccomb/brightway2-io@ccomb-6
ipywidgets>=8.1, <8.2
jupyter-collaboration>=2.0, <2.1
matplotlib>=3.7, <3.8
Expand Down
11 changes: 11 additions & 0 deletions data/import_ecoinvent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# Ecoinvent
EI391 = "./Ecoinvent3.9.1.CSV.zip"
EI310 = "./Ecoinvent3.10.CSV.zip"
WOOL = "./wool.CSV.zip"
BIOSPHERE = "biosphere3"
PROJECT = "default"
EXCLUDED = [
Expand Down Expand Up @@ -45,6 +46,16 @@ def main():
else:
print(f"{db} already imported")

if (db := "Woolmark") not in bw2data.databases:
import_simapro_csv(
join("..", "..", "dbfiles", WOOL),
db,
external_db="Ecoinvent 3.10", # wool is linked with EI 3.10
excluded_strategies=EXCLUDED,
)
else:
print(f"{db} already imported")


if __name__ == "__main__":
main()
26 changes: 2 additions & 24 deletions data/textile/activities.json
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@
{
"displayName": "Laine par défaut",
"info": "Textile > Matières > Matières naturelles",
"source": "Custom",
"source": "Woolmark",
"search": "greasy sheep wool",
"correctif": "",
"step_usage": "Matières",
"uuid": "wool-default",
Expand All @@ -512,29 +513,6 @@
"geographicOrigin": "Asie - Pacifique",
"defaultCountry": "CN",
"unit": "kg",
"impacts": {
"acd": 0.949051,
"cch": 30.5996,
"etf": 125.562,
"etf-c": 170.543,
"fru": 34.1905,
"fwe": 0.00923991,
"htc": -7.09764e-10,
"htc-c": 3.31229e-9,
"htn": -6.25711e-7,
"htn-c": 8.57317e-8,
"ior": 0.0862947,
"ldu": 2335.33,
"mru": 5.16897e-5,
"ozd": 4.86254e-8,
"pco": 0.0305717,
"pma": 6.7068e-6,
"swe": 0.158058,
"tre": 4.21086,
"wtu": 16.2801,
"ecs": 4263.098561863456,
"pef": 4646.846238265963
},
"primary": false
},
{
Expand Down
8 changes: 4 additions & 4 deletions public/data/textile/processes.json
Original file line number Diff line number Diff line change
Expand Up @@ -988,11 +988,11 @@
"alias": null
},
{
"name": "Laine par défaut",
"name": "wool; sheep; production mix; at farm; 1 kg greasy wool",
"displayName": "Laine par défaut",
"info": "Textile > Matières > Matières naturelles",
"unit": "kg",
"source": "Custom",
"source": "Woolmark",
"correctif": "",
"step_usage": "Matières",
"uuid": "wool-default",
Expand All @@ -1016,8 +1016,8 @@
"swe": 0,
"tre": 0,
"wtu": 0,
"ecs": 4263.098561863456,
"pef": 4646.846238265962
"ecs": 2781.800631273725,
"pef": 2931.4802301799327
},
"heat_MJ": 0,
"elec_pppm": 0,
Expand Down

0 comments on commit ca8a987

Please sign in to comment.