Skip to content
Snippets Groups Projects
Commit 742500c7 authored by Laura Christine Kühle's avatar Laura Christine Kühle
Browse files

Combined 'get_cells()' and '_get_cells()'.

parent 3e4d5284
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,10 @@ TODO: Contemplate saving training data for each IC separately ...@@ -16,6 +16,10 @@ TODO: Contemplate saving training data for each IC separately
TODO: Contemplate removing TrainingDataGenerator class TODO: Contemplate removing TrainingDataGenerator class
TODO: Ask why no fine mesh is used for calculate_coarse_projection() TODO: Ask why no fine mesh is used for calculate_coarse_projection()
TODO: Ask the meaning of the shifted bounds in Boxplot (Modified script)
TODO: Ask whether the indices for the wavelet calculation are i or i+1
TODO: Ask why wavelet matrix has unset ghost cells
Urgent: Urgent:
TODO: Enforce mesh with 2^n cells TODO: Enforce mesh with 2^n cells
TODO: Change heaviside random to uniform(-100, 100) TODO: Change heaviside random to uniform(-100, 100)
......
...@@ -8,12 +8,10 @@ TODO: Change method of calculating quartiles -> Done ...@@ -8,12 +8,10 @@ TODO: Change method of calculating quartiles -> Done
TODO: Include overlapping cells in quartile calculation (if needed) -> Done TODO: Include overlapping cells in quartile calculation (if needed) -> Done
TODO: Determine max_value for Theoretical only over highest degree TODO: Determine max_value for Theoretical only over highest degree
-> Done (now optional) -> Done (now optional)
TODO: Check if indexing in wavelets is correct TODO: Check if indexing in wavelets is correct -> Done
TODO: Combine get_cells() and _get_cells() TODO: Combine get_cells() and _get_cells() -> Done
TODO: Add TC condition to only flag cell if left-adjacent one is flagged as TODO: Check coarse_projection calculation for indexing errors -> Done
well (remove this condition) TODO: Adjust Boxplot approach (adjacent cells, outer fence, etc.) -> Done
TODO: Check coarse_projection calculation for indexing errors
TODO: Adjust Boxplot approach (adjacent cells, outer fence, etc.)
TODO: Give detailed description of wavelet detection TODO: Give detailed description of wavelet detection
""" """
...@@ -237,24 +235,6 @@ class WaveletDetector(TroubledCellDetector): ...@@ -237,24 +235,6 @@ class WaveletDetector(TroubledCellDetector):
self._wavelet_projection_left, self._wavelet_projection_right \ self._wavelet_projection_left, self._wavelet_projection_right \
= self._basis.multiwavelet_projection = self._basis.multiwavelet_projection
def get_cells(self, projection):
"""Calculates troubled cells in a given projection.
Parameters
----------
projection : ndarray
Matrix of projection for each polynomial degree.
Returns
-------
list
List of indices for all detected troubled cells.
"""
multiwavelet_coeffs = self._calculate_wavelet_coeffs(projection)
multiwavelet_coeffs = self._select_degree(multiwavelet_coeffs)
return self._get_cells(multiwavelet_coeffs, projection)
def _calculate_wavelet_coeffs(self, projection): def _calculate_wavelet_coeffs(self, projection):
"""Calculates wavelet coefficients used for projection to coarser grid. """Calculates wavelet coefficients used for projection to coarser grid.
...@@ -303,25 +283,6 @@ class WaveletDetector(TroubledCellDetector): ...@@ -303,25 +283,6 @@ class WaveletDetector(TroubledCellDetector):
min_values = np.min(wavelet_matrix, axis=0) min_values = np.min(wavelet_matrix, axis=0)
return np.where(-min_values > max_values, min_values, max_values) return np.where(-min_values > max_values, min_values, max_values)
@abstractmethod
def _get_cells(self, multiwavelet_coeffs, projection):
"""Calculates troubled cells using multiwavelet coefficients.
Parameters
----------
multiwavelet_coeffs : ndarray
Matrix of multiwavelet coefficients.
projection : ndarray
Matrix of projection for each polynomial degree.
Returns
-------
list
List of indices for all detected troubled cells.
"""
pass
def _calculate_coarse_projection(self, projection): def _calculate_coarse_projection(self, projection):
"""Calculates coarse projection. """Calculates coarse projection.
...@@ -419,23 +380,23 @@ class Boxplot(WaveletDetector): ...@@ -419,23 +380,23 @@ class Boxplot(WaveletDetector):
fold * self._fold_len - num_overlapping_cells, fold * self._fold_len - num_overlapping_cells,
(fold+1) * self._fold_len + num_overlapping_cells)]) (fold+1) * self._fold_len + num_overlapping_cells)])
def _get_cells(self, coeffs, projection): def get_cells(self, projection):
"""Calculate troubled cells using multiwavelet coefficients. """Calculate troubled cells in a given projection.
Parameters Parameters
---------- ----------
coeffs : ndarray
Matrix of multiwavelet coefficients.
projection : ndarray projection : ndarray
Matrix of projection for each polynomial degree. Matrix of projection for each polynomial degree.
Returns Returns
------- -------
list list
List of indices of all detected troubled cells. List of indices for all detected troubled cells.
""" """
# Determine quartiles of folds # Determine quartiles of folds
coeffs = self._select_degree(self._calculate_wavelet_coeffs(
projection))
folds = coeffs[self._fold_indices] folds = coeffs[self._fold_indices]
first_quartiles = np.quantile(folds, 0.25, axis=1, first_quartiles = np.quantile(folds, 0.25, axis=1,
method=self._quantile_method) method=self._quantile_method)
...@@ -508,13 +469,11 @@ class Theoretical(WaveletDetector): ...@@ -508,13 +469,11 @@ class Theoretical(WaveletDetector):
np.sqrt(2) * self._mesh.cell_len) np.sqrt(2) * self._mesh.cell_len)
# comment to line above: or 2 or 3 # comment to line above: or 2 or 3
def _get_cells(self, coeffs, projection): def get_cells(self, projection):
"""Calculates troubled cells using multiwavelet coefficients. """Calculate troubled cells in a given projection.
Parameters Parameters
---------- ----------
coeffs : ndarray
Matrix of multiwavelet coefficients.
projection : ndarray projection : ndarray
Matrix of projection for each polynomial degree. Matrix of projection for each polynomial degree.
...@@ -524,6 +483,8 @@ class Theoretical(WaveletDetector): ...@@ -524,6 +483,8 @@ class Theoretical(WaveletDetector):
List of indices for all detected troubled cells. List of indices for all detected troubled cells.
""" """
coeffs = self._select_degree(self._calculate_wavelet_coeffs(
projection))
troubled_cells = [] troubled_cells = []
max_avg = np.sqrt(0.5) \ max_avg = np.sqrt(0.5) \
* max(1, max(abs(projection[0][cell+1]) * max(1, max(abs(projection[0][cell+1])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment