lca_supplymat 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .venv/
6
+
7
+ # Build artifacts
8
+ dist/
9
+ build/
10
+
11
+ # Test / runtime data
12
+ data/
13
+ .cache/
14
+
15
+ # Notebook checkpoints
16
+ .ipynb_checkpoints/
17
+
18
+ # IDE
19
+ .idea/
20
+ *.pypi.md
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Raphaël JOLIVET, Joanna SCHLESINGER-MARTINAT
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ .PHONY: build publish
2
+
3
+ build:
4
+ .venv/bin/python scripts/preprocess_readme.py
5
+ uv build --out-dir dist
6
+
7
+ publish: build
8
+ uv publish --index pypi
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.5
2
+ Name: lca_supplymat
3
+ Version: 0.1.3
4
+ Summary: Calculate material-related metrics from Life Cycle Inventory data via a Brightway LCIA method.
5
+ Project-URL: Homepage, https://git.sophia.minesparis.psl.eu/oie/acv/lca-supplymat
6
+ Project-URL: Source, https://git.sophia.minesparis.psl.eu/oie/acv/lca-supplymat
7
+ Author: Raphaël JOLIVET, Joanna SCHLESINGER-MARTINAT
8
+ License: MIT License
9
+
10
+ Copyright (c) 2026 Raphaël JOLIVET, Joanna SCHLESINGER-MARTINAT
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ License-File: LICENSE
30
+ Requires-Python: >=3.12
31
+ Requires-Dist: brightway25>=1.1.1
32
+ Requires-Dist: ipykernel>=7.3.0
33
+ Requires-Dist: ipywidgets>=8.1.9
34
+ Requires-Dist: pypardiso>=0.4.7
35
+ Requires-Dist: pyyaml>=6.0.3
36
+ Requires-Dist: rich>=15.0.0
37
+ Provides-Extra: test
38
+ Requires-Dist: pytest>=8; extra == 'test'
39
+ Requires-Dist: tox>=4; extra == 'test'
40
+ Description-Content-Type: text/markdown
41
+
42
+ # lca_supplymat
43
+
44
+ A [Brightway](https://brightway.dev/) Life Cycle Impact Assessment (LCIA) method that computes the **amount of manufactured materials** (copper, concrete, steel, aluminium, …) directly from Life Cycle Inventory (LCI) data.
45
+
46
+ ## Intro
47
+
48
+ Impact indicators related to material depletion, criticality or circularity are notoriously complex to interpret. `lca-supplymat` exposes a simpler, physical metric: the **quantity of manufactured material** required by an inventory. Instead of weighing environmental impact, it counts how much of a given material (e.g. copper or steel) is embedded in the activities of a life cycle.
49
+
50
+ This library implements this as a standard Brightway LCIA method, so it benefits from the full range of Brightway functionalities (MultiLCA, Monte-Carlo, parameterization, etc.). For each material, a pseudo-biosphere flow is added to the activities that produce it, and the method computes the **net production** of the material — the difference between what an activity outputs and what it consumes of the same material upstream. This avoids double counting between the production and market stages. One LCIA method is registered per material.
51
+
52
+ The approach was tested with ecoinvent 3.11 (cutoff and attributional system models). It is comparable in spirit to the [Edges](https://github.com/romainsacchi/EDGES_CA) library, but implemented natively within the Brightway framework.
53
+
54
+ ## Installation
55
+
56
+ ```bash
57
+ pip install lca_supplymat
58
+ ```
59
+
60
+ **Prerequisites** :
61
+ * A **Python>3.12** environement
62
+ * **Brightway 25** (will be installed if not found)
63
+ * A Brightway project with ecoinvent background database
64
+
65
+ ## Usage
66
+
67
+ ### Setup of the methods
68
+
69
+ ```python
70
+ from lca_supplymat import setup_lca_supply_mat, cleanup
71
+
72
+ setup_lca_supply_mat(
73
+ target_db="ecoinvent-3.11-cutoff",
74
+ yaml_file="path.yaml", # optionnal: load 23 definition from the package by default
75
+ subset=["concrete"], # optional: install only these definitions
76
+ out_folder="data/out", # optional: write a CSV report per material
77
+ check_impacts=True, # optional: verify impact scores are ~1
78
+ cleanup_before=True, # optional: reset existing material methods first
79
+ )
80
+ ```
81
+
82
+ What it does:
83
+
84
+ - creates a dedicated Brightway database `lca_supplymat` holding the pseudo-biosphere "counting" flows;
85
+ - computes the net production of each requested material for every matching activity and adds the corresponding exchanges;
86
+ - registers one Brightway `Method` per material, keyed as `("lca_supplymat", "total", "<material>")`.
87
+
88
+ Once the setup is done, you can use the new methods as regular LCIA methods in Brightway / Activity Browser.
89
+
90
+ To tear the material methods down again:
91
+
92
+ ```python
93
+ cleanup("ecoinvent-3.11-cutoff")
94
+ ```
95
+
96
+ ## Material definitions
97
+
98
+ By default, the 23 definitions of material methods are installed :
99
+ See [materials_methods.yaml](https://git.sophia.minesparis.psl.eu/oie/acv/lca-supplymat/-/blob/main/lca_supplymat/res/materials_methods.yaml)
100
+
101
+ ## Writing your own definitions
102
+
103
+ You can provide your own definitions by passing the `yaml_file` parameter.
104
+
105
+ The file maps a definition key to a set of matching rules:
106
+
107
+ ```yaml
108
+ copper:
109
+ matchings: ["copper, cathode*", "copper, anode*"]
110
+ excludes: ["*scrap*"] # optional: patterns that veto a match
111
+ unit: kilogram
112
+ tolerance: 0.05 # optional: allowed deviation for the impact check (default 0.05)
113
+ ```
114
+
115
+ - **`matchings`** (required): a list of patterns used to select activities.
116
+ - **`excludes`** (optional): a list of patterns; if any matches, the activity is rejected.
117
+ - **`unit`** (required): the unit the matching activities must be in.
118
+ - **`tolerance`** (optional): allowed deviation of the impact score from 1 during the `check_impacts` step (default `0.05`).
119
+
120
+ **Matching semantics.** Matching is performed against an activity's **reference product name** (`act["reference product"]`), and the activity's unit must equal the definition's `unit`. A pattern containing `*` acts as a **prefix wildcard** (`"steel*"` matches any reference product starting with `steel`); a pattern without `*` must be an **exact match**. `excludes` follows the same wildcard rules and overrides any `matchings` hit.
121
+
122
+ Then pass your file to the setup:
123
+
124
+ ```python
125
+ setup_lca_supply_mat(
126
+ target_db="ecoinvent-3.11-cutoff",
127
+ yaml_file="path/to/my_definitions.yaml")
128
+ ```
129
+
130
+ ## Example
131
+
132
+ See the [demo notebook](https://git.sophia.minesparis.psl.eu/oie/acv/lca-supplymat/-/blob/main/notebook.ipynb) for a complete, runnable example.
133
+
134
+ ## License
135
+
136
+ [MIT](https://git.sophia.minesparis.psl.eu/oie/acv/lca-supplymat/-/blob/main/LICENSE)
137
+
138
+ ## Authors
139
+
140
+ - [Raphaël JOLIVET](https://orcid.org/0000-0001-7149-5010)
141
+ - [Joanna SCHLESINGER-MARTINAT](https://orcid.org/0009-0006-0419-0990)
142
+
143
+ Organisation : [OIE | Mines Paris | PSL](https://ror.org/054fae424)
@@ -0,0 +1,102 @@
1
+ # lca_supplymat
2
+
3
+ A [Brightway](https://brightway.dev/) Life Cycle Impact Assessment (LCIA) method that computes the **amount of manufactured materials** (copper, concrete, steel, aluminium, …) directly from Life Cycle Inventory (LCI) data.
4
+
5
+ ## Intro
6
+
7
+ Impact indicators related to material depletion, criticality or circularity are notoriously complex to interpret. `lca-supplymat` exposes a simpler, physical metric: the **quantity of manufactured material** required by an inventory. Instead of weighing environmental impact, it counts how much of a given material (e.g. copper or steel) is embedded in the activities of a life cycle.
8
+
9
+ This library implements this as a standard Brightway LCIA method, so it benefits from the full range of Brightway functionalities (MultiLCA, Monte-Carlo, parameterization, etc.). For each material, a pseudo-biosphere flow is added to the activities that produce it, and the method computes the **net production** of the material — the difference between what an activity outputs and what it consumes of the same material upstream. This avoids double counting between the production and market stages. One LCIA method is registered per material.
10
+
11
+ The approach was tested with ecoinvent 3.11 (cutoff and attributional system models). It is comparable in spirit to the [Edges](https://github.com/romainsacchi/EDGES_CA) library, but implemented natively within the Brightway framework.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install lca_supplymat
17
+ ```
18
+
19
+ **Prerequisites** :
20
+ * A **Python>3.12** environement
21
+ * **Brightway 25** (will be installed if not found)
22
+ * A Brightway project with ecoinvent background database
23
+
24
+ ## Usage
25
+
26
+ ### Setup of the methods
27
+
28
+ ```python
29
+ from lca_supplymat import setup_lca_supply_mat, cleanup
30
+
31
+ setup_lca_supply_mat(
32
+ target_db="ecoinvent-3.11-cutoff",
33
+ yaml_file="path.yaml", # optionnal: load 23 definition from the package by default
34
+ subset=["concrete"], # optional: install only these definitions
35
+ out_folder="data/out", # optional: write a CSV report per material
36
+ check_impacts=True, # optional: verify impact scores are ~1
37
+ cleanup_before=True, # optional: reset existing material methods first
38
+ )
39
+ ```
40
+
41
+ What it does:
42
+
43
+ - creates a dedicated Brightway database `lca_supplymat` holding the pseudo-biosphere "counting" flows;
44
+ - computes the net production of each requested material for every matching activity and adds the corresponding exchanges;
45
+ - registers one Brightway `Method` per material, keyed as `("lca_supplymat", "total", "<material>")`.
46
+
47
+ Once the setup is done, you can use the new methods as regular LCIA methods in Brightway / Activity Browser.
48
+
49
+ To tear the material methods down again:
50
+
51
+ ```python
52
+ cleanup("ecoinvent-3.11-cutoff")
53
+ ```
54
+
55
+ ## Material definitions
56
+
57
+ By default, the 23 definitions of material methods are installed :
58
+ See [materials_methods.yaml](lca_supplymat/res/materials_methods.yaml)
59
+
60
+ ## Writing your own definitions
61
+
62
+ You can provide your own definitions by passing the `yaml_file` parameter.
63
+
64
+ The file maps a definition key to a set of matching rules:
65
+
66
+ ```yaml
67
+ copper:
68
+ matchings: ["copper, cathode*", "copper, anode*"]
69
+ excludes: ["*scrap*"] # optional: patterns that veto a match
70
+ unit: kilogram
71
+ tolerance: 0.05 # optional: allowed deviation for the impact check (default 0.05)
72
+ ```
73
+
74
+ - **`matchings`** (required): a list of patterns used to select activities.
75
+ - **`excludes`** (optional): a list of patterns; if any matches, the activity is rejected.
76
+ - **`unit`** (required): the unit the matching activities must be in.
77
+ - **`tolerance`** (optional): allowed deviation of the impact score from 1 during the `check_impacts` step (default `0.05`).
78
+
79
+ **Matching semantics.** Matching is performed against an activity's **reference product name** (`act["reference product"]`), and the activity's unit must equal the definition's `unit`. A pattern containing `*` acts as a **prefix wildcard** (`"steel*"` matches any reference product starting with `steel`); a pattern without `*` must be an **exact match**. `excludes` follows the same wildcard rules and overrides any `matchings` hit.
80
+
81
+ Then pass your file to the setup:
82
+
83
+ ```python
84
+ setup_lca_supply_mat(
85
+ target_db="ecoinvent-3.11-cutoff",
86
+ yaml_file="path/to/my_definitions.yaml")
87
+ ```
88
+
89
+ ## Example
90
+
91
+ See the [demo notebook](notebook.ipynb) for a complete, runnable example.
92
+
93
+ ## License
94
+
95
+ [MIT](LICENSE)
96
+
97
+ ## Authors
98
+
99
+ - [Raphaël JOLIVET](https://orcid.org/0000-0001-7149-5010)
100
+ - [Joanna SCHLESINGER-MARTINAT](https://orcid.org/0009-0006-0419-0990)
101
+
102
+ Organisation : [OIE | Mines Paris | PSL](https://ror.org/054fae424)
@@ -0,0 +1,102 @@
1
+ # lca_supplymat
2
+
3
+ A [Brightway](https://brightway.dev/) Life Cycle Impact Assessment (LCIA) method that computes the **amount of manufactured materials** (copper, concrete, steel, aluminium, …) directly from Life Cycle Inventory (LCI) data.
4
+
5
+ ## Intro
6
+
7
+ Impact indicators related to material depletion, criticality or circularity are notoriously complex to interpret. `lca-supplymat` exposes a simpler, physical metric: the **quantity of manufactured material** required by an inventory. Instead of weighing environmental impact, it counts how much of a given material (e.g. copper or steel) is embedded in the activities of a life cycle.
8
+
9
+ This library implements this as a standard Brightway LCIA method, so it benefits from the full range of Brightway functionalities (MultiLCA, Monte-Carlo, parameterization, etc.). For each material, a pseudo-biosphere flow is added to the activities that produce it, and the method computes the **net production** of the material — the difference between what an activity outputs and what it consumes of the same material upstream. This avoids double counting between the production and market stages. One LCIA method is registered per material.
10
+
11
+ The approach was tested with ecoinvent 3.11 (cutoff and attributional system models). It is comparable in spirit to the [Edges](https://github.com/romainsacchi/EDGES_CA) library, but implemented natively within the Brightway framework.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install lca_supplymat
17
+ ```
18
+
19
+ **Prerequisites** :
20
+ * A **Python>3.12** environement
21
+ * **Brightway 25** (will be installed if not found)
22
+ * A Brightway project with ecoinvent background database
23
+
24
+ ## Usage
25
+
26
+ ### Setup of the methods
27
+
28
+ ```python
29
+ from lca_supplymat import setup_lca_supply_mat, cleanup
30
+
31
+ setup_lca_supply_mat(
32
+ target_db="ecoinvent-3.11-cutoff",
33
+ yaml_file="path.yaml", # optionnal: load 23 definition from the package by default
34
+ subset=["concrete"], # optional: install only these definitions
35
+ out_folder="data/out", # optional: write a CSV report per material
36
+ check_impacts=True, # optional: verify impact scores are ~1
37
+ cleanup_before=True, # optional: reset existing material methods first
38
+ )
39
+ ```
40
+
41
+ What it does:
42
+
43
+ - creates a dedicated Brightway database `lca_supplymat` holding the pseudo-biosphere "counting" flows;
44
+ - computes the net production of each requested material for every matching activity and adds the corresponding exchanges;
45
+ - registers one Brightway `Method` per material, keyed as `("lca_supplymat", "total", "<material>")`.
46
+
47
+ Once the setup is done, you can use the new methods as regular LCIA methods in Brightway / Activity Browser.
48
+
49
+ To tear the material methods down again:
50
+
51
+ ```python
52
+ cleanup("ecoinvent-3.11-cutoff")
53
+ ```
54
+
55
+ ## Material definitions
56
+
57
+ By default, the 23 definitions of material methods are installed :
58
+ See [materials_methods.yaml](https://git.sophia.minesparis.psl.eu/oie/acv/lca-supplymat/-/blob/main/lca_supplymat/res/materials_methods.yaml)
59
+
60
+ ## Writing your own definitions
61
+
62
+ You can provide your own definitions by passing the `yaml_file` parameter.
63
+
64
+ The file maps a definition key to a set of matching rules:
65
+
66
+ ```yaml
67
+ copper:
68
+ matchings: ["copper, cathode*", "copper, anode*"]
69
+ excludes: ["*scrap*"] # optional: patterns that veto a match
70
+ unit: kilogram
71
+ tolerance: 0.05 # optional: allowed deviation for the impact check (default 0.05)
72
+ ```
73
+
74
+ - **`matchings`** (required): a list of patterns used to select activities.
75
+ - **`excludes`** (optional): a list of patterns; if any matches, the activity is rejected.
76
+ - **`unit`** (required): the unit the matching activities must be in.
77
+ - **`tolerance`** (optional): allowed deviation of the impact score from 1 during the `check_impacts` step (default `0.05`).
78
+
79
+ **Matching semantics.** Matching is performed against an activity's **reference product name** (`act["reference product"]`), and the activity's unit must equal the definition's `unit`. A pattern containing `*` acts as a **prefix wildcard** (`"steel*"` matches any reference product starting with `steel`); a pattern without `*` must be an **exact match**. `excludes` follows the same wildcard rules and overrides any `matchings` hit.
80
+
81
+ Then pass your file to the setup:
82
+
83
+ ```python
84
+ setup_lca_supply_mat(
85
+ target_db="ecoinvent-3.11-cutoff",
86
+ yaml_file="path/to/my_definitions.yaml")
87
+ ```
88
+
89
+ ## Example
90
+
91
+ See the [demo notebook](https://git.sophia.minesparis.psl.eu/oie/acv/lca-supplymat/-/blob/main/notebook.ipynb) for a complete, runnable example.
92
+
93
+ ## License
94
+
95
+ [MIT](https://git.sophia.minesparis.psl.eu/oie/acv/lca-supplymat/-/blob/main/LICENSE)
96
+
97
+ ## Authors
98
+
99
+ - [Raphaël JOLIVET](https://orcid.org/0000-0001-7149-5010)
100
+ - [Joanna SCHLESINGER-MARTINAT](https://orcid.org/0009-0006-0419-0990)
101
+
102
+ Organisation : [OIE | Mines Paris | PSL](https://ror.org/054fae424)
@@ -0,0 +1,2 @@
1
+ from .main import setup_lca_supply_mat, cleanup, list_methods_available_methods
2
+ from .settings import *