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
fa3bea75
Commit
fa3bea75
authored
5 years ago
by
Peter Lünenschloß
Browse files
Options
Downloads
Patches
Plain Diff
implemented aggregation wrapper
parent
9d83127a
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
+3
-3
3 additions, 3 deletions
docs/FunctionDescriptions.md
saqc/funcs/harm_functions.py
+60
-2
60 additions, 2 deletions
saqc/funcs/harm_functions.py
with
63 additions
and
5 deletions
docs/FunctionDescriptions.md
+
3
−
3
View file @
fa3bea75
...
@@ -26,9 +26,9 @@ Main documentation of the implemented functions, their purpose and parameters an
...
@@ -26,9 +26,9 @@ Main documentation of the implemented functions, their purpose and parameters an
-
[
harmonize
](
#harmonize
)
-
[
harmonize
](
#harmonize
)
-
[
deharmonize
](
#deharmonize
)
-
[
deharmonize
](
#deharmonize
)
-
[
harmonize_shift2Grid
](
#harmonize_shift2grid
)
-
[
harmonize_shift2Grid
](
#harmonize_shift2grid
)
-
[
harmonize_
shift
2Grid
](
#harmonize_aggregate2grid
)
-
[
harmonize_
aggregate
2Grid
](
#harmonize_aggregate2grid
)
-
[
harmonize_
shift
2Grid
](
#harmonize_linear2grid
)
-
[
harmonize_
linear
2Grid
](
#harmonize_linear2grid
)
-
[
harmonize_
shift
2Grid
](
#harmonize_interpolate2grid
)
-
[
harmonize_
interpolate
2Grid
](
#harmonize_interpolate2grid
)
## range
## range
...
...
This diff is collapsed.
Click to expand it.
saqc/funcs/harm_functions.py
+
60
−
2
View file @
fa3bea75
...
@@ -829,7 +829,8 @@ def linear2Grid(data, field, flagger, freq, flag_assignment_method='nearest_agg'
...
@@ -829,7 +829,8 @@ def linear2Grid(data, field, flagger, freq, flag_assignment_method='nearest_agg'
@register
(
'
harmonize_interpolate2Grid
'
)
@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
):
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
(
return
harmonize
(
data
,
data
,
field
,
field
,
...
@@ -842,4 +843,61 @@ def interpolate2Grid(data, field, flagger, freq, interpolation_method, interpola
...
@@ -842,4 +843,61 @@ def interpolate2Grid(data, field, flagger, freq, interpolation_method, interpola
drop_flags
=
drop_flags
,
drop_flags
=
drop_flags
,
**
kwargs
)
**
kwargs
)
#def aggregate(data, field, flagger, freq_base, freq_target, agg_func, **kwargs):
\ No newline at end of file
def
aggregate
(
data
,
field
,
flagger
,
source_freq
,
target_freq
,
agg_func
=
np
.
mean
,
sample_func
=
np
.
mean
,
invalid_flags
=
None
,
max_invalid
=
np
.
inf
,
**
kwargs
):
# define the "fastest possible" aggregator
if
sample_func
is
None
:
if
max_invalid
<
np
.
inf
:
def
aggregator
(
x
):
if
x
.
isna
().
sum
()
<
max_invalid
:
return
agg_func
(
x
)
else
:
return
np
.
nan
else
:
def
aggregator
(
x
):
return
agg_func
(
x
)
else
:
dummy_resampler
=
pd
.
Series
(
np
.
nan
,
index
=
[
pd
.
Timedelta
(
'
1min
'
)]).
resample
(
'
1min
'
)
if
hasattr
(
dummy_resampler
,
sample_func
.
__name__
):
sample_func_name
=
sample_func
.
__name__
if
max_invalid
<
np
.
inf
:
def
aggregator
(
x
):
y
=
getattr
(
x
.
resample
(
source_freq
),
sample_func_name
)()
if
y
.
isna
().
sum
()
<
max_invalid
:
return
agg_func
(
y
)
else
:
return
np
.
nan
else
:
def
aggregator
(
x
):
agg_func
(
getattr
(
x
.
resample
(
source_freq
),
sample_func_name
)())
else
:
if
max_invalid
<
np
.
inf
:
def
aggregator
(
x
):
y
=
x
.
resample
(
source_freq
).
apply
(
sample_func
)
if
y
.
isna
().
sum
()
<
max_invalid
:
agg_func
(
y
)
else
:
return
np
.
nan
else
:
def
aggregator
(
x
):
return
agg_func
(
x
.
resample
(
source_freq
).
apply
(
sample_func
))
return
harmonize
(
data
,
field
,
flagger
,
target_freq
,
inter_method
=
'
bagg
'
,
reshape_method
=
'
bagg
'
,
inter_agg
=
aggregator
,
reshape_agg
=
max
,
drop_flags
=
invalid_flags
,
**
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