Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SaQC
Manage
Activity
Members
Labels
Plan
Issues
36
Issue boards
Milestones
Wiki
Code
Merge requests
8
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rdm-software
SaQC
Commits
57003137
Commit
57003137
authored
4 years ago
by
Peter Lünenschloß
Browse files
Options
Downloads
Patches
Plain Diff
flagBasic fixed ... again
parent
7d44640b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!193
Release 1.4
,
!188
Release 1.4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
saqc/funcs/spikes_detection.py
+12
-23
12 additions, 23 deletions
saqc/funcs/spikes_detection.py
with
12 additions
and
23 deletions
saqc/funcs/spikes_detection.py
+
12
−
23
View file @
57003137
...
...
@@ -962,30 +962,19 @@ def spikes_flagBasic(data, field, flagger, thresh, tolerance, window, numba_kick
# correct the result: only those values define plateaus, that do not have
# values at their left starting point, that belong to other plateaus themself:
def
correctResult
(
result
):
for
k
in
range
(
len
(
result
)):
def
calcResult
(
result
):
var_num
=
result
.
shape
[
0
]
flag_scopes
=
np
.
zeros
(
var_num
,
dtype
=
bool
)
for
k
in
range
(
var_num
):
if
result
[
k
]
>
0
:
check_val
=
result
[
int
(
k
-
result
[
k
])]
if
check_val
>
0
:
result
[
k
]
=
np
.
nan
return
result
result
=
correctResult
(
result
)
group_col
=
np
.
nancumsum
(
result
)
group_frame
=
pd
.
DataFrame
({
'
group_col
'
:
group_col
[:
-
1
],
'
diff_col
'
:
np
.
diff
(
group_col
).
astype
(
int
)},
index
=
result
.
index
[:
-
1
])
groups
=
group_frame
.
groupby
(
'
group_col
'
)
def
gFunc
(
x
):
r
=
np
.
zeros
(
shape
=
x
.
shape
[
0
],
dtype
=
np
.
bool
)
i_val
=
-
x
[
-
1
]
if
i_val
<
0
:
r
[
i_val
:]
=
True
return
r
to_flag
=
groups
[
'
diff_col
'
].
transform
(
gFunc
)
flagger
=
flagger
.
setFlags
(
field
,
to_flag
[
to_flag
==
True
].
index
,
**
kwargs
)
# validity check: plateuas start isnt another plateaus end:
if
not
flag_scopes
[
int
(
k
-
result
[
k
]
-
1
)]:
flag_scopes
[
int
(
k
-
result
[
k
]):
int
(
k
)]
=
True
return
pd
.
Series
(
flag_scopes
,
index
=
result
.
index
)
cresult
=
calcResult
(
result
)
cresult
=
cresult
[
cresult
]
flagger
=
flagger
.
setFlags
(
field
,
cresult
,
**
kwargs
)
return
data
,
flagger
...
...
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