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
Admin message
UFZ GitLab and Mattermost will be
OFFLINE
on
March 27
from
8:00pm
to
10pm
due to a system migration!
Show more breadcrumbs
rdm-software
SaQC
Commits
f4186b5c
Commit
f4186b5c
authored
5 years ago
by
David Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
removed frequency restriction from mad
parent
b53ed0d2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/FunctionDescriptions.md
+8
-11
8 additions, 11 deletions
docs/FunctionDescriptions.md
saqc/funcs/spike_detection.py
+4
-11
4 additions, 11 deletions
saqc/funcs/spike_detection.py
with
12 additions
and
22 deletions
docs/FunctionDescriptions.md
+
8
−
11
View file @
f4186b5c
...
@@ -11,7 +11,7 @@ Main documentation of the implemented functions, their purpose and parameters an
...
@@ -11,7 +11,7 @@ Main documentation of the implemented functions, their purpose and parameters an
-
[
clear
](
#clear
)
-
[
clear
](
#clear
)
-
[
force
](
#force
)
-
[
force
](
#force
)
-
[
sliding_outlier
](
#sliding_outlier
)
-
[
sliding_outlier
](
#sliding_outlier
)
-
[
mad
](
#m
ad
)
-
[
spikes_simpleMad
](
#spikes_simpleM
ad
)
-
[
spikes_Basic
](
#spikes_basic
)
-
[
spikes_Basic
](
#spikes_basic
)
-
[
Spikes_SpektrumBased
](
#spikes_spektrumbased
)
-
[
Spikes_SpektrumBased
](
#spikes_spektrumbased
)
-
[
constant
](
#constant
)
-
[
constant
](
#constant
)
...
@@ -188,22 +188,19 @@ with $` r, M, mad, z `$: data, data median, data median absolute deviation, `z`.
...
@@ -188,22 +188,19 @@ with $` r, M, mad, z `$: data, data median, data median absolute deviation, `z`.
See also:
See also:
[1] https://www.itl.nist.gov/div898/handbook/eda/section3/eda35h.htm
[1] https://www.itl.nist.gov/div898/handbook/eda/section3/eda35h.htm
##
m
ad
##
spikes_simpleM
ad
Flag outlier by simple median absolute deviation test.
Flag outlier by simple median absolute deviation test.
```
```
m
ad(length, z=3.5
, freq=None
)
spikes_simpleM
ad(length, z=3.5)
```
```
| parameter | data type | default value | description |
| parameter | data type | default value | description |
| --------- | ----------- | ---- | ----------- |
| --------- | ----------- | ---- | ----------- |
| length | offset-string |
`"1h"`
| size of the sliding window, where the modified Z-score is applied on |
| winsz | offset-string or int |
`"1h"`
| size of the sliding window, where the modified Z-score is applied on |
| z | float |
`3.5`
| z-parameter the modified Z-score |
| z | float |
`3.5`
| z-parameter the modified Z-score |
| freq | |
`None`
| The frequency the data have |
Parameter note: If freq is omitted, it is tried to infer the correct frequency. This is not fail save (!), because
if no frequency can be found a error is thrown, but even worse, also a wrong frequency could be assumed.
The
*modified Z-score*
[1] is used to detect outlier.
The
*modified Z-score*
[1] is used to detect outlier.
All values are flagged as outlier, if in any slice of thw sliding window, a value fulfill:
All values are flagged as outlier, if in any slice of thw sliding window, a value fulfill:
...
@@ -997,4 +994,4 @@ Interpolation of an inserted equidistant frequency grid of sampling rate `freq`.
...
@@ -997,4 +994,4 @@ Interpolation of an inserted equidistant frequency grid of sampling rate `freq`.
, and the result gets assigned to the next grid point.
, and the result gets assigned to the next grid point.
* `
"nearest_agg"
`: all flags in the range (+/- freq/2) of a grid point get
* `
"nearest_agg"
`: all flags in the range (+/- freq/2) of a grid point get
aggregated with the function passed to `
agg_func
`
and assigned to it.
aggregated with the function passed to `
agg_func
`
and assigned to it.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
saqc/funcs/spike_detection.py
+
4
−
11
View file @
f4186b5c
...
@@ -144,7 +144,7 @@ def flagSpikes_slidingZscore(
...
@@ -144,7 +144,7 @@ def flagSpikes_slidingZscore(
@register
(
"
spikes_simpleMad
"
)
@register
(
"
spikes_simpleMad
"
)
def
flagSpikes_simpleMad
(
data
,
field
,
flagger
,
length
,
z
=
3.5
,
freq
=
None
,
**
kwargs
):
def
flagSpikes_simpleMad
(
data
,
field
,
flagger
,
winsz
,
z
=
3.5
,
**
kwargs
):
"""
The function represents an implementation of the modyfied Z-score outlier detection method, as introduced here:
"""
The function represents an implementation of the modyfied Z-score outlier detection method, as introduced here:
[1] https://www.itl.nist.gov/div898/handbook/eda/section3/eda35h.htm
[1] https://www.itl.nist.gov/div898/handbook/eda/section3/eda35h.htm
...
@@ -156,21 +156,14 @@ def flagSpikes_simpleMad(data, field, flagger, length, z=3.5, freq=None, **kwarg
...
@@ -156,21 +156,14 @@ def flagSpikes_simpleMad(data, field, flagger, length, z=3.5, freq=None, **kwarg
time raster with seconds precision.
time raster with seconds precision.
:param field: Fieldname of the Soil moisture measurements field in data.
:param field: Fieldname of the Soil moisture measurements field in data.
:param flagger: A flagger - object. (saqc.flagger.X)
:param flagger: A flagger - object. (saqc.flagger.X)
:param
length
: Offset String. Denoting the windows size that that th
"
Z-scored
"
values have to lie in.
:param
winsz
: Offset String. Denoting the windows size that that th
"
Z-scored
"
values have to lie in.
:param z: Float. The value the Z-score is tested against. Defaulting to 3.5 (Recommendation of [1])
:param z: Float. The value the Z-score is tested against. Defaulting to 3.5 (Recommendation of [1])
:param freq: Frequencie.
"""
"""
d
=
data
[
field
].
copy
()
d
=
data
[
field
].
copy
()
freq
=
inferFrequency
(
d
)
if
freq
is
None
else
freq
median
=
d
.
rolling
(
window
=
winsz
,
closed
=
"
both
"
).
median
()
if
freq
is
None
:
raise
ValueError
(
"
freqency cannot inferred, provide `freq` as a param to mad().
"
)
winsz
=
int
(
pd
.
to_timedelta
(
length
)
/
freq
)
median
=
d
.
rolling
(
window
=
winsz
,
center
=
True
,
closed
=
"
both
"
).
median
()
diff
=
abs
(
d
-
median
)
diff
=
abs
(
d
-
median
)
mad
=
diff
.
rolling
(
window
=
winsz
,
center
=
True
,
closed
=
"
both
"
).
median
()
mad
=
diff
.
rolling
(
window
=
winsz
,
closed
=
"
both
"
).
median
()
mask
=
(
mad
>
0
)
&
(
0.6745
*
diff
>
z
*
mad
)
mask
=
(
mad
>
0
)
&
(
0.6745
*
diff
>
z
*
mad
)
flagger
=
flagger
.
setFlags
(
field
,
mask
,
**
kwargs
)
flagger
=
flagger
.
setFlags
(
field
,
mask
,
**
kwargs
)
...
...
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