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

Enforced boundary condition on Boxplot bounds with decorator.

parent e036e917
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,7 @@ TODO: Discuss how wavelet details should be plotted
Urgent:
TODO: Refactor Boxplot class -> Done
TODO: Enforce periodic boundary condition for projection with decorator -> Done
TODO: Enforce Boxplot bounds with decorator
TODO: Enforce Boxplot bounds with decorator -> Done
TODO: Enforce Boxplot folds with decorator
TODO: Enforce boundary for initial condition in exact solution only
TODO: Adapt number of ghost cells based on ANN stencil
......
......@@ -3,17 +3,9 @@
@author: Laura C. Kühle
"""
# from typing import Tuple
# from abc import ABC, abstractmethod
# import numpy as np
import numpy as np
from numpy import ndarray
# from .Basis_Function import Basis
# from .Initial_Condition import InitialCondition
# from .Mesh import Mesh
# from .projection_utils import do_initial_projection
# from .Quadrature import Quadrature
def periodic_boundary(projection: ndarray, num_ghost_cells: int) -> ndarray:
"""Enforce boundary condition.
......@@ -74,3 +66,14 @@ def enforce_boundary(num_ghost_cells=None):
raise Exception('Not implemented!')
return boundary
return _enforce_boundary
def enforce_boxplot_boundaries(func):
def boxplot_boundary(self, *args, **kwargs):
bounds = np.array(func(self, *args, **kwargs))
if self._mesh.boundary == 'periodic':
return tuple(periodic_boundary(projection=bounds,
num_ghost_cells=1))
else:
raise Exception('Not implemented!')
return boxplot_boundary
......@@ -10,6 +10,7 @@ from numpy import ndarray
import torch
from . import ANN_Model
from .Boundary_Condition import enforce_boxplot_boundaries
from .Mesh import Mesh
......@@ -423,6 +424,7 @@ class Boxplot(WaveletDetector):
return troubled_cells
@enforce_boxplot_boundaries
def _compute_bounds(self, coeffs: ndarray) -> Tuple[ndarray, ndarray]:
"""Compute lower and upper bound for Boxplot outliers.
......@@ -455,12 +457,6 @@ class Boxplot(WaveletDetector):
upper_bounds[1:-1] = third_quartiles + self._whisker_len * (
third_quartiles-first_quartiles)
# Adjust bounds to capture periodic boundary
lower_bounds[0] = lower_bounds[-2]
lower_bounds[-1] = lower_bounds[1]
upper_bounds[0] = upper_bounds[-2]
upper_bounds[-1] = upper_bounds[1]
return lower_bounds, upper_bounds
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment