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
9f45e741
Commit
9f45e741
authored
1 year ago
by
David Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
Reworked the flagManual docstring
parent
b3654e21
No related branches found
No related tags found
1 merge request
!721
Reworked the flagManual docstring
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
saqc/funcs/flagtools.py
+48
-46
48 additions, 46 deletions
saqc/funcs/flagtools.py
with
48 additions
and
46 deletions
saqc/funcs/flagtools.py
+
48
−
46
View file @
9f45e741
...
...
@@ -93,7 +93,7 @@ class FlagtoolsMixin:
def
flagManual
(
self
:
"
SaQC
"
,
field
:
str
,
mdata
:
pd
.
Series
|
pd
.
DataFrame
|
DictOfSeries
|
list
|
np
.
ndarray
,
mdata
:
str
|
pd
.
Series
|
np
.
ndarray
|
list
|
pd
.
DataFrame
|
DictOfSeries
,
method
:
Literal
[
"
left-open
"
,
"
right-open
"
,
"
closed
"
,
"
plain
"
,
"
ontime
"
]
=
"
left-open
"
,
...
...
@@ -103,61 +103,64 @@ class FlagtoolsMixin:
**
kwargs
,
)
->
"
SaQC
"
:
"""
Flag data by given,
"
manually generated
"
data.
Include flags listed in external
data.
The data is flagged at locations where `mdata` is equal to a provided
flag (`mflag`). The format of mdata can be an indexed object,
like pd.Series, pd.Dataframe or dios.DictOfSeries, but also can
be a plain list- or array-like. How indexed mdata is aligned to
data is specified via the `method` parameter.
The method allows to integrate pre-existing flagging information.
Parameters
----------
mdata :
The Data determining, wich intervals are to be flagged, or a
string, denoting under which field the data is
accessable.
Determines which values or intervals will be flagged. Supported input types:
method :
Defines how mdata is projected on data. Except for the
'
plain
'
method, the methods assume mdata to have an index.
*
'
plain
'
: mdata must have the same length as data and is
projected one-to-one on data.
*
'
ontime
'
: works only with indexed mdata. mdata entries are
matched with data entries that have the same index.
*
'
right-open
'
: mdata defines intervals, values are to be
projected on. The intervals are defined,
(1) Either, by any two consecutive timestamps t_1 and 1_2
where t_1 is valued with mflag, or by a series,
(2) Or, a Series, where the index contains in the t1 timestamps
and the values the respective t2 stamps.
The value at t_1 gets projected onto all data timestamps t,
with t_1 <= t < t_2.
* ``pd.Series``: Needs a datetime index and values of type:
*
'
left-open
'
: like
'
right-open
'
, but the projected interval
now covers all t with t_1 < t <= t_2.
*
'
closed
'
: like
'
right-open
'
, but the projected interval
now covers all t with t_1 <= t <= t_2.
- datetime, for :py:attr:`method` values ``
"
right-closed
"
``, ``
"
left-closed
"
``, ``
"
closed
"
``
- or any scalar, for :py:attr:`method` values ``
"
plain
"
``, ``
"
ontime
"
``
* ``str``: Variable holding the manual flag information.
* ``pd.DataFrame``, ``DictOfSeries``: Need to provide a ``pd.Series`` with column name
:py:attr:`field`.
* ``list``, ``np.ndarray``: Only supported with :py:attr:`method` value ``
"
plain
"
`` and
:py:attr:`mformat` value ``
"
mflag
"
``
method :
Defines how :py:attr:`mdata` is projected to data:
* ``
"
plain
"
``: :py:attr:`mdata` must have the same length as :py:attr:`field`, flags
are set, where the values in :py:attr:`mdata` equal :py:attr:`mflag`.
* ``
"
ontime
"
``: Expects datetime indexed :py:attr:`mdata` (types ``pd.Series``,
``pd.DataFrame``, ``DictOfSeries``). Flags are set, where the values in
:py:attr:`mdata` equal :py:attr:`mflag` and the indices of :py:attr:`field` and
:py:attr:`mdata` match.
* ``
"
right-open
"
``: Expects datetime indexed :py:attr:`mdata`, which will be interpreted
as a number of time intervals ``t_1, t_2``. Flags are set to all timestamps ``t`` of
:py:attr:`field` with ``t_1 <= t < t_2``.
* ``
"
left-open
"
``: like ``
"
right-open
"
``, but the interval covers all ``t`` with
``t_1 < t <= t_2``.
* ``
"
closed
"
``: like ``
"
right-open
"
``, but the interval now covers all ``t`` with
``t_1 <= t <= t_2``.
mformat :
Controls the interval definition in :py:attr:`mdata` (see examples):
* ``
"
start-end
"
``: expects datetime indexed :py:attr:`mdata` (types ``pd.Series``,
``pd.DataFrame``, ``DictOfSeries``) with values of type datetime. Each
index-value pair is interpreted as an interval to flag, the index defines the
left bound, the respective value the right bound.
* ``
"
mflag
"
``:
*
"
start-end
"
: mdata is a Series, where every entry indicates
an interval to-flag. The index defines the left bound,
the value defines the right bound.
*
"
mflag
"
: mdata is an array like, with entries containing
'
mflag
'
,where flags shall be set. See documentation for
examples.
- :py:attr:`mdata` of type ``pd.Series``, ``pd.DataFrame``, ``DictOfSeries``:
Two successive index values ``i_1, i_2`` will be interpreted as an interval
``t_1, t_2`` to flag, if the value of ``t_1`` equals :py:attr:`mflag`
- :py:attr:`mdata` of type ``list``, ``np.ndarray``: Flags all :py:attr:`field`
where :py:attr:`mdata` euqals :py:attr:`mflag`.
mflag :
The flag that indicates data points in `mdata`, of wich the
projection in data should be flagged.
Value in :py:attr:`mdata` indicating that a flag should be set at the respective
position, timestamp or interval. Ignored if :py:attr:`mformat` is set to ``
"
start-end
"
``.
Examples
--------
An example for
mdata
Usage of :py:attr:`
mdata
`
.. doctest:: ExampleFlagManual
...
...
@@ -169,9 +172,8 @@ class FlagtoolsMixin:
2000
-
05
-
01
1
dtype
:
int64
On *dayly* data, with the
'
ontime
'
method, only the provided timestamps
are used. Bear in mind that only exact timestamps apply, any offset
will result in ignoring the timestamp.
On *daily* data, with :py:attr:`method` ``
"
ontime
"
``, only the provided timestamps
are used. Only exact matches apply, offsets will be ignored.
.. doctest:: ExampleFlagManual
...
...
@@ -186,7 +188,7 @@ class FlagtoolsMixin:
2000
-
05
-
01
True
dtype
:
bool
With
the
'
right-open
'
method, the
mdata is forward fill:
With
:py:attr:`method` ``
"
right-open
"
`` , :py:attr:`
mdata
`
is forward fill
ed
:
.. doctest:: ExampleFlagManual
...
...
@@ -199,7 +201,7 @@ class FlagtoolsMixin:
2000
-
05
-
01
True
dtype
:
bool
With
the
'
left-open
'
method,
backward fill
ing is us
ed:
With
:py:attr:`method` ``
"
left-open
"
`` , :py:attr:`mdata` is
backward filled:
.. doctest:: ExampleFlagManual
...
...
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