Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Troubled Cell Detection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Laura Christine Kühle
Troubled Cell Detection
Commits
17e71388
Commit
17e71388
authored
3 years ago
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Added documentation to 'Plotting'.
parent
a5264b2d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Plotting.py
+133
-0
133 additions, 0 deletions
Plotting.py
with
133 additions
and
0 deletions
Plotting.py
+
133
−
0
View file @
17e71388
...
...
@@ -17,6 +17,22 @@ sns.set()
def
plot_solution_and_approx
(
grid
,
exact
,
approx
,
color_exact
,
color_approx
):
""""
Plots approximate and exact solution against each other.
Parameters
----------
grid : np.array
List of mesh evaluation points.
exact : np.array
Array containing exact evaluation of a function.
approx : np.array
Array containing approximate evaluation of a function.
color_exact : str
String describing color to plot exact solution.
color_approx : str
String describing color to plot approximate solution.
"""
print
(
color_exact
,
color_approx
)
plt
.
figure
(
'
exact_and_approx
'
)
plt
.
plot
(
grid
[
0
],
exact
[
0
],
color_exact
)
...
...
@@ -27,6 +43,16 @@ def plot_solution_and_approx(grid, exact, approx, color_exact, color_approx):
def
plot_semilog_error
(
grid
,
pointwise_error
):
""""
Plots semi-logarithmic error between approximate and exact solution.
Parameters
----------
grid : np.array
List of mesh evaluation points.
pointwise_error : np.array
Array containing pointwise difference between exact and approximate solution.
"""
plt
.
figure
(
'
semilog_error
'
)
plt
.
semilogy
(
grid
[
0
],
pointwise_error
[
0
])
plt
.
xlabel
(
'
x
'
)
...
...
@@ -35,6 +61,18 @@ def plot_semilog_error(grid, pointwise_error):
def
plot_error
(
grid
,
exact
,
approx
):
""""
Plots error between approximate and exact solution.
Parameters
----------
grid : np.array
List of mesh evaluation points.
exact : np.array
Array containing exact evaluation of a function.
approx : np.array
Array containing approximate evaluation of a function.
"""
plt
.
figure
(
'
error
'
)
plt
.
plot
(
grid
[
0
],
exact
[
0
]
-
approx
[
0
])
plt
.
xlabel
(
'
X
'
)
...
...
@@ -43,6 +81,20 @@ def plot_error(grid, exact, approx):
def
plot_shock_tube
(
num_grid_cells
,
troubled_cell_history
,
time_history
):
""""
Plots shock tube.
Plots detected troubled cells over time to depict the evolution of shocks as shock tubes.
Parameters
----------
num_grid_cells : int
Number of cells in the mesh. Usually exponential of 2.
troubled_cell_history : list
List of detected troubled cells for each time step.
time_history:
List of value of each time step.
"""
plt
.
figure
(
'
shock_tube
'
)
for
pos
in
range
(
len
(
time_history
)):
current_cells
=
troubled_cell_history
[
pos
]
...
...
@@ -56,6 +108,27 @@ def plot_shock_tube(num_grid_cells, troubled_cell_history, time_history):
def
plot_details
(
fine_projection
,
fine_mesh
,
coarse_projection
,
basis
,
wavelet
,
multiwavelet_coeffs
,
num_coarse_grid_cells
,
polynomial_degree
):
""""
Plots details of projection to coarser mesh..
Parameters
----------
fine_projection, coarse_projection : np.array
Matrix of projection for each polynomial degree.
fine_mesh : np.array
List of evaluation points for fine mesh.
basis : np.array
Basis vector for calculation.
wavelet : np.array
Wavelet vector for calculation.
multiwavelet_coeffs : np.array
Matrix of multiwavelet coefficients.
num_coarse_grid_cells : int
Number of cells in the coarse mesh (half the cells of the fine mesh).
Usually exponential of 2.
polynomial_degree : int
Polynomial degree.
"""
averaged_projection
=
[[
coarse_projection
[
degree
][
cell
]
*
basis
[
degree
].
subs
(
x
,
value
)
for
cell
in
range
(
num_coarse_grid_cells
)
for
value
in
[
-
0.5
,
0.5
]]
...
...
@@ -81,6 +154,25 @@ def plot_details(fine_projection, fine_mesh, coarse_projection, basis, wavelet,
def
calculate_approximate_solution
(
projection
,
points
,
polynomial_degree
,
basis
):
""""
Calculates approximate solution.
Parameters
----------
projection : np.array
Matrix of projection for each polynomial degree.
points : np.array
List of evaluation points for mesh.
polynomial_degree : int
Polynomial degree.
basis : np.array
Basis vector for calculation.
Returns
-------
np.array
Array containing approximate evaluation of a function.
"""
num_points
=
len
(
points
)
basis_matrix
=
[[
basis
[
degree
].
subs
(
x
,
points
[
point
])
for
point
in
range
(
num_points
)]
...
...
@@ -96,6 +188,31 @@ def calculate_approximate_solution(projection, points, polynomial_degree, basis)
def
calculate_exact_solution
(
mesh
,
cell_len
,
wave_speed
,
final_time
,
interval_len
,
quadrature
,
init_cond
):
""""
Calculates exact solution.
Parameters
----------
mesh : array
List of mesh valuation points.
cell_len : float
Length of a cell in mesh.
wave_speed : float
Speed of wave in rightward direction.
final_time : float
Final time for which approximation is calculated.
interval_len : float
Length of the interval between left and right boundary.
quadrature : Quadrature object
Quadrature for evaluation.
init_cond : InitialCondition object
Initial condition for evaluation.
Returns
-------
np.array
Array containing exact evaluation of a function.
"""
grid
=
[]
exact
=
[]
num_periods
=
np
.
floor
(
wave_speed
*
final_time
/
interval_len
)
...
...
@@ -119,6 +236,22 @@ def calculate_exact_solution(mesh, cell_len, wave_speed, final_time, interval_le
def
plot_classification_accuracy
(
precision
,
recall
,
accuracy
,
xlabels
):
"""
Plots classification accuracy.
Plots the accuracy, precision, and recall in a bar plot.
Parameters
----------
precision : float
Precision of classification.
recall : float
Recall of classification.
accuracy : float
Accuracy of classification.
xlabels : list
List of strings for x-axis labels.
"""
precision
=
[
precision
]
recall
=
[
recall
]
accuracy
=
[
accuracy
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment