edges 1.0.2__py3-none-any.whl → 1.0.3__py3-none-any.whl
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.
Potentially problematic release.
This version of edges might be problematic. Click here for more details.
- edges/__init__.py +9 -2
- edges/data/AWARE 2.0_Country_all_yearly.json +8 -1
- edges/data/AWARE 2.0_Country_irri_yearly.json +8 -1
- edges/data/AWARE 2.0_Country_non_irri_yearly.json +8 -1
- edges/data/AWARE 2.0_Country_unspecified_yearly.json +8 -1
- edges/data/GeoPolRisk_paired_2024.json +7 -0
- edges/data/ImpactWorld+ 2.1_Freshwater acidification_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Freshwater acidification_midpoint.json +8 -1
- edges/data/ImpactWorld+ 2.1_Freshwater ecotoxicity, long term_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Freshwater ecotoxicity, short term_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Freshwater ecotoxicity_midpoint.json +8 -1
- edges/data/ImpactWorld+ 2.1_Freshwater eutrophication_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Freshwater eutrophication_midpoint.json +8 -1
- edges/data/ImpactWorld+ 2.1_Land occupation, biodiversity_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Land occupation, biodiversity_midpoint.json +8 -1
- edges/data/ImpactWorld+ 2.1_Land transformation, biodiversity_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Land transformation, biodiversity_midpoint.json +8 -1
- edges/data/ImpactWorld+ 2.1_Marine ecotoxicity, long term_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Marine ecotoxicity, short term_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Marine eutrophication_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Marine eutrophication_midpoint.json +8 -1
- edges/data/ImpactWorld+ 2.1_Particulate matter formation_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Particulate matter formation_midpoint.json +8 -1
- edges/data/ImpactWorld+ 2.1_Photochemical ozone formation, ecosystem quality_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Photochemical ozone formation, human health_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Photochemical ozone formation_midpoint.json +8 -1
- edges/data/ImpactWorld+ 2.1_Terrestrial acidification_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Terrestrial acidification_midpoint.json +8 -1
- edges/data/ImpactWorld+ 2.1_Terrestrial ecotoxicity, long term_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Terrestrial ecotoxicity, short term_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Thermally polluted water_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Water availability, freshwater ecosystem_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Water availability, human health_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Water availability, terrestrial ecosystem_damage.json +8 -1
- edges/data/ImpactWorld+ 2.1_Water scarcity_midpoint.json +8 -1
- edges/data/LCC 1.0_2023.json +8 -1
- edges/data/RELICS_copper_primary.json +44 -0
- edges/data/RELICS_copper_secondary.json +42 -0
- edges/data/SCP_1.0.json +4 -1
- edges/edgelcia.py +2113 -816
- edges/flow_matching.py +344 -130
- edges/georesolver.py +61 -2
- edges/supply_chain.py +2052 -0
- edges/uncertainty.py +37 -8
- {edges-1.0.2.dist-info → edges-1.0.3.dist-info}/METADATA +5 -2
- edges-1.0.3.dist-info/RECORD +57 -0
- edges/data/GeoPolRisk_elementary flows_2024.json +0 -877
- edges/data/ImpactWorld+ 2.1_Freshwater ecotoxicity, long term_midpoint.json +0 -5
- edges/data/ImpactWorld+ 2.1_Freshwater ecotoxicity, short term_midpoint.json +0 -5
- edges/data/ImpactWorld+ 2.1_Freshwater ecotoxicity_damage.json +0 -0
- edges/data/ImpactWorld+ 2.1_Marine ecotoxicity, long term_midpoint.json +0 -5
- edges/data/ImpactWorld+ 2.1_Marine ecotoxicity, short term_midpoint.json +0 -5
- edges/data/ImpactWorld+ 2.1_Photochemical ozone formation, ecosystem quality_midpoint.json +0 -5
- edges/data/ImpactWorld+ 2.1_Photochemical ozone formation, human health_midpoint.json +0 -5
- edges/data/ImpactWorld+ 2.1_Photochemical ozone formation_damage.json +0 -5
- edges/data/ImpactWorld+ 2.1_Terrestrial ecotoxicity, long term_midpoint.json +0 -5
- edges/data/ImpactWorld+ 2.1_Terrestrial ecotoxicity, short term_midpoint.json +0 -5
- edges/data/ImpactWorld+ 2.1_Thermally polluted water_midpoint.json +0 -5
- edges/data/ImpactWorld+ 2.1_Water availability, freshwater ecosystem_midpoint.json +0 -5
- edges/data/ImpactWorld+ 2.1_Water availability, human health_midpoint.json +0 -5
- edges/data/ImpactWorld+ 2.1_Water availability, terrestrial ecosystem_midpoint.json +0 -5
- edges/data/ImpactWorld+ 2.1_Water scarcity_damage.json +0 -5
- edges/data/RELICS_copper.json +0 -22
- edges-1.0.2.dist-info/RECORD +0 -71
- {edges-1.0.2.dist-info → edges-1.0.3.dist-info}/WHEEL +0 -0
- {edges-1.0.2.dist-info → edges-1.0.3.dist-info}/top_level.txt +0 -0
edges/uncertainty.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
Utilities for uncertainty handling: RNG derivation, cache keys, canonicalization,
|
|
3
|
+
and sampling of characterization-factor (CF) uncertainty distributions.
|
|
3
4
|
"""
|
|
4
5
|
|
|
5
6
|
import numpy as np
|
|
@@ -17,6 +18,13 @@ logger.addHandler(logging.NullHandler())
|
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
def get_rng_for_key(key: str, base_seed: int) -> np.random.Generator:
|
|
21
|
+
"""
|
|
22
|
+
Derive a reproducible RNG from a base seed and a string key.
|
|
23
|
+
|
|
24
|
+
:param key: Arbitrary identifier (e.g., CF uncertainty fingerprint).
|
|
25
|
+
:param base_seed: Base integer seed.
|
|
26
|
+
:return: Numpy random.Generator instance initialized from derived seed.
|
|
27
|
+
"""
|
|
20
28
|
key_digest = int(hashlib.sha256(key.encode()).hexdigest(), 16) % (2**32)
|
|
21
29
|
seed = base_seed + key_digest
|
|
22
30
|
logger.debug("Creating RNG with derived seed %d for key %s", seed, key)
|
|
@@ -24,7 +32,12 @@ def get_rng_for_key(key: str, base_seed: int) -> np.random.Generator:
|
|
|
24
32
|
|
|
25
33
|
|
|
26
34
|
def make_distribution_key(cf):
|
|
27
|
-
"""
|
|
35
|
+
"""
|
|
36
|
+
Generate a stable, hashable cache key for a CF's uncertainty block.
|
|
37
|
+
|
|
38
|
+
:param cf: CF dictionary potentially containing an 'uncertainty' entry.
|
|
39
|
+
:return: JSON string key without 'negative' flag, or None if no uncertainty.
|
|
40
|
+
"""
|
|
28
41
|
unc = cf.get("uncertainty")
|
|
29
42
|
if unc:
|
|
30
43
|
unc_copy = dict(unc) # shallow copy
|
|
@@ -38,10 +51,14 @@ def make_distribution_key(cf):
|
|
|
38
51
|
|
|
39
52
|
def _canon_atom(item):
|
|
40
53
|
"""
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
Canonicalize a mixture atom and return its fingerprint.
|
|
55
|
+
|
|
56
|
+
- If ``item`` is a distribution dict, remove 'negative'; for
|
|
57
|
+
``discrete_empirical`` recursively canonicalize children and merge duplicates.
|
|
58
|
+
- If scalar or expression string, return as-is.
|
|
59
|
+
|
|
60
|
+
:param item: Scalar, expression string, or distribution dict.
|
|
61
|
+
:return: Tuple (canonical_object, fingerprint_string).
|
|
45
62
|
"""
|
|
46
63
|
if isinstance(item, dict) and "distribution" in item:
|
|
47
64
|
clean = deepcopy(item)
|
|
@@ -92,8 +109,20 @@ def sample_cf_distribution(
|
|
|
92
109
|
SAFE_GLOBALS: dict = None,
|
|
93
110
|
) -> np.ndarray:
|
|
94
111
|
"""
|
|
95
|
-
|
|
96
|
-
|
|
112
|
+
Draw samples from the CF's uncertainty distribution (or constant fallback).
|
|
113
|
+
|
|
114
|
+
If no uncertainty or distributions are disabled, returns a length-``n`` array
|
|
115
|
+
filled with the (possibly evaluated) deterministic CF value.
|
|
116
|
+
|
|
117
|
+
:param cf: CF dictionary with 'value' and optional 'uncertainty' specification.
|
|
118
|
+
:param n: Number of samples to generate.
|
|
119
|
+
:param parameters: Parameter dict for evaluating expression atoms.
|
|
120
|
+
:param random_state: RNG to use for sampling.
|
|
121
|
+
:param use_distributions: If False, bypass uncertainty and return constants.
|
|
122
|
+
:param SAFE_GLOBALS: Safe globals for expression evaluation.
|
|
123
|
+
:return: NumPy array of shape (n,) with sampled CF values.
|
|
124
|
+
|
|
125
|
+
:raises ValueError: If sampling fails due to invalid distribution parameters.
|
|
97
126
|
"""
|
|
98
127
|
if not use_distributions or cf.get("uncertainty") is None:
|
|
99
128
|
# If value is a string (expression), evaluate once
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edges
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Country-specific characterization factors for the Brightway LCA framework
|
|
5
5
|
Author-email: Romain Sacchi <romain.sacchi@psi.ch>, Alvaro Hahn Menacho <alvaro.hahn-menacho@psi.ch>
|
|
6
6
|
Maintainer-email: Romain Sacchi <romain.sacchi@psi.ch>
|
|
@@ -23,10 +23,13 @@ Requires-Dist: bw2calc
|
|
|
23
23
|
Requires-Dist: bw2data
|
|
24
24
|
Requires-Dist: bw2io
|
|
25
25
|
Requires-Dist: bw2analyzer
|
|
26
|
-
Requires-Dist:
|
|
26
|
+
Requires-Dist: country_converter>=1.3.1
|
|
27
|
+
Requires-Dist: constructive_geometries>=1.0.0
|
|
27
28
|
Requires-Dist: prettytable
|
|
28
29
|
Requires-Dist: sparse>=0.13.0
|
|
29
30
|
Requires-Dist: highspy
|
|
31
|
+
Requires-Dist: plotly
|
|
32
|
+
Requires-Dist: ecoinvent_interface
|
|
30
33
|
Provides-Extra: testing
|
|
31
34
|
Requires-Dist: setuptools; extra == "testing"
|
|
32
35
|
Requires-Dist: pytest; extra == "testing"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
edges/__init__.py,sha256=2TkmZVz-J7rouzuC4OY8pyh3W8u_B3f4wyUqBaWlyso,499
|
|
2
|
+
edges/analysis.py,sha256=FkJzqFkormYOzhEP5p7YGsmxwN66JdMfktokGRUKjKI,7388
|
|
3
|
+
edges/costs.py,sha256=OV46FS627fw6BikbRvtWWdXRvt4oRl8zsA9-Z8bdOkU,23399
|
|
4
|
+
edges/edgelcia.py,sha256=qay_QO7plyxk14zzwUAj45WMCC4SFdqtmwUr3QUBMeU,162598
|
|
5
|
+
edges/filesystem_constants.py,sha256=FSH8hW84V1MCMvo8UOeZKM5Up26ls6bLbTRvfMl2tAg,207
|
|
6
|
+
edges/flow_matching.py,sha256=_dBQ9X4D1u_x1KttXmZkK8pXOlicmUMyDAoOOt6G7tw,35858
|
|
7
|
+
edges/georesolver.py,sha256=fe_8hNgUsUfBgUP2SCfUPrRifhCJ4Vyth1K8gWFSI1Q,5770
|
|
8
|
+
edges/logging_config.py,sha256=zZLxKsh7on0v9HaGBp45ynqTrEuDa3wPgMvTognoum0,1231
|
|
9
|
+
edges/matrix_builders.py,sha256=vXl80pKfIeXWkYkTJsD4c8aVrFexWncqwl1saA0gRCM,1800
|
|
10
|
+
edges/supply_chain.py,sha256=uzcPg0Oo0DxgIphTQAsOOVUTNwTsHIqTFjjPGDLxlmY,71690
|
|
11
|
+
edges/uncertainty.py,sha256=mAYu4Jxxp1wQ2SRTav3_PTb-Z0yxXUYi5XagTCJfw1k,8882
|
|
12
|
+
edges/utils.py,sha256=boVrCOeq4RZjbQ8u-xPMPdiE3uYwXBVfLqRO6NuYkBI,14868
|
|
13
|
+
edges/data/AWARE 2.0_Country_all_yearly.json,sha256=GUk5iuqTey6ldT4dsaeQxxrmPKf3y9wA78e4cvRedsQ,13187711
|
|
14
|
+
edges/data/AWARE 2.0_Country_irri_yearly.json,sha256=nyphUBxJwokmD1KIEHwCun29pAMFiMDXbuAKxmnvcNE,3068388
|
|
15
|
+
edges/data/AWARE 2.0_Country_non_irri_yearly.json,sha256=aObCM8De_XKYB4V_vD3VMSbZuiX29t3QFWCFXq4LGFs,4503080
|
|
16
|
+
edges/data/AWARE 2.0_Country_unspecified_yearly.json,sha256=MniR1UWaiFTpR8u7zeKimCdpLvAUGB0iclICSsg0BGA,3806405
|
|
17
|
+
edges/data/GeoPolRisk_paired_2024.json,sha256=MQbN4gr--LBNc30gjAltl3ybKodUZgVKauhP2j6ELws,21543080
|
|
18
|
+
edges/data/ImpactWorld+ 2.1_Freshwater acidification_damage.json,sha256=Ywvgmadc2jnFOEc4BrI9R-PTRcaJbelb0r2q2qjQR5c,7347676
|
|
19
|
+
edges/data/ImpactWorld+ 2.1_Freshwater acidification_midpoint.json,sha256=YmAdsMst0ewBCEgJlfz-Ruue3Zf06AZCl0o4MbG-Fxc,7363074
|
|
20
|
+
"edges/data/ImpactWorld+ 2.1_Freshwater ecotoxicity, long term_damage.json",sha256=PmOJacNlhO6P_5YxukIBRqMFQIRtI0nNxWZDjN4BBco,76643
|
|
21
|
+
"edges/data/ImpactWorld+ 2.1_Freshwater ecotoxicity, short term_damage.json",sha256=qg3K1q6QCbvOfwWrPCHV4NfxaXPTHZzQoXpVrxBVQAI,779650
|
|
22
|
+
edges/data/ImpactWorld+ 2.1_Freshwater ecotoxicity_midpoint.json,sha256=jyBBLCRQiNRRhKiGozrqdmm8nBK81axfcBim3uK4u9Q,815678
|
|
23
|
+
edges/data/ImpactWorld+ 2.1_Freshwater eutrophication_damage.json,sha256=fFEFoJyRVFRWH0NmZJEfgIi26oVomzMKzieUkVFspkc,1064016
|
|
24
|
+
edges/data/ImpactWorld+ 2.1_Freshwater eutrophication_midpoint.json,sha256=Hs9S5AoAiyzaHiTa9iPNZxlmjQGooJaILsrlqjVt9Cg,1065652
|
|
25
|
+
"edges/data/ImpactWorld+ 2.1_Land occupation, biodiversity_damage.json",sha256=zDhegsaCbMN7lyrNf1FHnKXhxro6zXfMNtNMZxuHmwc,3495866
|
|
26
|
+
"edges/data/ImpactWorld+ 2.1_Land occupation, biodiversity_midpoint.json",sha256=e_5s265gxPHXhYV9HE0oiTZSRwhIJ5pnPSg203spjuU,3532271
|
|
27
|
+
"edges/data/ImpactWorld+ 2.1_Land transformation, biodiversity_damage.json",sha256=Ldezmpp15IL9G0gS1dTE6E-tTRmMgUbzaTfSFp-0xSE,7396774
|
|
28
|
+
"edges/data/ImpactWorld+ 2.1_Land transformation, biodiversity_midpoint.json",sha256=TTHFupTp9j6X5tVrbb7HbOLncFeWF8w27FE2gbGlMCE,7398060
|
|
29
|
+
"edges/data/ImpactWorld+ 2.1_Marine ecotoxicity, long term_damage.json",sha256=0vxy2w7qU2oYHxJU2hAzo6NTeFAaUC_hL6gBghyndRk,77107
|
|
30
|
+
"edges/data/ImpactWorld+ 2.1_Marine ecotoxicity, short term_damage.json",sha256=U3yJNzZXWT5dS5MOc5okU7BtV_gdfb9eJjABEDgRoSE,503498
|
|
31
|
+
edges/data/ImpactWorld+ 2.1_Marine eutrophication_damage.json,sha256=ZL5mnqT735QYU9gr_iPv1NYWYflhEEBw8HsfS0bDNbs,3239319
|
|
32
|
+
edges/data/ImpactWorld+ 2.1_Marine eutrophication_midpoint.json,sha256=7YnEvbrGNdoErKsZlmhOn2d1fn-Rtk1eKpe8gmMMons,3255717
|
|
33
|
+
edges/data/ImpactWorld+ 2.1_Particulate matter formation_damage.json,sha256=7RsI7WAn3KA7lAzE9loRt4ccYmAJdEZ9y1d8xbp5cvE,4789093
|
|
34
|
+
edges/data/ImpactWorld+ 2.1_Particulate matter formation_midpoint.json,sha256=gOfwulmqGohE-hdHtc9liNBLoHbO8qeShSD-MnqndgA,4751910
|
|
35
|
+
"edges/data/ImpactWorld+ 2.1_Photochemical ozone formation, ecosystem quality_damage.json",sha256=rVyntaoX_YWrAqBBceCfGR5tPslTFeaTgHiC8miCnjY,1605778
|
|
36
|
+
"edges/data/ImpactWorld+ 2.1_Photochemical ozone formation, human health_damage.json",sha256=SzYS0IKPbu1_-Qi5PwQqqicAjICF7f1Z_ii0om-_oVU,1561128
|
|
37
|
+
edges/data/ImpactWorld+ 2.1_Photochemical ozone formation_midpoint.json,sha256=XmdKthzjkzhX5LzhKKywOXCE-7opXR8LR7dyNFT32C0,1536243
|
|
38
|
+
edges/data/ImpactWorld+ 2.1_Terrestrial acidification_damage.json,sha256=34WlRAprwyh-6_zA6k5f1SCjufvhzclggoaeNQsta4E,6915100
|
|
39
|
+
edges/data/ImpactWorld+ 2.1_Terrestrial acidification_midpoint.json,sha256=pogNwb8AxKA6kU0UMRqX501bBaUmn3k0sioUTV5TTNc,6934476
|
|
40
|
+
"edges/data/ImpactWorld+ 2.1_Terrestrial ecotoxicity, long term_damage.json",sha256=u91iUVoTR_ZImVU9xfP7OzDaW6S4CS1A1NfYDH9FX1E,76176
|
|
41
|
+
"edges/data/ImpactWorld+ 2.1_Terrestrial ecotoxicity, short term_damage.json",sha256=PHFAAxli_Y6SoiIsqHScg3W-s4L-ymZLDrK9vUXRwGc,499759
|
|
42
|
+
edges/data/ImpactWorld+ 2.1_Thermally polluted water_damage.json,sha256=pBxi8kyEhtbW_ix33VYTpUbQR8KY8FIwbkV3ot1axy0,751297
|
|
43
|
+
"edges/data/ImpactWorld+ 2.1_Water availability, freshwater ecosystem_damage.json",sha256=yzHInvXwP5BzPX3vt1WJ8oOTU7-zLbBrpVRKFnU_Z5c,2583169
|
|
44
|
+
"edges/data/ImpactWorld+ 2.1_Water availability, human health_damage.json",sha256=2iEoZox2T39P7V03VWUK8Si_CEswktxxK-IOxttKCVE,1614840
|
|
45
|
+
"edges/data/ImpactWorld+ 2.1_Water availability, terrestrial ecosystem_damage.json",sha256=ckzYIQDlw75ncdxE9gPulSjas_GprADYCTjfztKoyBo,349788
|
|
46
|
+
edges/data/ImpactWorld+ 2.1_Water scarcity_midpoint.json,sha256=MT4emQvNct1H3siThXPaQJD5NPOl5WPFOaFQLATmAPQ,2541699
|
|
47
|
+
edges/data/LCC 1.0_2023.json,sha256=WzifNW7ZKvDOK7Q0zkkfpyw-j_sefvAuSNHTnLe1GGk,3124883
|
|
48
|
+
edges/data/RELICS_copper_primary.json,sha256=6CgXD18X0V77jtC3DvDFZuvKDO1_Wh6hAMoUe6KEtBE,880
|
|
49
|
+
edges/data/RELICS_copper_secondary.json,sha256=1an5CynzT8paqoV0ugVDJotv4PhkOh-_h8ZWJCUiCEA,860
|
|
50
|
+
edges/data/SCP_1.0.json,sha256=OCZK7W9OFciWIyXTi8i1oUD1WBvuxN4Btw9eFLjy_cQ,60137
|
|
51
|
+
edges/data/metadata/gdp.yaml,sha256=_I13ZlffUigydP74iGA6eTTNmZdup70KP1GiFQkxRDQ,5509
|
|
52
|
+
edges/data/metadata/missing_geographies.yaml,sha256=eTzO-I642ecG49_nn03fGPgWl-60VCYstWLjGk4h0i8,33
|
|
53
|
+
edges/data/metadata/population.yaml,sha256=BnNaYnx2SrfJLf1lf1-fKfG9JIilC95StgJiCu2so3I,4769
|
|
54
|
+
edges-1.0.3.dist-info/METADATA,sha256=fPSU1MiCHhmRZgwjtMiOURNokqojsKi17quNooaE3fk,10078
|
|
55
|
+
edges-1.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
56
|
+
edges-1.0.3.dist-info/top_level.txt,sha256=85BmdR7cFR5dfKfZ4mdJ4omGk9t4C89GE6N0RS3CCGA,6
|
|
57
|
+
edges-1.0.3.dist-info/RECORD,,
|