dynamic-characterization 1.4.0__tar.gz → 1.4.1__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.
- {dynamic_characterization-1.4.0/dynamic_characterization.egg-info → dynamic_characterization-1.4.1}/PKG-INFO +1 -1
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/__init__.py +1 -1
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/dynamic_characterization.py +20 -15
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1/dynamic_characterization.egg-info}/PKG-INFO +1 -1
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization.egg-info/SOURCES.txt +1 -0
- dynamic_characterization-1.4.1/tests/test_default_characterization_functions.py +210 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/LICENSE +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/MANIFEST.in +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/README.md +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/classes.py +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/ipcc_ar6/__init__.py +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/ipcc_ar6/data/decay_multipliers.json +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/ipcc_ar6/data/hodnebrog20.csv +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/ipcc_ar6/radiative_forcing.py +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/original_temporalis_functions/__init__.py +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/original_temporalis_functions/radiative_forcing.py +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/__init__.py +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/agtp.py +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/agwp.py +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/config.py +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_001.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_002.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_003.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_004.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_009.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_010.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_011.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_012.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_013.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_014.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_015.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_016.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_017.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_018.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_019.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_020.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_021.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_022.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_023.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_024.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_025.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data/es5c12391_si_026.xlsx +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/data_loader.py +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization/prospective/radiative_forcing.py +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization.egg-info/dependency_links.txt +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization.egg-info/requires.txt +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/dynamic_characterization.egg-info/top_level.txt +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/pyproject.toml +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/setup.cfg +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/tests/test_characterize_dynamic_inventory.py +0 -0
- {dynamic_characterization-1.4.0 → dynamic_characterization-1.4.1}/tests/test_prospective.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dynamic_characterization
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: Collection of functions for characterizing life cycle inventories with temporal information
|
|
5
5
|
Author-email: Timo Diepers <timo.diepers@ltt.rwth-aachen.de>
|
|
6
6
|
Maintainer-email: Timo Diepers <timo.diepers@ltt.rwth-aachen.de>
|
|
@@ -457,21 +457,26 @@ def create_characterization_functions_from_method(
|
|
|
457
457
|
|
|
458
458
|
for node in bioflow_nodes:
|
|
459
459
|
if "carbon dioxide" in node["name"].lower():
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
460
|
+
categories = node.get("categories") or ()
|
|
461
|
+
# uptake by soil, i.e. CO2 leaving the technosphere towards the soil compartment.
|
|
462
|
+
# Only the categories are checked, so that emissions to air from flows like
|
|
463
|
+
# "Carbon dioxide, from soil or biomass stock" are not misread as uptake.
|
|
464
|
+
is_soil_uptake = "soil" in categories
|
|
465
|
+
# CO2 as a natural resource in air is assumed to be used for uptake in biomass
|
|
466
|
+
# or CDR processes
|
|
467
|
+
is_uptake_resource = (
|
|
468
|
+
"in air" in categories and node.get("type") == "natural resource"
|
|
469
|
+
)
|
|
470
|
+
|
|
471
|
+
if is_soil_uptake or is_uptake_resource:
|
|
472
|
+
if characterize_uptake:
|
|
473
|
+
characterization_functions[node.id] = (
|
|
474
|
+
co2_uptake_func # negative emission because of uptake
|
|
475
|
+
)
|
|
476
|
+
# else: uptake is modelled outside of the dynamic characterization,
|
|
477
|
+
# so these flows are intentionally left uncharacterized
|
|
478
|
+
else:
|
|
479
|
+
# all remaining CO2 flows are emissions, regardless of the air subcategory
|
|
475
480
|
characterization_functions[node.id] = co2_func
|
|
476
481
|
|
|
477
482
|
elif (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dynamic_characterization
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: Collection of functions for characterizing life cycle inventories with temporal information
|
|
5
5
|
Author-email: Timo Diepers <timo.diepers@ltt.rwth-aachen.de>
|
|
6
6
|
Maintainer-email: Timo Diepers <timo.diepers@ltt.rwth-aachen.de>
|
|
@@ -82,4 +82,5 @@ dynamic_characterization/prospective/data/es5c12391_si_024.xlsx
|
|
|
82
82
|
dynamic_characterization/prospective/data/es5c12391_si_025.xlsx
|
|
83
83
|
dynamic_characterization/prospective/data/es5c12391_si_026.xlsx
|
|
84
84
|
tests/test_characterize_dynamic_inventory.py
|
|
85
|
+
tests/test_default_characterization_functions.py
|
|
85
86
|
tests/test_prospective.py
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"""Tests for the default characterization functions built from a static LCIA method."""
|
|
2
|
+
|
|
3
|
+
import bw2data as bd
|
|
4
|
+
import numpy as np
|
|
5
|
+
import pandas as pd
|
|
6
|
+
import pytest
|
|
7
|
+
from bw2data.tests import bw2test
|
|
8
|
+
|
|
9
|
+
from dynamic_characterization import characterize
|
|
10
|
+
from dynamic_characterization.dynamic_characterization import (
|
|
11
|
+
clear_characterization_function_cache,
|
|
12
|
+
create_characterization_functions_from_method,
|
|
13
|
+
)
|
|
14
|
+
from dynamic_characterization.ipcc_ar6.radiative_forcing import (
|
|
15
|
+
characterize_ch4,
|
|
16
|
+
characterize_co2,
|
|
17
|
+
characterize_co2_uptake,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
METHOD = ("test", "climate change", "GWP100")
|
|
21
|
+
|
|
22
|
+
BIOFLOWS = {
|
|
23
|
+
"co2_fossil_high_stacks": {
|
|
24
|
+
"name": "Carbon dioxide, fossil",
|
|
25
|
+
"categories": ("air", "non-urban air or from high stacks"),
|
|
26
|
+
"type": "emission",
|
|
27
|
+
"CAS number": "000124-38-9",
|
|
28
|
+
},
|
|
29
|
+
"co2_fossil_unspecified": {
|
|
30
|
+
"name": "Carbon dioxide, fossil",
|
|
31
|
+
"categories": ("air",),
|
|
32
|
+
"type": "emission",
|
|
33
|
+
"CAS number": "000124-38-9",
|
|
34
|
+
},
|
|
35
|
+
"co2_fossil_urban": {
|
|
36
|
+
"name": "Carbon dioxide, fossil",
|
|
37
|
+
"categories": ("air", "urban air close to ground"),
|
|
38
|
+
"type": "emission",
|
|
39
|
+
"CAS number": "000124-38-9",
|
|
40
|
+
},
|
|
41
|
+
"co2_fossil_stratosphere": {
|
|
42
|
+
"name": "Carbon dioxide, fossil",
|
|
43
|
+
"categories": ("air", "lower stratosphere + upper troposphere"),
|
|
44
|
+
"type": "emission",
|
|
45
|
+
"CAS number": "000124-38-9",
|
|
46
|
+
},
|
|
47
|
+
"co2_non_fossil": {
|
|
48
|
+
"name": "Carbon dioxide, non-fossil",
|
|
49
|
+
"categories": ("air", "non-urban air or from high stacks"),
|
|
50
|
+
"type": "emission",
|
|
51
|
+
"CAS number": "000124-38-9",
|
|
52
|
+
},
|
|
53
|
+
"co2_from_soil_or_biomass_stock": {
|
|
54
|
+
"name": "Carbon dioxide, from soil or biomass stock",
|
|
55
|
+
"categories": ("air",),
|
|
56
|
+
"type": "emission",
|
|
57
|
+
"CAS number": "000124-38-9",
|
|
58
|
+
},
|
|
59
|
+
"co2_to_soil": {
|
|
60
|
+
"name": "Carbon dioxide, to soil or biomass stock",
|
|
61
|
+
"categories": ("soil",),
|
|
62
|
+
"type": "emission",
|
|
63
|
+
"CAS number": "000124-38-9",
|
|
64
|
+
},
|
|
65
|
+
"co2_in_air": {
|
|
66
|
+
"name": "Carbon dioxide, in air",
|
|
67
|
+
"categories": ("natural resource", "in air"),
|
|
68
|
+
"type": "natural resource",
|
|
69
|
+
"CAS number": "000124-38-9",
|
|
70
|
+
},
|
|
71
|
+
"ch4_fossil": {
|
|
72
|
+
"name": "Methane, fossil",
|
|
73
|
+
"categories": ("air", "non-urban air or from high stacks"),
|
|
74
|
+
"type": "emission",
|
|
75
|
+
"CAS number": "000074-82-8",
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# static CFs, roughly EF v3.1 GWP100; uptake flows are negative
|
|
80
|
+
CHARACTERIZATION_FACTORS = {
|
|
81
|
+
"co2_fossil_high_stacks": 1.0,
|
|
82
|
+
"co2_fossil_unspecified": 1.0,
|
|
83
|
+
"co2_fossil_urban": 1.0,
|
|
84
|
+
"co2_fossil_stratosphere": 1.0,
|
|
85
|
+
"co2_non_fossil": 1.0,
|
|
86
|
+
"co2_from_soil_or_biomass_stock": 1.0,
|
|
87
|
+
"co2_to_soil": -1.0,
|
|
88
|
+
"co2_in_air": -1.0,
|
|
89
|
+
"ch4_fossil": 29.8,
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def setup_project():
|
|
94
|
+
"""Write a minimal biosphere database and static method into the current project."""
|
|
95
|
+
clear_characterization_function_cache()
|
|
96
|
+
biosphere = bd.Database(bd.config.biosphere)
|
|
97
|
+
biosphere.write(
|
|
98
|
+
{
|
|
99
|
+
(bd.config.biosphere, code): data | {"code": code}
|
|
100
|
+
for code, data in BIOFLOWS.items()
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
bd.Method(METHOD).write(
|
|
104
|
+
[
|
|
105
|
+
((bd.config.biosphere, code), factor)
|
|
106
|
+
for code, factor in CHARACTERIZATION_FACTORS.items()
|
|
107
|
+
]
|
|
108
|
+
)
|
|
109
|
+
return {code: biosphere.get(code).id for code in BIOFLOWS}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
@pytest.mark.parametrize(
|
|
113
|
+
"code",
|
|
114
|
+
[
|
|
115
|
+
"co2_fossil_high_stacks",
|
|
116
|
+
"co2_fossil_unspecified",
|
|
117
|
+
"co2_fossil_urban",
|
|
118
|
+
"co2_fossil_stratosphere",
|
|
119
|
+
"co2_non_fossil",
|
|
120
|
+
"co2_from_soil_or_biomass_stock",
|
|
121
|
+
],
|
|
122
|
+
)
|
|
123
|
+
@bw2test
|
|
124
|
+
def test_co2_emission_flows_get_co2_function(code):
|
|
125
|
+
ids = setup_project()
|
|
126
|
+
functions = create_characterization_functions_from_method(METHOD)
|
|
127
|
+
assert functions[ids[code]] is characterize_co2
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
@bw2test
|
|
131
|
+
def test_co2_emission_flows_characterized_without_uptake():
|
|
132
|
+
"""Disabling uptake must not drop the ordinary CO2 emission flows."""
|
|
133
|
+
ids = setup_project()
|
|
134
|
+
functions = create_characterization_functions_from_method(
|
|
135
|
+
METHOD, characterize_uptake=False
|
|
136
|
+
)
|
|
137
|
+
assert functions[ids["co2_fossil_high_stacks"]] is characterize_co2
|
|
138
|
+
assert functions[ids["co2_from_soil_or_biomass_stock"]] is characterize_co2
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
@bw2test
|
|
142
|
+
def test_uptake_flows_use_uptake_function():
|
|
143
|
+
ids = setup_project()
|
|
144
|
+
functions = create_characterization_functions_from_method(METHOD)
|
|
145
|
+
assert functions[ids["co2_in_air"]] is characterize_co2_uptake
|
|
146
|
+
assert functions[ids["co2_to_soil"]] is characterize_co2_uptake
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@bw2test
|
|
150
|
+
def test_uptake_flows_absent_when_uptake_disabled():
|
|
151
|
+
ids = setup_project()
|
|
152
|
+
functions = create_characterization_functions_from_method(
|
|
153
|
+
METHOD, characterize_uptake=False
|
|
154
|
+
)
|
|
155
|
+
assert ids["co2_in_air"] not in functions
|
|
156
|
+
assert ids["co2_to_soil"] not in functions
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
@bw2test
|
|
160
|
+
def test_all_method_flows_are_characterized():
|
|
161
|
+
ids = setup_project()
|
|
162
|
+
functions = create_characterization_functions_from_method(METHOD)
|
|
163
|
+
assert set(functions) == set(ids.values())
|
|
164
|
+
assert functions[ids["ch4_fossil"]] is characterize_ch4
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
@bw2test
|
|
168
|
+
def test_dynamic_gwp100_matches_static_score():
|
|
169
|
+
"""
|
|
170
|
+
End-to-end: with fixed_time_horizon=False, dynamic GWP100 of an inventory
|
|
171
|
+
must match the static GWP100 score of the same inventory within a few percent.
|
|
172
|
+
"""
|
|
173
|
+
ids = setup_project()
|
|
174
|
+
|
|
175
|
+
amounts = {
|
|
176
|
+
"co2_fossil_high_stacks": 17864.7,
|
|
177
|
+
"co2_fossil_unspecified": 2322.3,
|
|
178
|
+
"co2_fossil_urban": 1287.9,
|
|
179
|
+
"co2_fossil_stratosphere": 1.9,
|
|
180
|
+
"co2_from_soil_or_biomass_stock": 24.7,
|
|
181
|
+
"co2_non_fossil": 100.0,
|
|
182
|
+
"co2_to_soil": 50.0,
|
|
183
|
+
"co2_in_air": 200.0,
|
|
184
|
+
"ch4_fossil": 30.0,
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
dynamic_inventory_df = pd.DataFrame(
|
|
188
|
+
{
|
|
189
|
+
"date": pd.Series(
|
|
190
|
+
["2024-01-01"] * len(amounts), dtype="datetime64[s]"
|
|
191
|
+
),
|
|
192
|
+
"amount": pd.Series(list(amounts.values()), dtype="float64"),
|
|
193
|
+
"flow": pd.Series([ids[code] for code in amounts], dtype="int"),
|
|
194
|
+
"activity": pd.Series([1] * len(amounts), dtype="int"),
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
static_score = sum(
|
|
199
|
+
amount * CHARACTERIZATION_FACTORS[code] for code, amount in amounts.items()
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
characterized = characterize(
|
|
203
|
+
dynamic_inventory_df,
|
|
204
|
+
metric="GWP",
|
|
205
|
+
base_lcia_method=METHOD,
|
|
206
|
+
time_horizon=100,
|
|
207
|
+
fixed_time_horizon=False,
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
assert np.isclose(characterized.amount.sum(), static_score, rtol=0.05)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|