py-pilecore 0.5.0__py3-none-any.whl → 0.6.0__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 py-pilecore might be problematic. Click here for more details.

@@ -0,0 +1,75 @@
1
+ from __future__ import annotations # noqa: F404
2
+
3
+ from typing import Any
4
+
5
+ from IPython.display import DisplayHandle, display
6
+ from ipywidgets import widgets
7
+
8
+ from pypilecore.results.cases_multi_cpt_results import CasesMultiCPTBearingResults
9
+ from pypilecore.results.result_definitions import CPTGroupResultDefinitions
10
+ from pypilecore.viewers.interactive_figures import FigureCPTGroupResultsVersusPtls
11
+
12
+
13
+ class ViewerCptGroupResults:
14
+ """
15
+ Viewer for the CPT group results of the bearing capacity calculations.
16
+
17
+ It offers the following layout:
18
+ - Dropdown widgets:
19
+ - Result: to select the result to show.
20
+ - Figure CPT group results vs. pile tip level:
21
+ - X axis: result values
22
+ - Y axis: pile tip level w.r.t. NAP
23
+ - Each trace represents a different case.
24
+ """
25
+
26
+ def __init__(self, cases_multi_results: CasesMultiCPTBearingResults) -> None:
27
+ """Initialize the viewer.
28
+
29
+ Parameters
30
+ ----------
31
+ cases_multi_results : CasesMultiCPTBearingResults
32
+ The results of the bearing capacity calculations.
33
+
34
+ Raises
35
+ ------
36
+ TypeError
37
+ If 'cases_multi_results' are not of type 'CasesMultiCPTBearingResults'.
38
+ """
39
+ # Initialize figure CPT group resuls vs. pile tip level
40
+ self._figure_plts = FigureCPTGroupResultsVersusPtls(
41
+ cases_multi_results=cases_multi_results
42
+ )
43
+
44
+ # Set up control widgets
45
+ self._result_dropdown = widgets.Dropdown(
46
+ description="Result:",
47
+ value=CPTGroupResultDefinitions.R_c_d_net.name,
48
+ options=CPTGroupResultDefinitions.natsorted_names(),
49
+ )
50
+
51
+ # Update plot for initial selection of control widgets
52
+ self._update_result(None)
53
+
54
+ # Set up callbacks
55
+ self._result_dropdown.observe(self._update_result, "value")
56
+
57
+ # Set up layout
58
+ self._control_widgets = widgets.HBox(
59
+ [
60
+ self._result_dropdown,
61
+ ]
62
+ )
63
+ self._layout = widgets.VBox([self._control_widgets, self._figure_plts.figure])
64
+
65
+ def _update_result(self, change: Any) -> None:
66
+ """Private method to update the figure when the result name is changed in the result dropdown."""
67
+
68
+ # Update the figure
69
+ self._figure_plts.show_result(
70
+ result_name=self._result_dropdown.value,
71
+ )
72
+
73
+ def display(self) -> DisplayHandle | None:
74
+ """Display the figure."""
75
+ return display(self._layout)
@@ -0,0 +1,87 @@
1
+ from __future__ import annotations # noqa: F404
2
+
3
+ from typing import Any
4
+
5
+ from IPython.display import DisplayHandle, display
6
+ from ipywidgets import widgets
7
+
8
+ from pypilecore.results.cases_multi_cpt_results import CasesMultiCPTBearingResults
9
+ from pypilecore.results.result_definitions import CPTResultDefinitions
10
+ from pypilecore.viewers.interactive_figures import FigureCPTResultsVersusPtls
11
+
12
+
13
+ class ViewerCptResults:
14
+ """
15
+ Viewer for the CPT results of the bearing capacity calculations.
16
+
17
+ It offers the following layout:
18
+ - Dropdown widgets:
19
+ - Case: to select the case to show.
20
+ - Result: to select the result to show.
21
+ - Figure CPT results vs. pile tip level:
22
+ - X axis: result values
23
+ - Y axis: pile tip level w.r.t. NAP
24
+ - Each trace represents a different CPT.
25
+ """
26
+
27
+ def __init__(self, cases_multi_results: CasesMultiCPTBearingResults) -> None:
28
+ """Initialize the viewer.
29
+
30
+ Parameters
31
+ ----------
32
+ cases_multi_results : CasesMultiCPTBearingResults
33
+ The results of the bearing capacity calculations.
34
+
35
+ Raises
36
+ ------
37
+ TypeError
38
+ If 'cases_multi_results' are not of type 'CasesMultiCPTBearingResults'.
39
+ """
40
+
41
+ # Initialize figure CPT resuls vs. pile tip level
42
+ self._figure_plts = FigureCPTResultsVersusPtls(
43
+ cases_multi_results=cases_multi_results
44
+ )
45
+
46
+ # Set up control widgets
47
+ self._case_dropdown = widgets.Dropdown(
48
+ description="Case:",
49
+ value=self._figure_plts.cases[0],
50
+ options=self._figure_plts.cases,
51
+ )
52
+ self._result_dropdown = widgets.Dropdown(
53
+ description="Result:",
54
+ value=CPTResultDefinitions.R_c_d_net.name,
55
+ options=CPTResultDefinitions.natsorted_names(),
56
+ )
57
+
58
+ # Update plot for initial selection of control widgets
59
+ self._update_case_and_result(None)
60
+
61
+ # Set up callbacks
62
+ self._case_dropdown.observe(self._update_case_and_result, "value")
63
+ self._result_dropdown.observe(self._update_case_and_result, "value")
64
+
65
+ # Set up layout
66
+ self._control_widgets = widgets.HBox(
67
+ [
68
+ self._case_dropdown,
69
+ self._result_dropdown,
70
+ ]
71
+ )
72
+ self._layout = widgets.VBox(
73
+ [self._control_widgets, self._figure_plts.figure]
74
+ ) # , width=800)
75
+
76
+ def _update_case_and_result(self, change: Any) -> None:
77
+ """Private method to update the figure when the case or result name are changed in the control widgets."""
78
+
79
+ # Update the figure
80
+ self._figure_plts.show_case_and_result(
81
+ case_name=self._case_dropdown.value,
82
+ result_name=self._result_dropdown.value,
83
+ )
84
+
85
+ def display(self) -> DisplayHandle | None:
86
+ """Display the figure."""
87
+ return display(self._layout)
@@ -0,0 +1,101 @@
1
+ from __future__ import annotations # noqa: F404
2
+
3
+ from typing import Any
4
+
5
+ from IPython.display import DisplayHandle, display
6
+ from ipywidgets import widgets
7
+
8
+ from pypilecore.results.cases_multi_cpt_results import CasesMultiCPTBearingResults
9
+ from pypilecore.results.result_definitions import CPTResultDefinitions
10
+ from pypilecore.viewers.interactive_figures.figure_cpt_results_plan_view import (
11
+ FigureCPTResultsPlanView,
12
+ )
13
+
14
+
15
+ class ViewerCptResultsPlanView:
16
+ """
17
+ Viewer for the CPT results of the bearing capacity calculations in
18
+ plan view for a fixed pile tip level (PTL).
19
+
20
+ It offers the following layout:
21
+ - Dropdown widgets:
22
+ - Case: to select the case to show.
23
+ - Result: to select the result to show.
24
+ - Pile tip level: to select the pile tip level to show.
25
+ - Figure CPT results vs. pile tip level:
26
+ - X axis: X coordinate.
27
+ - Y axis: Y coordinate.
28
+ - Each point represents a different CPT, but the same pile tip level.
29
+ """
30
+
31
+ def __init__(self, cases_multi_results: CasesMultiCPTBearingResults) -> None:
32
+ """Initialize the viewer.
33
+
34
+ Parameters
35
+ ----------
36
+ cases_multi_results : CasesMultiCPTBearingResults
37
+ The results of the bearing capacity calculations.
38
+
39
+ Raises
40
+ ------
41
+ TypeError
42
+ If 'cases_multi_results' are not of type 'CasesMultiCPTBearingResults'.
43
+ """
44
+
45
+ # Initialize figure CPT results in plan view
46
+ self._figure_plan_view = FigureCPTResultsPlanView(
47
+ cases_multi_results=cases_multi_results
48
+ )
49
+
50
+ # Set up control widgets
51
+ self._case_dropdown = widgets.Dropdown(
52
+ description="Case:",
53
+ value=self._figure_plan_view.cases[0],
54
+ options=self._figure_plan_view.cases,
55
+ )
56
+ self._result_dropdown = widgets.Dropdown(
57
+ description="Result:",
58
+ value=CPTResultDefinitions.R_c_d_net.name,
59
+ options=CPTResultDefinitions.natsorted_names(),
60
+ )
61
+ self._pile_tip_level_dropdown = widgets.Dropdown(
62
+ description="Pile tip level NAP:",
63
+ value=self._figure_plan_view.pile_tip_levels_nap[-1],
64
+ options=self._figure_plan_view.pile_tip_levels_nap,
65
+ )
66
+
67
+ # Update plot for initial selection of control widgets
68
+ self._update_case_result_and_ptl(None)
69
+
70
+ # Set up callbacks
71
+ self._case_dropdown.observe(self._update_case_result_and_ptl, "value")
72
+ self._result_dropdown.observe(self._update_case_result_and_ptl, "value")
73
+ self._pile_tip_level_dropdown.observe(self._update_case_result_and_ptl, "value")
74
+
75
+ # Set up layout
76
+ self._control_widgets = widgets.HBox(
77
+ [
78
+ self._case_dropdown,
79
+ self._result_dropdown,
80
+ self._pile_tip_level_dropdown,
81
+ ]
82
+ )
83
+ self._layout = widgets.VBox(
84
+ [self._control_widgets, self._figure_plan_view.figure]
85
+ )
86
+
87
+ def _update_case_result_and_ptl(self, change: Any) -> None:
88
+ """
89
+ Private method to update the figure when the case, result name or pile tip level
90
+ are changed in the control widgets.
91
+ """
92
+ # Update the figure
93
+ self._figure_plan_view.show_case_result_and_ptl(
94
+ case_name=self._case_dropdown.value,
95
+ result_name=self._result_dropdown.value,
96
+ pile_tip_level_nap=self._pile_tip_level_dropdown.value,
97
+ )
98
+
99
+ def display(self) -> DisplayHandle | None:
100
+ """Display the figure."""
101
+ return display(self._layout)