Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/mc' into mc
Browse files Browse the repository at this point in the history
# Conflicts:
#	pathways/lca.py
  • Loading branch information
romainsacchi authored and romainsacchi committed Jul 23, 2024
2 parents fb4560f + 4977266 commit 89b3518
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
10 changes: 6 additions & 4 deletions dev/timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@

p.calculate(
methods=[
'EF v3.1 EN15804 - climate change - global warming potential (GWP100)',
'EF v3.1 EN15804 - ecotoxicity: freshwater - comparative toxic unit for ecosystems (CTUe)',
"EF v3.1 EN15804 - climate change - global warming potential (GWP100)",
"EF v3.1 EN15804 - ecotoxicity: freshwater - comparative toxic unit for ecosystems (CTUe)",
],
regions=[
"CH",
],
regions=["CH",],
scenarios=p.scenarios.pathway.values.tolist(),
years=[
2050,
],
variables=[v for v in p.scenarios.coords["variables"].values if v.startswith("FE")],
use_distributions=20,
subshares=True,
multiprocessing=False
multiprocessing=False,
)
4 changes: 3 additions & 1 deletion pathways/pathways.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ def calculate(
results.update(
{
(model, scenario, year): result
for year, result in zip(years, p.map(_calculate_year, args))
for year, result in zip(
years, p.map(_calculate_year, args)
)
}
)
else:
Expand Down
12 changes: 9 additions & 3 deletions pathways/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
import pandas as pd
import statsmodels.api as sm
from openpyxl import load_workbook, Workbook
from openpyxl import Workbook, load_workbook
from SALib.analyze import delta


Expand Down Expand Up @@ -313,8 +313,14 @@ def run_GSA_OLS(methods: list, export_path: Path):
X_base = data.drop(columns=["Iteration", "Year"] + methods)
X_base = sm.add_constant(X_base)
corr_matrix = X_base.corr().abs()
upper_triangle = corr_matrix.where(np.triu(np.ones(corr_matrix.shape), k=1).astype(bool))
high_correlation = [column for column in upper_triangle.columns if any(upper_triangle[column] > 0.95)]
upper_triangle = corr_matrix.where(
np.triu(np.ones(corr_matrix.shape), k=1).astype(bool)
)
high_correlation = [
column
for column in upper_triangle.columns
if any(upper_triangle[column] > 0.95)
]

if high_correlation:
print(f"OLS: High multicollinearity detected in columns: {high_correlation}")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def package_files(directory):
"platformdirs",
"fs",
"statsmodels",
"SALib"
"SALib",
],
url="https://github.com/polca/premise",
description="Scenario-level LCA of energy systems and transition pathways",
Expand Down

0 comments on commit 89b3518

Please sign in to comment.