Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SaQC
Manage
Activity
Members
Labels
Plan
Issues
35
Issue boards
Milestones
Wiki
Code
Merge requests
7
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
ffac6189
Commit
ffac6189
authored
2 years ago
by
David Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
Add option to not overwrite existing flags to concatFlags
parent
714aac54
No related branches found
Branches containing commit
No related tags found
Tags containing commit
4 merge requests
!685
Release 2.4
,
!684
Release 2.4
,
!578
Add option to not overwrite existing flags to concatFlags
,
!567
Release 2.2.1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
saqc/funcs/resampling.py
+16
-5
16 additions, 5 deletions
saqc/funcs/resampling.py
tests/funcs/test_resampling.py
+52
-0
52 additions, 0 deletions
tests/funcs/test_resampling.py
with
69 additions
and
5 deletions
CHANGELOG.md
+
1
−
0
View file @
ffac6189
...
...
@@ -9,6 +9,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
## Unreleased
[
List of commits
](
https://git.ufz.de/rdm-software/saqc/-/compare/v2.2.1...develop
)
### Added
-
add option to not overwrite existing flags to
`concatFlags`
### Changed
### Removed
### Fixed
...
...
This diff is collapsed.
Click to expand it.
saqc/funcs/resampling.py
+
16
−
5
View file @
ffac6189
...
...
@@ -334,9 +334,10 @@ class ResamplingMixin:
"
inverse_interpolation
"
,
"
match
"
,
]
=
"
match
"
,
freq
:
Optional
[
str
]
=
None
,
drop
:
Optional
[
bool
]
=
False
,
squeeze
:
Optional
[
bool
]
=
False
,
freq
:
str
|
None
=
None
,
drop
:
bool
=
False
,
squeeze
:
bool
=
False
,
overwrite
:
bool
=
True
,
**
kwargs
,
)
->
"
SaQC
"
:
"""
...
...
@@ -394,6 +395,10 @@ class ResamplingMixin:
If set to `True`, the appended flags frame will be squeezed - resulting in function specific flags informations
getting lost.
overwrite: bool, default True
If set to True, the newly appended flags will overwrite exsiting flags. This might result in a loss of previous
flagging information.
Returns
-------
saqc.SaQC
...
...
@@ -449,13 +454,19 @@ class ResamplingMixin:
raise
ValueError
(
f
"
unknown method
{
method
}
"
)
history
=
self
.
_flags
.
history
[
field
].
apply
(
dummy
.
index
,
func
,
func_kws
)
if
overwrite
is
False
:
mask
=
_isflagged
(
self
.
_flags
[
target
],
thresh
=
kwargs
[
"
dfilter
"
])
history
.
hist
[
mask
]
=
np
.
nan
if
squeeze
:
history
=
history
.
squeeze
(
raw
=
True
)
meta
=
{
"
func
"
:
f
"
concatFlags
(
{
field
}
)
"
,
"
args
"
:
(
field
,
target
),
"
func
"
:
f
"
concatFlags
"
,
"
args
"
:
(
field
,),
"
kwargs
"
:
{
"
target
"
:
target
,
"
method
"
:
method
,
"
freq
"
:
freq
,
"
drop
"
:
drop
,
...
...
This diff is collapsed.
Click to expand it.
tests/funcs/test_
harm_funcs
.py
→
tests/funcs/test_
resampling
.py
+
52
−
0
View file @
ffac6189
...
...
@@ -375,3 +375,55 @@ def test_harmSingleVarInterpolationShift(data, params, expected):
qc
=
qc
.
dropField
(
h_field
)
assert
qc
.
data
[
field
].
equals
(
pre_data
[
field
])
assert
qc
.
flags
[
field
].
equals
(
pre_flags
[
field
])
def
test_concatFlags
():
index
=
pd
.
to_datetime
(
[
"
2020-01-01 00:00
"
,
"
2020-01-01 00:10
"
,
"
2020-01-01 00:30
"
,
"
2020-01-01 00:40
"
,
"
2020-01-01 01:00
"
,
]
)
df
=
pd
.
DataFrame
(
data
=
{
"
a
"
:
[
1
,
2
,
5
,
4
,
3
,
]
},
index
=
index
,
)
qc
=
SaQC
(
df
)
qc
=
qc
.
flagRange
(
field
=
"
a
"
,
max
=
4
)
# branch out to another variable
qc
=
qc
.
flagRange
(
field
=
"
a
"
,
target
=
"
b
"
,
max
=
3
)
# bring the flags back again
qc_overwrite
=
qc
.
concatFlags
(
"
b
"
,
target
=
"
a
"
,
overwrite
=
True
,
squeeze
=
True
)
hist_overwrite
=
qc_overwrite
.
_flags
.
history
[
"
a
"
].
hist
.
astype
(
float
)
assert
hist_overwrite
[
0
].
equals
(
pd
.
Series
([
np
.
nan
,
np
.
nan
,
255.0
,
np
.
nan
,
np
.
nan
],
index
=
index
)
)
assert
hist_overwrite
[
1
].
equals
(
pd
.
Series
([
np
.
nan
,
np
.
nan
,
255.0
,
255.0
,
np
.
nan
],
index
=
index
)
)
# bring the flags back again
qc_respect
=
qc
.
concatFlags
(
"
b
"
,
target
=
"
a
"
,
overwrite
=
False
,
squeeze
=
True
)
hist_respect
=
qc_respect
.
_flags
.
history
[
"
a
"
].
hist
.
astype
(
float
)
assert
hist_respect
[
0
].
equals
(
pd
.
Series
([
np
.
nan
,
np
.
nan
,
255.0
,
np
.
nan
,
np
.
nan
],
index
=
index
)
)
assert
hist_respect
[
1
].
equals
(
pd
.
Series
([
np
.
nan
,
np
.
nan
,
np
.
nan
,
255.0
,
np
.
nan
],
index
=
index
)
)
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