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
3bef3da5
Commit
3bef3da5
authored
5 years ago
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Upload Limiter.py (as of March 17 2020)
parent
26a9a147
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Limiter.py
+105
-0
105 additions, 0 deletions
Limiter.py
with
105 additions
and
0 deletions
Limiter.py
0 → 100644
+
105
−
0
View file @
3bef3da5
# -*- coding: utf-8 -*-
"""
@author: Laura C. Kühle
"""
import
numpy
as
np
class
Limiter
(
object
):
def
__init__
(
self
,
config
):
pass
def
get_name
(
self
):
return
self
.
function_name
def
apply
():
pass
class
NoLimiter
(
Limiter
):
def
__init__
(
self
,
config
):
# Set name of function
self
.
function_name
=
'
NoLimiter
'
pass
def
apply
(
self
,
projection
,
cell
):
return
np
.
transpose
(
self
.
projection
)[
cell
]
class
MinMod
(
Limiter
):
def
__init__
(
self
,
config
):
# Unpack necessary parameter
self
.
erase_degree
=
config
.
pop
(
'
erase_degree
'
,
0
)
# Set name of function
self
.
function_name
=
'
MinMod
'
+
str
(
self
.
erase_degree
)
# Pop unncessary parameter
config
.
pop
(
'
cell_len
'
)
self
.
projection
=
[]
self
.
cell
=
0
pass
def
apply
(
self
,
projection
,
cell
):
self
.
projection
=
projection
self
.
cell
=
cell
self
.
_set_cell_slope
()
is_good_cell
=
self
.
_determine_modification
()
if
is_good_cell
:
return
np
.
transpose
(
self
.
projection
)[
self
.
cell
]
adapted_projection
=
np
.
transpose
(
self
.
projection
)[
self
.
cell
].
copy
()
for
i
in
range
(
len
(
adapted_projection
)):
if
(
i
>
self
.
erase_degree
):
adapted_projection
[
i
]
=
0
return
adapted_projection
def
_set_cell_slope
(
self
):
slope
=
[]
transposed_projection
=
np
.
transpose
(
self
.
projection
)
for
cell
in
range
(
len
(
transposed_projection
)):
new_entry
=
sum
(
transposed_projection
[
cell
][
degree
]
*
(
degree
+
0.5
)
**
0.5
for
degree
in
range
(
1
,
len
(
self
.
projection
)))
slope
.
append
(
new_entry
)
self
.
cell_slope
=
slope
[
self
.
cell
]
def
_determine_modification
(
self
):
forward_slope
=
(
self
.
projection
[
0
][
self
.
cell
+
1
]
-
self
.
projection
[
0
][
self
.
cell
])
*
(
0.5
**
0.5
)
backward_slope
=
(
self
.
projection
[
0
][
self
.
cell
]
-
self
.
projection
[
0
][
self
.
cell
-
1
])
*
(
0.5
**
0.5
)
if
((
forward_slope
<=
0
)
&
(
backward_slope
<=
0
)
&
(
self
.
cell_slope
<=
0
)):
return
True
if
((
forward_slope
>=
0
)
&
(
backward_slope
>=
0
)
&
(
self
.
cell_slope
>=
0
)):
return
True
return
False
class
ModifiedMinMod
(
MinMod
):
def
__init__
(
self
,
config
):
# Unpack necessary configurations
self
.
cell_len
=
config
.
pop
(
'
cell_len
'
)
self
.
erase_degree
=
config
.
pop
(
'
erase_degree
'
,
0
)
self
.
mod_factor
=
config
.
pop
(
'
mod_factor
'
,
0
)
# Set name of function
self
.
function_name
=
'
ModifiedMinMod
'
+
str
(
self
.
erase_degree
)
self
.
projection
=
[]
self
.
cell
=
0
pass
def
_determine_modification
(
self
):
if
(
abs
(
self
.
cell_slope
)
<=
self
.
mod_factor
*
self
.
cell_len
**
2
):
return
True
# former: u_tilde_entry
return
super
().
_determine_modification
()
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