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
512a6c1c
Commit
512a6c1c
authored
4 years ago
by
Peter Lünenschloß
Browse files
Options
Downloads
Patches
Plain Diff
added support to roll with frequencie defined windows and center=True to customRolling
parent
08586229
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!193
Release 1.4
,
!188
Release 1.4
,
!138
WIP: Detect and reset offset
Pipeline
#8392
passed with stage
in 6 minutes and 29 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
saqc/funcs/functions.py
+1
-0
1 addition, 0 deletions
saqc/funcs/functions.py
saqc/lib/tools.py
+16
-5
16 additions, 5 deletions
saqc/lib/tools.py
with
17 additions
and
5 deletions
saqc/funcs/functions.py
+
1
−
0
View file @
512a6c1c
...
@@ -1111,6 +1111,7 @@ def flagChangePoints(data, field, flagger, stat_func, thresh_func, bwd_window, m
...
@@ -1111,6 +1111,7 @@ def flagChangePoints(data, field, flagger, stat_func, thresh_func, bwd_window, m
indexer
.
win_points
=
np
.
array
([
True
]
*
var_len
)
indexer
.
win_points
=
np
.
array
([
True
]
*
var_len
)
indexer
.
window_size
=
int
(
pd
.
Timedelta
(
bwd_window
).
total_seconds
()
*
10
**
9
)
indexer
.
window_size
=
int
(
pd
.
Timedelta
(
bwd_window
).
total_seconds
()
*
10
**
9
)
indexer
.
forward
=
False
indexer
.
forward
=
False
indexer
.
center
=
False
bwd_start
,
bwd_end
=
indexer
.
get_window_bounds
(
var_len
,
min_periods_bwd
,
center
,
closed
)
bwd_start
,
bwd_end
=
indexer
.
get_window_bounds
(
var_len
,
min_periods_bwd
,
center
,
closed
)
indexer
.
window_size
=
int
(
pd
.
Timedelta
(
fwd_window
).
total_seconds
()
*
10
**
9
)
indexer
.
window_size
=
int
(
pd
.
Timedelta
(
fwd_window
).
total_seconds
()
*
10
**
9
)
...
...
This diff is collapsed.
Click to expand it.
saqc/lib/tools.py
+
16
−
5
View file @
512a6c1c
...
@@ -406,8 +406,14 @@ class FreqIndexer(BaseIndexer):
...
@@ -406,8 +406,14 @@ class FreqIndexer(BaseIndexer):
self
.
index_array
[::
i_dir
])
self
.
index_array
[::
i_dir
])
if
self
.
forward
:
if
self
.
forward
:
start
,
end
=
(
num_values
-
end
)[::
-
1
],
(
num_values
-
start
)[::
-
1
]
start
,
end
=
(
num_values
-
end
)[::
-
1
],
(
num_values
-
start
)[::
-
1
]
end
[
~
self
.
win_points
]
=
0
if
self
.
center
:
start
[
~
self
.
win_points
]
=
0
end
=
(
num_values
-
start
)[::
-
1
]
end
=
np
.
roll
(
end
,
-
1
)
end
[
-
1
]
=
num_values
-
1
if
self
.
win_points
is
not
None
:
end
[
~
self
.
win_points
]
=
0
start
[
~
self
.
win_points
]
=
0
return
start
,
end
return
start
,
end
...
@@ -426,8 +432,9 @@ class PeriodsIndexer(BaseIndexer):
...
@@ -426,8 +432,9 @@ class PeriodsIndexer(BaseIndexer):
end_s
=
np
.
arange
(
self
.
window_size
,
dtype
=
"
int64
"
)
+
1
end_s
=
np
.
arange
(
self
.
window_size
,
dtype
=
"
int64
"
)
+
1
end_e
=
start_e
+
self
.
window_size
end_e
=
start_e
+
self
.
window_size
end
=
np
.
concatenate
([
end_s
,
end_e
])[:
num_values
]
end
=
np
.
concatenate
([
end_s
,
end_e
])[:
num_values
]
start
[
~
self
.
win_points
]
=
0
if
self
.
win_points
is
not
None
:
end
[
~
self
.
win_points
]
=
0
start
[
~
self
.
win_points
]
=
0
end
[
~
self
.
win_points
]
=
0
return
start
,
end
return
start
,
end
...
@@ -446,11 +453,12 @@ def customRolling(to_roll, winsz, func, roll_mask, min_periods=1, center=False,
...
@@ -446,11 +453,12 @@ def customRolling(to_roll, winsz, func, roll_mask, min_periods=1, center=False,
func : Callable
func : Callable
Function to be rolled with. If the funcname matches a .rolling attribute,
Function to be rolled with. If the funcname matches a .rolling attribute,
the associated method of .rolling will be used instead of .apply(func) (=faster)
the associated method of .rolling will be used instead of .apply(func) (=faster)
roll_mask : numpy.array[bool]
roll_mask :
{
numpy.array[bool]
, None}
A mask, indicating the rolling windows, `func` shall be applied on.
A mask, indicating the rolling windows, `func` shall be applied on.
Has to be of same length as `to_roll`.
Has to be of same length as `to_roll`.
roll_mask[i] = False indicates, that the window with right end point to_roll.index[i] shall
roll_mask[i] = False indicates, that the window with right end point to_roll.index[i] shall
be skipped.
be skipped.
Pass None if you want values to be masked.
min_periods : int, default 1
min_periods : int, default 1
Gets passed on to the min_periods parameter of pandas.Rolling.
Gets passed on to the min_periods parameter of pandas.Rolling.
(Note, that rolling with freq string defined window size and `min_periods`=None,
(Note, that rolling with freq string defined window size and `min_periods`=None,
...
@@ -467,6 +475,9 @@ def customRolling(to_roll, winsz, func, roll_mask, min_periods=1, center=False,
...
@@ -467,6 +475,9 @@ def customRolling(to_roll, winsz, func, roll_mask, min_periods=1, center=False,
forward : bool, default False
forward : bool, default False
If true, roll with forward facing windows. (not yet implemented for
If true, roll with forward facing windows. (not yet implemented for
integer defined windows.)
integer defined windows.)
center : bool, default False
If true, set the label to the center of the rolling window. Although available
for windows defined by sample rates! (yeah!)
Returns
Returns
-------
-------
...
...
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