Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • berntm/saqc
  • rdm-software/saqc
  • schueler/saqc
3 results
Show changes
Commits on Source (26)
......@@ -4,11 +4,11 @@
recommonmark==0.7.1
sphinx==6.2.1
sphinx-automodapi==0.15.0
sphinx-automodapi==0.16.0
sphinxcontrib-fulltoc==1.2.0
sphinx-markdown-tables==0.0.17
jupyter-sphinx==0.4.0
sphinx_autodoc_typehints==1.23
sphinx-tabs==3.4.1
sphinx-design==0.4.1
sphinx-design==0.5.0
pydata-sphinx-theme==0.13.3
......@@ -2,15 +2,15 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
Click==8.1.3
Click==8.1.7
docstring_parser==0.15
dtw==1.4.0
matplotlib==3.7.1
matplotlib==3.7.2
numpy==1.24.3
outlier-utils==0.0.3
pyarrow==11.0.0
outlier-utils==0.0.5
pyarrow==13.0.0
pandas==2.0.1
scikit-learn==1.2.2
scikit-learn==1.3.0
scipy==1.10.1
typing_extensions==4.5.0
fancy-collections==0.2.1
\ No newline at end of file
......@@ -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 filled:
.. doctest:: ExampleFlagManual
......@@ -199,7 +201,7 @@ class FlagtoolsMixin:
2000-05-01 True
dtype: bool
With the 'left-open' method, backward filling is used:
With :py:attr:`method` ``"left-open"`` , :py:attr:`mdata` is backward filled:
.. doctest:: ExampleFlagManual
......
......@@ -176,6 +176,8 @@ def makeFig(
ax_kwargs.pop("fontsize", None) or plt.rcParams["font.size"]
)
plt.rcParams["figure.figsize"] = FIG_KWARGS["figsize"]
# set default axis sharing behavior (share x axis over rows if not explicitly opted sharex=False):
sharex = False
if len(d) > 1:
......
......@@ -3,8 +3,8 @@
# SPDX-License-Identifier: GPL-3.0-or-later
beautifulsoup4==4.12.2
hypothesis==6.75.1
Markdown==3.4.3
pytest==7.3.1
hypothesis==6.82.7
Markdown==3.4.4
pytest==7.4.0
pytest-lazy-fixture==0.6.3
requests==2.29.0
requests==2.31.0