Skip to content
Snippets Groups Projects
Commit 087a3bef authored by David Schäfer's avatar David Schäfer
Browse files

fixed stuff

parent 85fb44f3
No related branches found
No related tags found
7 merge requests!685Release 2.4,!684Release 2.4,!567Release 2.2.1,!566Release 2.2,!501Release 2.1,!372fix doctest snippets,!369Current documentation
...@@ -5,6 +5,7 @@ General structure ...@@ -5,6 +5,7 @@ General structure
----------------- -----------------
The Python API of SaQC consists of three distinct components: The Python API of SaQC consists of three distinct components:
1. the core class ``SaQC`` 1. the core class ``SaQC``
2. a number of flagging schemes 2. a number of flagging schemes
3. a collection of functions 3. a collection of functions
...@@ -12,13 +13,14 @@ The Python API of SaQC consists of three distinct components: ...@@ -12,13 +13,14 @@ The Python API of SaQC consists of three distinct components:
One and two are implemented as distinct classes, the core object is called ``SaQC`` and we currently One and two are implemented as distinct classes, the core object is called ``SaQC`` and we currently
provide three flagging schemes, namely: provide three flagging schemes, namely:
1. ``FloatTranslators``: Provides the quality flags ``-np.inf`` and ``[0..255]``. ``-np.inf`` denotes the 1. ``FloatScheme``: Provides the quality flags ``-np.inf`` and ``[0..255]``.
absence of quality flags and ``255`` denotes, that the associated data value is considered to be bad. ``-np.inf`` denotes the absence of quality flags and ``255`` denotes, that
the absence of a flags, ``1`` the presence of flag (i.e. one of the tests provided a positive result) the associated data value is considered to be bad. the absence of a flags,
``1`` the presence of flag (i.e. one of the tests provided a positive result)
and ``0`` acts as an indicator for an tested-to-be-not-bad value. and ``0`` acts as an indicator for an tested-to-be-not-bad value.
2. ``SimpleTranslator``: Provides three distinct quality labels, namely ``UNFLAGGED``, ``BAD``, ``OKAY``. 2. ``SimpleScheme``: Provides three distinct quality labels, namely ``UNFLAGGED``, ``BAD``, ``OKAY``.
3. ``DmpTranslator``: Provides the four distinct flags ``NIL``, ``OK``, ``DOUBTFUL``, ``BAD``, whereas each 3. ``DmpScheme``: Provides the four distinct flags ``NIL``, ``OK``, ``DOUBTFUL``, ``BAD``, whereas each
flag is extended by information about the generating function and optional comments flag is extended by information about the generating function and optional comments.
The third component, the actual test functions, appear as methods of ``SaQC``. The third component, the actual test functions, appear as methods of ``SaQC``.
...@@ -27,8 +29,8 @@ Getting started - Put something in ...@@ -27,8 +29,8 @@ Getting started - Put something in
---------------------------------- ----------------------------------
The definition of a ``SaQC`` test suite starts with some data as a ``pandas.DataFrame`` and the selection The definition of a ``SaQC`` test suite starts with some data as a ``pandas.DataFrame`` and the selection
of an appropriate flagging scheme. For reasons of simplicity, we'll use the ``SimpleTranslator`` throughout of an appropriate flagging scheme. For reasons of simplicity, we'll use the ``SimpleScheme`` throughout
the following examples. However, as the flagging schemes are interchangable, replacing the ``SimpleTranslator`` the following examples. However, as the flagging schemes are mostly interchangable, replacing the ``SimpleScheme``
with something more elaborate, is in fact a one line change. So let's start with: with something more elaborate, is in fact a one line change. So let's start with:
.. code-block:: python .. code-block:: python
...@@ -60,22 +62,23 @@ available functions appear as methods of the ``SaQC`` class, so we can add a te ...@@ -60,22 +62,23 @@ available functions appear as methods of the ``SaQC`` class, so we can add a te
qc.flagRange("a", min=20, max=80) qc.flagRange("a", min=20, max=80)
``flagRange`` is the easiest of all functions and simply marks all values smaller than ``min`` and larger :py:func:`flagRange <Functions.saqc.flagRange>` is the easiest of all functions and simply marks all values
than ``max``. This feature by itself wouldn't be worth the trouble of getting into ``SaQC``, but it serves smaller than ``min`` and larger than ``max``. This feature by itself wouldn't be worth the trouble of getting
as a simple example. All functions expect the name of a column in ``data`` as the first positional argument into ``SaQC``, but it serves as a simple example. All functions expect the name of a column in the given
(called ``field``). The function ``flagRange`` (like all other functions for that matter) is then called on ``data`` as their first positional argument (called ``field``). The function ``flagRange`` (like all other
the given ``field`` (only). functions for that matter) is then called on the given ``field`` (only).
Each call to a ``SaQC`` method returns a new object (all itermediate objects share the main internal data Each call to a ``SaQC`` method returns a new object (all itermediate objects share the main internal data
structures, so we only create shallow copies). Setting up more complex quality control suites is therefore structures, so we only create shallow copies). Setting up more complex quality control suites (here by calling
simply a matter of method chaining. the additional methods :py:func:`flagConstants <Functions.saqc.flagConstants>` and
:py:func:`flagByGrubbs <Functions.saqc.flagByGrubbs>`) is therefore simply a matter of method chaining.
.. code-block:: python .. code-block:: python
# execute some tests # execute some tests
qc = (qc qc = (qc
.flagConstants("a", thresh=0.1, window="4D") .flagConstants("a", thresh=0.1, window=4)
.flagByGrubbs("a", window="10D") .flagByGrubbs("a", window=10)
.flagRange("a", min=20, max=80)) .flagRange("a", min=20, max=80))
...@@ -135,8 +138,12 @@ The snippet below provides you with a compete example from the things we have se ...@@ -135,8 +138,12 @@ The snippet below provides you with a compete example from the things we have se
Can I get something visual, please? Can I get something visual, please?
----------------------------------- -----------------------------------
Yes, you can. We provide an elaborated plotting method to generate and show or write matplotlib figures. We provide an elaborated plotting method to generate and show or write matplotlib figures. Building on
Building on the example :ref:`above <getting_started/TutorialAPI:putting it together - a complete workflow>` the example :ref:`above <getting_started/TutorialAPI:putting it together - the complete workflow>` above
the calling the method ``qc.plot("a")`` will generate a plot like the following: simply call:
.. code-block:: python
qc.plot("a")
.. image:: /ressources/images/tutorial_api_1.png .. image:: /ressources/images/tutorial_api_1.png
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment