From ca8a9878ef34b3d799d2e4b5157e87d8e121df94 Mon Sep 17 00:00:00 2001 From: Christophe Combelles Date: Mon, 18 Nov 2024 12:23:08 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20Int=C3=A9gration=20Laine=20woolmark=20(?= =?UTF-8?q?#831)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## :wrench: Problem We got new more robust LCI data for wool. ## :cake: 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. ## :desert_island: 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 --- data/common/__init__.py | 4 +++- data/common/import_.py | 7 ++++++- data/docker/Dockerfile | 2 +- data/docker/requirements.txt | 2 +- data/import_ecoinvent.py | 11 +++++++++++ data/textile/activities.json | 26 ++------------------------ public/data/textile/processes.json | 8 ++++---- 7 files changed, 28 insertions(+), 32 deletions(-) diff --git a/data/common/__init__.py b/data/common/__init__.py index d75d51b85..a3a71e534 100644 --- a/data/common/__init__.py +++ b/data/common/__init__.py @@ -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" @@ -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" diff --git a/data/common/import_.py b/data/common/import_.py index a6de85078..cc0d0b757 100644 --- a/data/common/import_.py +++ b/data/common/import_.py @@ -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=[], @@ -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( diff --git a/data/docker/Dockerfile b/data/docker/Dockerfile index d1b85e9db..ce8fa4964 100644 --- a/data/docker/Dockerfile +++ b/data/docker/Dockerfile @@ -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 diff --git a/data/docker/requirements.txt b/data/docker/requirements.txt index e7b9f8988..649445423 100644 --- a/data/docker/requirements.txt +++ b/data/docker/requirements.txt @@ -12,7 +12,7 @@ git+https://github.com/brightway-lca/brightway2-calc@2.0.dev17 git+https://github.com/brightway-lca/brightway2-data@4.0.dev42 git+https://github.com/brightway-lca/brightway2-parameters@1.1.0 git+https://github.com/brightway-lca/bw_projects@v2.1.0 -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 diff --git a/data/import_ecoinvent.py b/data/import_ecoinvent.py index 357402cd1..6a59d4b77 100755 --- a/data/import_ecoinvent.py +++ b/data/import_ecoinvent.py @@ -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 = [ @@ -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() diff --git a/data/textile/activities.json b/data/textile/activities.json index ec5ec2215..2857d242a 100644 --- a/data/textile/activities.json +++ b/data/textile/activities.json @@ -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", @@ -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 }, { diff --git a/public/data/textile/processes.json b/public/data/textile/processes.json index e2c6456ae..2a1d1835c 100644 --- a/public/data/textile/processes.json +++ b/public/data/textile/processes.json @@ -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", @@ -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,