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
f909e3e5
Commit
f909e3e5
authored
5 years ago
by
Peter Lünenschloß
Browse files
Options
Downloads
Patches
Plain Diff
minor bugfix/ handy harm wrappers introduced + tested
parent
50e2ca0a
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
saqc/funcs/harm_functions.py
+57
-1
57 additions, 1 deletion
saqc/funcs/harm_functions.py
test/funcs/test_harm_funcs.py
+18
-1
18 additions, 1 deletion
test/funcs/test_harm_funcs.py
with
75 additions
and
2 deletions
saqc/funcs/harm_functions.py
+
57
−
1
View file @
f909e3e5
...
...
@@ -608,7 +608,6 @@ def _reshapeFlags(
# NOTE: breaks for non categorical flaggers
.
apply
(
lambda
x
:
agg_method
(
x
)
if
not
x
.
empty
else
missing_flag
)
.
astype
(
flagger
.
dtype
)
.
to_frame
(
name
=
field
)
)
if
method
==
"
nearest_agg
"
:
...
...
@@ -776,3 +775,60 @@ def _toMerged(
return
flagMissing
(
data
,
fieldname
,
flagger
.
initFlags
(
flags
=
flags
),
nodata
=
np
.
nan
)
@register
(
'
harmonize_shift2Grid
'
)
def
shift2Grid
(
data
,
field
,
flagger
,
freq
,
shift_method
=
'
nearest_shift
'
,
drop_flags
=
None
,
**
kwargs
):
return
harmonize
(
data
,
field
,
flagger
,
freq
,
inter_method
=
shift_method
,
reshape_method
=
shift_method
,
drop_flags
=
drop_flags
,
**
kwargs
)
@register
(
'
harmonize_aggregate2Grid
'
)
def
aggregate2Grid
(
data
,
field
,
flagger
,
freq
,
agg_func
,
agg_method
=
'
nearest_agg
'
,
flag_agg_func
=
max
,
drop_flags
=
None
,
**
kwargs
):
return
harmonize
(
data
,
field
,
flagger
,
freq
,
inter_method
=
agg_method
,
reshape_method
=
agg_method
,
inter_agg
=
agg_func
,
reshape_agg
=
flag_agg_func
,
drop_flags
=
drop_flags
,
**
kwargs
)
@register
(
'
harmonize_linear2Grid
'
)
def
linear2Grid
(
data
,
field
,
flagger
,
freq
,
flag_assignment_method
=
'
nearest_agg
'
,
flag_agg_func
=
max
,
drop_flags
=
None
,
**
kwargs
):
return
harmonize
(
data
,
field
,
flagger
,
freq
,
inter_method
=
'
time
'
,
reshape_method
=
flag_assignment_method
,
reshape_agg
=
flag_agg_func
,
drop_flags
=
drop_flags
,
**
kwargs
)
@register
(
'
harmonize_interpolate2Grid
'
)
def
interpolate2Grid
(
data
,
field
,
flagger
,
freq
,
interpolation_method
,
interpolation_order
=
1
,
flag_assignment_method
=
'
nearest_agg
'
,
flag_agg_func
=
max
,
drop_flags
=
None
,
**
kwargs
):
return
harmonize
(
data
,
field
,
flagger
,
freq
,
inter_method
=
interpolation_method
,
inter_order
=
interpolation_order
,
reshape_method
=
flag_assignment_method
,
reshape_agg
=
flag_agg_func
,
drop_flags
=
drop_flags
,
**
kwargs
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
test/funcs/test_harm_funcs.py
+
18
−
1
View file @
f909e3e5
...
...
@@ -15,6 +15,10 @@ from saqc.funcs.harm_functions import (
_interpolateGrid
,
_insertGrid
,
_outsortCrap
,
linear2Grid
,
interpolate2Grid
,
shift2Grid
,
aggregate2Grid
)
...
...
@@ -287,7 +291,7 @@ def test_multivariatHarmonization(multi_data, flagger, shift_comment):
def
test_gridInterpolation
(
data
,
method
):
freq
=
"
15min
"
data
=
(
data
*
np
.
sin
(
data
)).
append
(
data
.
shift
(
1
,
"
2h
"
)).
shift
(
1
,
"
3s
"
)
# we are just testing if the interolation gets passed to the series without causing an error:
# we are just testing if the inter
p
olation gets passed to the series without causing an error:
_interpolateGrid
(
data
,
freq
,
method
,
order
=
1
,
agg_method
=
sum
,
downcast_interpolation
=
True
)
...
...
@@ -322,3 +326,16 @@ def test_outsortCrap(data, flagger):
data
,
field
,
flagger
,
drop_flags
=
[
flagger
.
BAD
,
flagger
.
GOOD
],
return_drops
=
True
,
)
assert
f_drop
.
index
.
sort_values
().
equals
(
drop_index
.
sort_values
())
@pytest.mark.parametrize
(
"
flagger
"
,
TESTFLAGGER
)
def
test_wrapper
(
data
,
flagger
):
# we are only testing, whether the wrappers do pass processing:
field
=
data
.
columns
[
0
]
freq
=
'
15min
'
flagger
=
flagger
.
initFlags
(
data
)
linear2Grid
(
data
,
field
,
flagger
,
freq
,
flag_assignment_method
=
'
nearest_agg
'
,
flag_agg_func
=
max
,
drop_flags
=
None
)
aggregate2Grid
(
data
,
field
,
flagger
,
freq
,
agg_func
=
sum
,
agg_method
=
'
nearest_agg
'
,
flag_agg_func
=
max
,
drop_flags
=
None
)
shift2Grid
(
data
,
field
,
flagger
,
freq
,
shift_method
=
'
nearest_shift
'
,
drop_flags
=
None
)
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