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
62ba32a6
Commit
62ba32a6
authored
4 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
fixed to_mask usage
parent
52f6ae4c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!231
new Flagger and Stuff
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
saqc/funcs/interpolation.py
+13
-15
13 additions, 15 deletions
saqc/funcs/interpolation.py
saqc/funcs/resampling.py
+4
-18
4 additions, 18 deletions
saqc/funcs/resampling.py
with
17 additions
and
33 deletions
saqc/funcs/interpolation.py
+
13
−
15
View file @
62ba32a6
...
...
@@ -101,7 +101,6 @@ def interpolateInvalid(
flag
:
float
=
UNFLAGGED
,
**
kwargs
)
->
Tuple
[
DictOfSeries
,
Flagger
]:
"""
Function to interpolate nan values in the data.
...
...
@@ -185,15 +184,15 @@ def interpolateIndex(
field
:
str
,
flagger
:
Flagger
,
freq
:
str
,
method
:
Literal
[
"
linear
"
,
"
time
"
,
"
nearest
"
,
"
zero
"
,
"
slinear
"
,
"
quadratic
"
,
"
cubic
"
,
"
spline
"
,
"
barycentric
"
,
"
polynomial
"
,
"
krogh
"
,
"
piecewise_polynomial
"
,
"
spline
"
,
"
pchip
"
,
"
akima
"
],
inter_order
:
int
=
2
,
downgrade_interpolation
:
bool
=
False
,
inter_limit
:
int
=
2
,
to_mask
:
Optional
[
Union
[
Any
,
Sequence
[
Any
]]]
=
BAD
,
method
:
Literal
[
"
linear
"
,
"
time
"
,
"
nearest
"
,
"
zero
"
,
"
slinear
"
,
"
quadratic
"
,
"
cubic
"
,
"
spline
"
,
"
barycentric
"
,
"
polynomial
"
,
"
krogh
"
,
"
piecewise_polynomial
"
,
"
spline
"
,
"
pchip
"
,
"
akima
"
],
inter_order
:
int
=
2
,
downgrade_interpolation
:
bool
=
False
,
inter_limit
:
int
=
2
,
**
kwargs
)
->
Tuple
[
DictOfSeries
,
Flagger
]:
"""
Function to interpolate the data at regular (equidistant) timestamps (or Grid points).
...
...
@@ -244,19 +243,18 @@ def interpolateIndex(
The flagger object, holding flags and additional Informations related to `data`.
Flags values and shape may have changed relatively to the flagger input.
"""
if
data
[
field
].
empty
:
return
data
,
flagger
if
to_mask
is
None
:
to_mask
=
BAD
datcol
=
data
[
field
]
datcol
=
data
[
field
].
copy
()
flagscol
=
flagger
[
field
]
if
datcol
.
empty
:
return
data
,
flagger
start
,
end
=
datcol
.
index
[
0
].
floor
(
freq
),
datcol
.
index
[
-
1
].
ceil
(
freq
)
grid_index
=
pd
.
date_range
(
start
=
start
,
end
=
end
,
freq
=
freq
,
name
=
datcol
.
index
.
name
)
datcol
=
datcol
.
copy
()
# always injected by register
to_mask
=
kwargs
[
'
to_mask
'
]
datcol
.
drop
(
flagscol
[
flagscol
>=
to_mask
].
index
,
inplace
=
True
)
datcol
.
dropna
(
inplace
=
True
)
dat_index
=
datcol
.
index
...
...
This diff is collapsed.
Click to expand it.
saqc/funcs/resampling.py
+
4
−
18
View file @
62ba32a6
...
...
@@ -23,7 +23,6 @@ from saqc.lib.rolling import customRoller
logger
=
logging
.
getLogger
(
"
SaQC
"
)
METHOD2ARGS
=
{
"
inverse_fshift
"
:
(
"
backward
"
,
pd
.
Timedelta
),
"
inverse_bshift
"
:
(
"
forward
"
,
pd
.
Timedelta
),
...
...
@@ -565,9 +564,7 @@ def resample(
# create a dummys
if
all_na_2_empty
and
datcol
.
dropna
().
empty
:
# Todo: This needs discussion. It makes possible, that different harmonized variables,
# resulting from the harmonization of the same logger, have differing timestamps!
# (Same holds for starting/ending nan-chunk truncation)
# Todo: This needs discussion. See issue #GL170
datcol
=
pd
.
Series
([],
index
=
pd
.
DatetimeIndex
([]),
name
=
field
)
flagscol
=
pd
.
Series
([],
index
=
pd
.
DatetimeIndex
([]),
name
=
field
)
...
...
@@ -668,7 +665,6 @@ def _inverseShift(target_flagscol, source_col=None, freq=None, method=None, drop
return
target_flagscol
@register
(
masking
=
'
none
'
,
module
=
"
resampling
"
)
def
reindexFlags
(
data
:
DictOfSeries
,
...
...
@@ -676,11 +672,9 @@ def reindexFlags(
flagger
:
Flagger
,
method
:
Literal
[
"
inverse_fagg
"
,
"
inverse_bagg
"
,
"
inverse_nagg
"
,
"
inverse_fshift
"
,
"
inverse_bshift
"
,
"
inverse_nshift
"
],
source
:
str
,
freq
:
Optional
[
str
]
=
None
,
to_mask
:
Optional
[
Union
[
Any
,
Sequence
[
Any
]]]
=
BAD
,
freq
:
Optional
[
str
]
=
None
,
**
kwargs
)
->
Tuple
[
DictOfSeries
,
Flagger
]:
"""
The Function projects flags of
"
source
"
onto flags of
"
field
"
. Wherever the
"
field
"
flags are
"
better
"
then the
source flags projected on them, they get overridden with this associated source flag value.
...
...
@@ -728,9 +722,6 @@ def reindexFlags(
freq : {None, str},default None
The freq determines the projection range for the projection method. See above description for more details.
Defaultly (None), the sampling frequency of source is used.
to_mask : {None, str, List[str]}, default None
Flags referring to values that are to drop before flags projection. Relevant only when projecting with an
inverted shift method. Defaultly BAD is listed.
Returns
-------
...
...
@@ -740,17 +731,13 @@ def reindexFlags(
The flagger object, holding flags and additional Informations related to `data`.
Flags values and shape may have changed relatively to the flagger input.
"""
if
to_mask
is
None
:
to_mask
=
BAD
flagscol
=
flagger
[
source
]
if
flagscol
.
empty
:
return
data
,
flagger
if
freq
is
None
:
freq
=
getFreqDelta
(
flagscol
.
index
)
if
freq
is
None
and
not
method
==
'
match
'
:
if
freq
is
None
and
not
method
==
'
match
'
:
raise
ValueError
(
'
To project irregularly sampled data, either use method=
"
match
"
, or pass custom
'
'
projection range to freq parameter
'
)
...
...
@@ -762,15 +749,14 @@ def reindexFlags(
merge_func
=
_inverseInterpolation
merge_dict
=
dict
(
freq
=
freq
,
chunk_bounds
=
ignore
)
if
method
[
-
3
:]
==
"
agg
"
or
method
==
"
match
"
:
projection_method
=
METHOD2ARGS
[
method
][
0
]
tolerance
=
METHOD2ARGS
[
method
][
1
](
freq
)
merge_func
=
_inverseAggregation
merge_dict
=
dict
(
freq
=
tolerance
,
method
=
projection_method
)
if
method
[
-
5
:]
==
"
shift
"
:
to_mask
=
kwargs
[
'
to_mask
'
]
drop_mask
=
(
target_datcol
.
isna
()
|
target_flagscol
>=
to_mask
)
projection_method
=
METHOD2ARGS
[
method
][
0
]
tolerance
=
METHOD2ARGS
[
method
][
1
](
freq
)
...
...
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