Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 100 additions & 62 deletions PV-tool_TD.ipynb

Large diffs are not rendered by default.

Binary file modified dist/pv_tool-0.3.0-py3-none-any.whl
Binary file not shown.
Binary file modified dist/pv_tool-0.3.0.tar.gz
Binary file not shown.
Binary file added dist/pv_tool-0.3.1-py3-none-any.whl
Binary file not shown.
Binary file added dist/pv_tool-0.3.1.tar.gz
Binary file not shown.
3,888 changes: 3,888 additions & 0 deletions import_files/SHANSEP_ln_ocr_ln_s_TXT_klei_14_16.html

Large diffs are not rendered by default.

3,888 changes: 3,888 additions & 0 deletions import_files/SHANSEP_sv_su_TXT_klei_14_16.html

Large diffs are not rendered by default.

3,888 changes: 3,888 additions & 0 deletions import_files/SHANSEP_sv_su_nc_TXT_klei_14_16.html

Large diffs are not rendered by default.

3,888 changes: 3,888 additions & 0 deletions import_files/SU_ln_sv_ln_su_TXT_klei_14_16.html

Large diffs are not rendered by default.

3,888 changes: 3,888 additions & 0 deletions import_files/SU_sv_su_TXT_klei_14_16.html

Large diffs are not rendered by default.

Binary file modified import_files/WSRL 2025 PVtool5_0_gevalideerd.xlsx
Binary file not shown.
3,888 changes: 3,888 additions & 0 deletions import_files/c-phi_analyse_TXT_klei_14_16.html

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added import_files/temp_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added import_files/temp_plot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added import_files/temp_plot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added import_files/temp_plot3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added import_files/temp_sutabel_plot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added import_files/temp_sutabel_plot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 42 additions & 53 deletions pv_tool/cphi_analysis/c_phi_analysis.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from typing import Optional, List, Literal
from openpyxl import load_workbook, Workbook
from openpyxl.utils import get_column_letter
from pathlib import Path
from datetime import datetime
from pv_tool.utilities.utils import get_repo_root
from pandas import DataFrame, concat, read_excel, isna
from pv_tool.utilities.utils import get_repo_root, make_temp_folder
from pandas import DataFrame, ExcelWriter, concat, read_excel, isna
from pv_tool.cphi_analysis.globals import (TEXTUAL_NAMES, ALL_TEXTUAL_NAMES,
NEW_COLUMN_NAMES, TEXTUAL_NAMES_DSS, ALL_TEXTUAL_NAMES_DSS)
from pv_tool.cphi_analysis.save_and_export import save_total_to_excel, save_to_pdf
Expand All @@ -12,28 +14,25 @@
from pv_tool.cphi_analysis.expand_analysis_df import (calculate_tan_a, calculate_ln_tan_a, calculate_s_tt,
calculate_s_ty, calculate_kappa_2, calculate_s,
calculate_5pr_ondergrens, calculate_5pr_bovengrens,
calculate_s_tt_ondergrens, calculate_s_ty_ondergrens,
calculate_kappa_2_ondergrens, calculate_correctie_t,
kappa_2_2pr_cor,
calculate_5pr_ondergrens_correctie_c,
calculate_5pr_bovengrens_correctie_c,
calculate_s_ty_ondergrens_correctie_c,
calculate_kappa_2_ondergrens_correctie_c)
calculate_s_tt_ondergrens, calculate_s_ty_ondergrens,
calculate_kappa_2_ondergrens, calculate_correctie_t, kappa_2_2pr_cor,
calculate_5pr_ondergrens_correctie_c,
calculate_5pr_bovengrens_correctie_c,
calculate_s_ty_ondergrens_correctie_c,
calculate_kappa_2_ondergrens_correctie_c)
from pv_tool.cphi_analysis.visualization import (add_proefresultaten, add_extra_proefresultaten, add_5pr_bovengrens,
add_5pr_ondergrens, add_fysische_realiseerbare_ondergrens,
add_gemiddelde,
set_layout, add_gemiddelde_sh, add_raaklijn_kar_boven,
add_5pr_ondergrens, add_fysische_realiseerbare_ondergrens, add_gemiddelde,
set_layout, add_gemiddelde_sh, add_raaklijn_kar_boven,
add_raaklijn_kar_onder)
from pv_tool.cphi_analysis.calc_parameters import (calc_watergehalte_gem, calc_watergehalte_sd, calc_vgwnat_gem,
calc_vgwnat_sd, calc_a2_phi_gem, calc_a2_kar, calc_phi_d,
calc_vgwnat_sd, calc_a2_phi_gem, calc_a2_kar, calc_phi_d,
helling_gecorrigeerd, calc_a1_c_gem, calc_tan_phi_gem, calc_phi_kar,
calc_a1_kar, calc_phi_gem, calc_c_gem, calc_tan_phi_kar,
calc_c_kar, calc_tan_phi_d, calc_c_d, calc_st_dev_phi, calc_st_dev_c,
calc_a2_phi_gem_sh, calc_a2_phi_kar_boven_sh,
calc_a2_phi_kar_onder_sh,
calc_c_kar, calc_tan_phi_d, calc_c_d, calc_st_dev_phi, calc_st_dev_c,
calc_a2_phi_gem_sh, calc_a2_phi_kar_boven_sh, calc_a2_phi_kar_onder_sh,
calc_tan_phi_kar_sh)
from openpyxl import load_workbook

from pv_tool.imports.excel_utils import format_excel_sheet

class CPhiAnalyse:
"""
Expand All @@ -46,8 +45,8 @@ class CPhiAnalyse:
def __init__(self, dbase: Dbase,
analysis_type: Literal['TXT_CPhi', 'TXT_SH', 'DSS_CPhi', 'DSS_SH'],
investigation_groups: List,
effective_stress: Literal[
'2% rek', '5% rek', '10% rek', '15% rek', '20% rek', 'pieksterkte', 'eindsterkte']):
effective_stress: Literal['2% rek', '5% rek', '10% rek', '15% rek', '20% rek',
'pieksterkte', 'eindsterkte']):
"""
Initialiseert een nieuwe c-phi analyse.

Expand Down Expand Up @@ -140,7 +139,7 @@ def get_cphi_data(self):
if self.analysis_type in ['TXT_CPhi', 'TXT_SH']:
self.cphi_analyses_data_df = self.dbase_df[self.dbase_df['ALG__TRIAXIAAL']]
self.cphi_analyses_data_df = self.cphi_analyses_data_df[self.cphi_analyses_data_df['PV_NAAM'].isin(
self.investigation_groups)]
self.investigation_groups)]
self.calc_watergehalte_gem = calc_watergehalte_gem(self)
self.calc_watergehalte_sd = calc_watergehalte_sd(self)
self.calc_vgwnat_gem = calc_vgwnat_gem(self)
Expand All @@ -151,15 +150,14 @@ def get_cphi_data(self):
# Valideer of er data overblijft na filtering
if self.cphi_analyses_data_df.empty:
raise ValueError(f"Geen data gevonden na filtering op investigation_groups {self.investigation_groups} "
f"en effective_stress '{self.effective_stress}' "
f"voor analyse type '{self.analysis_type}'")
f"en effective_stress '{self.effective_stress}' voor analyse type '{self.analysis_type}'")

print(f"Data na filtering: {len(self.cphi_analyses_data_df)} rijen gevonden")

elif self.analysis_type in ['DSS_CPhi', 'DSS_SH']:
self.cphi_analyses_data_df = self.dbase_df[self.dbase_df['ALG__DSS']]
self.cphi_analyses_data_df = self.cphi_analyses_data_df[self.cphi_analyses_data_df['PV_NAAM'].isin(
self.investigation_groups)]
self.investigation_groups)]
self.calc_watergehalte_gem = calc_watergehalte_gem(self)
self.calc_watergehalte_sd = calc_watergehalte_sd(self)
self.calc_vgwnat_gem = calc_vgwnat_gem(self)
Expand All @@ -170,8 +168,7 @@ def get_cphi_data(self):
# Valideer of er data overblijft na filtering
if self.cphi_analyses_data_df.empty:
raise ValueError(f"Geen data gevonden na filtering op investigation_groups {self.investigation_groups} "
f"en effective_stress '{self.effective_stress}' "
f"voor analyse type '{self.analysis_type}'")
f"en effective_stress '{self.effective_stress}' voor analyse type '{self.analysis_type}'")

print(f"Data na filtering: {len(self.cphi_analyses_data_df)} rijen gevonden")

Expand Down Expand Up @@ -235,7 +232,7 @@ def plot_spanningspaden(self):
wordt een apart spanningspad gemaakt met alle beschikbare spanningsstappen.

Wordt aangeroepen binnen set_figure(). Het is aan de gebruiker om de spanningspaden wel of niet toe te voegen
aan de figuur
aan de figuur.
"""
if self.analysis_type in ['TXT_CPhi', 'TXT_SH']:
relevant_df = self.dbase_df[self.dbase_df['ALG__TRIAXIAAL']]
Expand All @@ -244,17 +241,15 @@ def plot_spanningspaden(self):
elif self.analysis_type in ['DSS_CPhi', 'DSS_SH']:
relevant_df = self.dbase_df[self.dbase_df['ALG__DSS']]
relevant_df = relevant_df[relevant_df['PV_NAAM'].isin(self.investigation_groups)]
effective_stress_options = ['consolidatie', '2% rek', '5% rek', '10% rek', '15% rek', '20% rek',
'pieksterkte', 'eindsterkte']
relevant_df['DSS_T_CONSOLIDATIE'] = [0] * len(relevant_df)
effective_stress_options = ['consolidatie', '2% rek', '5% rek', '10% rek', '15% rek', '20% rek', 'pieksterkte', 'eindsterkte']
relevant_df['DSS_T_CONSOLIDATIE'] = [0]*len(relevant_df)
else:
raise ValueError("Ongeldig analysetype. Gebruik 'TXT_CPhi', 'TXT_SH', 'DSS_CPhi' of 'DSS_SH'.")

# Eerst verzamelen we alle data per spanningsstap
all_data = {}
for stress in effective_stress_options:
columns = ALL_TEXTUAL_NAMES.get(stress, []) \
if self.analysis_type in ['TXT_CPhi', 'TXT_SH'] else ALL_TEXTUAL_NAMES_DSS.get(stress, [])
columns = ALL_TEXTUAL_NAMES.get(stress, []) if self.analysis_type in ['TXT_CPhi', 'TXT_SH'] else ALL_TEXTUAL_NAMES_DSS.get(stress, [])
if len(columns) > 0:
data = relevant_df[columns].copy()
if not data.empty and not data.isna().all().all():
Expand Down Expand Up @@ -292,17 +287,15 @@ def plot_spanningspaden(self):
stress_df = stress_df[stress_df['stress_state'] != 'pieksterkte']
if rek_bij_t_piek < 2:
insert_index = 1
elif rek_bij_t_piek < 5:
elif rek_bij_t_piek <5:
insert_index = 2
elif rek_bij_t_piek < 15:
elif rek_bij_t_piek <15:
insert_index = 3
elif not isna(rek_bij_t_eind) and rek_bij_t_eind > rek_bij_t_piek:
insert_index = 4
else:
insert_index = len(stress_df)
stress_df = concat(
[stress_df.iloc[:insert_index], piek_row, stress_df.iloc[insert_index:]]).reset_index(
drop=True)
stress_df = concat([stress_df.iloc[:insert_index], piek_row, stress_df.iloc[insert_index:]]).reset_index(drop=True)
elif self.analysis_type in ['DSS_CPhi', 'DSS_SH']:
rek_bij_t_max = self.total_cphi_analyses_data_df.loc[sample_name, 'DSS_REK_BIJ_T_MAX']
rek_bij_t_eind = self.total_cphi_analyses_data_df.loc[sample_name, 'DSS_REK_BIJ_T_EIND']
Expand All @@ -312,24 +305,24 @@ def plot_spanningspaden(self):
stress_df = stress_df[stress_df['stress_state'] != 'pieksterkte']
if rek_bij_t_max < 2:
insert_index = 1
elif rek_bij_t_max < 5:
elif rek_bij_t_max <5:
insert_index = 2
elif rek_bij_t_max < 10:
elif rek_bij_t_max <10:
insert_index = 3
elif rek_bij_t_max < 15:
elif rek_bij_t_max <15:
insert_index = 4
elif rek_bij_t_max < 20:
elif rek_bij_t_max <20:
insert_index = 5
elif not isna(rek_bij_t_eind) and rek_bij_t_eind > rek_bij_t_max:
insert_index = 6
else:
insert_index = len(stress_df)
stress_df = concat(
[stress_df.iloc[:insert_index], piek_row, stress_df.iloc[insert_index:]]).reset_index(
drop=True)
stress_df = concat([stress_df.iloc[:insert_index], piek_row, stress_df.iloc[insert_index:]]).reset_index(drop=True)

sample_stress_paths[sample_name] = stress_df



# Plot de spanningspaden
if sample_stress_paths:
from pv_tool.cphi_analysis.visualization import add_stress_paths
Expand Down Expand Up @@ -372,7 +365,7 @@ def get_previous_results(self, path: str, file_name: str):
(results_df['PV_RESULTAAT_ID'].str.contains(self.investigation_groups[0])) &
(results_df['PV_RESULTAAT_ID'].str.contains(self.effective_stress)) &
(results_df['PV_RESULTAAT_ID'].str.contains(self.analysis_type))
]
]

if filtered_df.empty:
print("Er zijn geen eerdere resultaten gevonden voor de opgegeven parameters.")
Expand Down Expand Up @@ -598,7 +591,7 @@ def get_short_results(self):
index = ['Verwachtingswaarde', 'Karakteristieke waarde', 'Rekenwaarde', 'Standaarddeviatie D-stability']
columns = ['tan phi [-]', 'phi [graden]']
analyse_output_df = DataFrame(index=index, columns=columns)
analyse_output_df['tan phi [-]'] = [self.tan_phi_gem, self.tan_phi_kar, self.tan_phi_d, '[-]']
analyse_output_df['tan phi [-]'] = [self.tan_phi_gem, self.tan_phi_kar , self.tan_phi_d, '[-]']
analyse_output_df['phi [graden]'] = [self.phi_gem, self.phi_kar, self.phi_d, self.st_dev_phi]
else:
self._run()
Expand Down Expand Up @@ -639,14 +632,10 @@ def add_results_to_template(self, path, export_name=None):
'PV_RESULTAAT_ID': f"{self.investigation_groups[0]}_{self.effective_stress}_"
f"{self.analysis_type.split('_')[0]}_{self.analysis_type.split('_')[1]}",
'PV_TYPEVERZAMELING': self.alpha,
'PV_A1_COH_GEM': round(self.gem_a1, 3) if self.gem_a1 is not None else None,
# TODO: gaat deze dan wel goed?
'PV_A2_TAN_PHI_GEM': round(self.gem_a2, 3) if self.gem_a2 is not None else None,
# TODO: welke waarde? gem_a2 of tan_phi_gem
'PV_A1_COH_KAR': round(self.kar_a1, 3) if self.kar_a1 is not None else None,
# TODO: gaat deze dan wel goed?
'PV_A2_TAN_PHI_KAR': round(self.kar_a2, 3) if self.kar_a2 is not None else None,
# TODO: zelfde geld hier met kar_a2 of tan_phi_kar
'PV_A1_COH_GEM': round(self.gem_a1, 3) if self.gem_a1 is not None else None, # TODO: gaat deze dan wel goed?
'PV_A2_TAN_PHI_GEM': round(self.gem_a2, 3) if self.gem_a2 is not None else None, # TODO: welke waarde? gem_a2 of tan_phi_gem
'PV_A1_COH_KAR': round(self.kar_a1, 3) if self.kar_a1 is not None else None, # TODO: gaat deze dan wel goed?
'PV_A2_TAN_PHI_KAR': round(self.kar_a2, 3) if self.kar_a2 is not None else None, # TODO: zelfde geld hier met kar_a2 of tan_phi_kar

'PV_COH_GEM': (
round(self.c_gem, 3) if self.c_gem is not None and self.c_gem >= 0
Expand Down
4 changes: 2 additions & 2 deletions pv_tool/cphi_analysis/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ def set_layout(self: CPhiAnalyse):
yas_title = 't [kPa]'
legend_title = 'Legenda'
self.figure.update_layout(
width=1280,
height=720,
width=1152,
height=648,
title=title if self.show_title else None,
xaxis_title=xas_title,
yaxis_title=yas_title,
Expand Down
2 changes: 1 addition & 1 deletion pv_tool/shansep_analysis/shansep_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def get_previous_results(self, path: str, file_name: str):
raise FileNotFoundError(f"Er is geen dbase aanwezig op de locatie {file_path}.")

try:
results_df = read_excel(file_path, sheet_name='Resultaten SHANSEP', header=6)
results_df = read_excel(file_path, sheet_name='Resultaten SHANSEP', skiprows=6)
except ValueError:
print("Er is geen tabblad 'Resultaten' aanwezig in het Excel-bestand.")
return None
Expand Down
12 changes: 6 additions & 6 deletions pv_tool/shansep_analysis/visualization_shansep.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,8 @@ def set_layout_sv_su(self: SHANSEP):

legend_title = 'Legenda'
self.figure_sv_su.update_layout(
width=1280,
height=720,
width=1152,
height=648,
title=title if self.show_title else None,
xaxis_title=xas_title,
yaxis_title=yas_title,
Expand All @@ -551,8 +551,8 @@ def set_layout_ln_ocr_ln_s(self: SHANSEP):

legend_title = 'Legenda'
self.figure_ln_ocr_ln_s.update_layout(
width=1280,
height=720,
width=1152,
height=648,
title=title if self.show_title else None,
xaxis_title=xas_title,
yaxis_title=yas_title,
Expand All @@ -574,8 +574,8 @@ def set_layout_sv_su_nc(self: SHANSEP):

legend_title = 'Legenda'
self.figure_sv_su_nc.update_layout(
width=1280,
height=720,
width=1152,
height=648,
title=title if self.show_title else None,
xaxis_title=xas_title,
yaxis_title=yas_title,
Expand Down
2 changes: 1 addition & 1 deletion pv_tool/sutabel_analysis/sutabel_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def get_previous_results(self, path: str, file_name: str):
raise FileNotFoundError(f"Er is geen dbase aanwezig op de locatie {file_path}.")

try:
results_df = read_excel(file_path, sheet_name='Resultaten SU-tabel-m', header=6)
results_df = read_excel(file_path, sheet_name='Resultaten SU-tabel-m', skiprows=6)
except ValueError:
print("Er is geen tabblad 'Resultaten' aanwezig in het Excel-bestand.")
return None
Expand Down
4 changes: 2 additions & 2 deletions pv_tool/sutabel_analysis/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ def set_layout_ln_sv_ln_su_sutabel(self: "SUTABEL"):

legend_title = 'Legenda'
self.figure.update_layout(
width=1280,
height=720,
width=1152,
height=648,
title=title if self.show_title else None,
xaxis_title=xas_title,
yaxis_title=yas_title,
Expand Down
8 changes: 4 additions & 4 deletions pv_tool/sutabel_analysis/visualization_sutabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ def set_layout_ln_sv_ln_su_sutabel(self: "SUTABEL"):

legend_title = 'Legenda'
self.figure_ln_sv_ln_su.update_layout(
width=1280,
height=720,
width=1152,
height=648,
title=title if self.show_title else None,
xaxis_title=xas_title,
yaxis_title=yas_title,
Expand Down Expand Up @@ -344,8 +344,8 @@ def set_layout_sv_su_sutabel(self: "SUTABEL"):

legend_title = 'Legenda'
self.figure_sv_su.update_layout(
width=1280,
height=720,
width=1152,
height=648,
title=title if self.show_title else None,
xaxis_title=xas_title,
yaxis_title=yas_title,
Expand Down
Loading
Loading