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
cdf9c9e7
Commit
cdf9c9e7
authored
2 years ago
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Reworked Theoretical method for efficiency.
parent
e01ce015
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
scripts/tcd/Troubled_Cell_Detector.py
+10
-38
10 additions, 38 deletions
scripts/tcd/Troubled_Cell_Detector.py
with
10 additions
and
38 deletions
scripts/tcd/Troubled_Cell_Detector.py
+
10
−
38
View file @
cdf9c9e7
...
@@ -432,13 +432,12 @@ class Boxplot(WaveletDetector):
...
@@ -432,13 +432,12 @@ class Boxplot(WaveletDetector):
class
Theoretical
(
WaveletDetector
):
class
Theoretical
(
WaveletDetector
):
"""
Class for troubled-cell detection based on the projection averages and
"""
Class for troubled-cell detection based on theoretical thresholding.
a cutoff factor.
Attributes
Attributes
----------
----------
cutoff_factor
: float
threshold
: float
Cutoff factor
above which a cell is considered troubled.
Threshold
above which a cell is considered troubled.
"""
"""
def
_reset
(
self
,
config
):
def
_reset
(
self
,
config
):
...
@@ -453,9 +452,10 @@ class Theoretical(WaveletDetector):
...
@@ -453,9 +452,10 @@ class Theoretical(WaveletDetector):
super
().
_reset
(
config
)
super
().
_reset
(
config
)
# Unpack necessary configurations
# Unpack necessary configurations
self
.
_
cutoff_factor
=
config
.
pop
(
'
cutoff_factor
'
,
cutoff_factor
=
config
.
pop
(
'
cutoff_factor
'
,
np
.
sqrt
(
2
)
*
self
.
_mesh
.
cell_len
)
np
.
sqrt
(
2
)
*
self
.
_mesh
.
cell_len
)
# comment to line above: or 2 or 3
self
.
_threshold
=
cutoff_factor
/
(
self
.
_mesh
.
cell_len
*
self
.
_mesh
.
num_cells
)
def
get_cells
(
self
,
projection
):
def
get_cells
(
self
,
projection
):
"""
Calculate troubled cells in a given projection.
"""
Calculate troubled cells in a given projection.
...
@@ -473,37 +473,9 @@ class Theoretical(WaveletDetector):
...
@@ -473,37 +473,9 @@ class Theoretical(WaveletDetector):
"""
"""
coeffs
=
self
.
_select_degree
(
self
.
_calculate_wavelet_coeffs
(
coeffs
=
self
.
_select_degree
(
self
.
_calculate_wavelet_coeffs
(
projection
))
projection
))
troubled_cells
=
[]
max_avg
=
np
.
sqrt
(
0.5
)
\
*
max
(
1
,
max
(
abs
(
projection
[
0
][
cell
+
1
])
for
cell
in
range
(
self
.
_mesh
.
num_cells
)))
for
cell
in
range
(
self
.
_mesh
.
num_cells
):
max_avg
=
np
.
sqrt
(
0.5
)
*
max
(
1
,
np
.
max
(
np
.
abs
(
projection
[
0
])))
if
self
.
_is_troubled_cell
(
coeffs
,
cell
,
max_avg
):
troubled_cells
=
np
.
flatnonzero
(
troubled_cells
.
append
(
cell
)
np
.
abs
(
coeffs
)
/
max_avg
>
self
.
_threshold
).
tolist
(
)
return
troubled_cells
return
troubled_cells
def
_is_troubled_cell
(
self
,
coeffs
,
cell
,
max_avg
):
"""
Checks whether a cell is troubled.
Parameters
----------
coeffs : ndarray
Matrix of multiwavelet coefficients.
cell : int
Index of cell.
max_avg : float
Maximum average of projection.
Returns
-------
bool
Flag whether cell is troubled.
"""
max_value
=
abs
(
coeffs
[
cell
])
/
max_avg
eps
=
self
.
_cutoff_factor
\
/
(
self
.
_mesh
.
cell_len
*
self
.
_mesh
.
num_cells
)
return
max_value
>
eps
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