diff --git a/Troubled_Cell_Detector.py b/Troubled_Cell_Detector.py index 19f0a4e04d2cd0394f83d519641825b567696bb8..7b5755bd6bf62577a361dd6c23e397b13ded49cf 100644 --- a/Troubled_Cell_Detector.py +++ b/Troubled_Cell_Detector.py @@ -4,12 +4,12 @@ TODO: Introduce Adjusted Outer Fence method in Boxplot using global_mean -> Done -TODO: Introduce overlapping cell for adjacent folds in Boxplot +TODO: Introduce overlapping cells for adjacent folds in Boxplot -> Done +TODO: Extract fold computing from TC checking TODO: Introduce lower/upper extreme outliers in Boxplot (each cell is also checked for neighboring domains if existing) TODO: Determine max_value for Theoretical only over highest degree TODO: Check if indexing in wavelets is correct -TODO: Extract fold computing from TC checking TODO: Add ThresholdDetector TODO: Add TC condition to only flag cell if left-adjacent one is flagged as well (remove this condition) @@ -342,6 +342,8 @@ class Boxplot(WaveletDetector): Length of Boxplot whiskers. adjust_outer_fences : bool Flag whether outer fences should be adjusted using global mean. + num_overlapping_cells : int + Number of cells overlapping with adjacent folds. """ def _reset(self, config): @@ -359,6 +361,7 @@ class Boxplot(WaveletDetector): self._fold_len = config.pop('fold_len', 16) self._whisker_len = config.pop('whisker_len', 3) self._adjust_outer_fences = config.pop('adjust_outer_fences', True) + self._num_overlapping_cells = config.pop('num_overlapping_cells', 1) def _get_cells(self, multiwavelet_coeffs, projection): """Calculates troubled cells using multiwavelet coefficients. @@ -392,8 +395,11 @@ class Boxplot(WaveletDetector): troubled_cells = [] for fold in range(num_folds): - sorted_fold = sorted(indexed_coeffs[fold * self._fold_len: - (fold+1) * self._fold_len]) + indices = np.array([i % len(indexed_coeffs) for i in range( + fold * self._fold_len - self._num_overlapping_cells, + (fold+1) * self._fold_len + self._num_overlapping_cells)]) + sorted_fold = sorted(np.array(indexed_coeffs)[indices], + key=lambda x: x[0]) boundary_index = self._fold_len//4 balance_factor = self._fold_len/4.0 - boundary_index @@ -422,7 +428,7 @@ class Boxplot(WaveletDetector): else: break - # Check for lower extreme outliers and add respective cells + # Check for upper extreme outliers and add respective cells for cell in sorted_fold[::-1][:]: if cell[0] > upper_bound: troubled_cells.append(cell[1])