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
06fe74f1
Commit
06fe74f1
authored
5 years ago
by
David Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
provied the DataFrame combination of BaseFlagger.setFlagger logic as
a sparate function
parent
b8076303
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
saqc/lib/tools.py
+23
-6
23 additions, 6 deletions
saqc/lib/tools.py
with
23 additions
and
6 deletions
saqc/lib/tools.py
+
23
−
6
View file @
06fe74f1
...
...
@@ -90,6 +90,25 @@ def inferFrequency(data):
return
pd
.
tseries
.
frequencies
.
to_offset
(
pd
.
infer_freq
(
data
.
index
))
def
combineDataFrames
(
left
,
right
,
fill_value
=
np
.
nan
):
"""
Combine the given DataFrames
'
left
'
and
'
right
'
such that, the
output is union of the indices and the columns of both. In case
of duplicated values,
'
left
'
is overwritten by
'
right
'
"""
combined
=
left
.
reindex
(
index
=
left
.
index
.
union
(
right
.
index
),
columns
=
left
.
columns
.
union
(
right
.
columns
,
sort
=
False
),
fill_value
=
fill_value
)
for
key
,
values
in
right
.
iteritems
():
combined
.
loc
[
right
.
index
,
key
]
=
values
return
combined
def
retrieveTrustworthyOriginal
(
data
,
field
,
flagger
=
None
,
level
=
None
):
"""
Columns of data passed to the saqc runner may not be sampled to its original sampling rate - thus
...
...
@@ -120,14 +139,12 @@ def retrieveTrustworthyOriginal(data, field, flagger=None, level=None):
"""
dataseries
=
data
[
field
]
# import ipdb; ipdb.set_trace()
if
flagger
is
not
None
:
if
level
is
not
None
:
data_use
=
flagger
.
isFlagged
(
field
,
flag
=
level
,
comparator
=
"
<=
"
)
else
:
data_use
=
flagger
.
isFlagged
(
field
,
flag
=
flagger
.
GOOD
,
comparator
=
"
<=
"
)
mask
=
flagger
.
isFlagged
(
field
,
flag
=
level
or
flagger
.
GOOD
,
comparator
=
"
<=
"
)
# drop all flags that are suspicious or worse
dataseries
=
dataseries
[
data_use
]
dataseries
=
dataseries
[
mask
]
# drop the nan values that may result from any preceeding upsampling of the measurements:
dataseries
=
dataseries
.
dropna
()
...
...
@@ -137,7 +154,7 @@ def retrieveTrustworthyOriginal(data, field, flagger=None, level=None):
# estimate original data sampling frequencie
# (the original series sampling rate may not match data-input sample rate):
seconds_rate
=
(
dataseries
.
index
-
dataseries
.
index
.
shift
(
-
1
))
.
to_series
().
min
().
seconds
seconds_rate
=
dataseries
.
index
.
to_series
().
diff
().
min
().
seconds
data_rate
=
pd
.
tseries
.
frequencies
.
to_offset
(
str
(
seconds_rate
)
+
'
s
'
)
return
dataseries
.
asfreq
(
data_rate
),
data_rate
...
...
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