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
5f8acb63
Commit
5f8acb63
authored
5 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
fixed flagNext/flagPeriod +tests
parent
7db6b6e4
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/core/core.py
+11
-4
11 additions, 4 deletions
saqc/core/core.py
test/test_core.py
+2
-2
2 additions, 2 deletions
test/test_core.py
with
13 additions
and
6 deletions
saqc/core/core.py
+
11
−
4
View file @
5f8acb63
...
...
@@ -12,10 +12,18 @@ from ..lib.tools import setup
def
flagWindow
(
old
,
new
,
field
,
flagger
,
direction
=
'
fw
'
,
window
=
0
,
**
kwargs
)
->
pd
.
Series
:
if
window
==
0
or
window
==
''
:
return
new
fw
,
bw
=
False
,
False
mask
=
flagger
.
getFlags
(
old
[
field
])
!=
flagger
.
getFlags
(
new
[
field
])
f
=
flagger
.
isFlagged
(
new
[
field
])
&
mask
if
not
mask
.
any
():
# nothing was flagged, so nothing need to be flagged additional
return
new
if
isinstance
(
window
,
int
):
x
=
f
.
rolling
(
window
=
window
+
1
).
sum
()
if
direction
in
[
'
fw
'
,
'
both
'
]:
...
...
@@ -29,8 +37,7 @@ def flagWindow(old, new, field, flagger, direction='fw', window=0, **kwargs) ->
fw
=
f
.
rolling
(
window
=
window
,
closed
=
'
both
'
).
sum
().
astype
(
bool
)
fmask
=
bw
|
fw
new
.
loc
[
fmask
,
field
]
=
flagger
.
setFlag
(
new
.
loc
[
fmask
,
field
],
**
kwargs
)
return
new
return
flagger
.
setFlags
(
new
,
field
,
fmask
,
**
kwargs
)
def
flagPeriod
(
old
,
new
,
field
,
flagger
,
flag_period
=
0
,
**
kwargs
)
->
pd
.
Series
:
...
...
@@ -129,12 +136,12 @@ def runner(metafname, flagger, data, flags=None, nodata=np.nan):
# flag a timespan after the condition is met
if
Params
.
FLAGPERIOD
in
flag_params
:
periodflags
=
flagPeriod
(
fchunk
,
ffchunk
,
varname
,
flagger
,
func_name
,
**
flag_params
)
periodflags
=
flagPeriod
(
fchunk
,
ffchunk
,
varname
,
flagger
,
func_name
=
func_name
,
**
flag_params
)
ffchunk
=
assignTypeSafe
(
ffchunk
,
varname
,
periodflags
)
# flag a certain amount of values after condition is met
if
Params
.
FLAGVALUES
in
flag_params
:
valueflags
=
flagNext
(
fchunk
,
ffchunk
,
varname
,
flagger
,
func_name
,
**
flag_params
)
valueflags
=
flagNext
(
fchunk
,
ffchunk
,
varname
,
flagger
,
func_name
=
func_name
,
**
flag_params
)
ffchunk
=
assignTypeSafe
(
ffchunk
,
varname
,
valueflags
)
if
flag_params
.
get
(
Params
.
PLOT
,
False
):
...
...
This diff is collapsed.
Click to expand it.
test/test_core.py
+
2
−
2
View file @
5f8acb63
...
...
@@ -166,7 +166,7 @@ def test_flagNext(flagger):
idx
=
[
0
,
1
,
2
]
dtidx
=
data
.
index
[
idx
]
flags
.
loc
[
dtidx
,
var1
]
=
flagger
.
setFlag
(
flags
.
loc
[
dtidx
,
var1
]
)
flags
=
flagger
.
setFlag
s
(
flags
,
var1
,
dtidx
)
n
=
4
fflags
=
flagNext
(
orig
,
flags
,
var1
,
flagger
,
flag_values
=
4
)
...
...
@@ -192,7 +192,7 @@ def test_flagPeriod(flagger):
idx
=
[
0
,
1
,
2
]
dtidx
=
data
.
index
[
idx
]
flags
.
loc
[
dtidx
,
var1
]
=
flagger
.
setFlag
(
flags
.
loc
[
dtidx
,
var1
]
)
flags
=
flagger
.
setFlag
s
(
flags
,
var1
,
dtidx
)
period
=
'
4h
'
fflags
=
flagPeriod
(
orig
,
flags
,
var1
,
flagger
,
flag_period
=
period
)
...
...
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