Flag by click (flagging GUI)
Since the demand for a visual, GUI-ish tool to manually set or remove flags from datasets with saqc was repeatedly stated during the latest saqc
workshop, i returned to a draft i developed, when learning matplotlib provides actually interactive widgets and selectors, and decided to work it out as an saqc
function and a proof of concept:
The merge adds the saqc
method flagByClick
, which provides a rudimentary pop up GUI for adding or removing flags by selection of points directly in the data plot.
In "overlay" mode, the GUI works as an overlay over the usual saqc.plot
figures and runs within the usual matplotlib.pyplot
frontend, thus enabling the basic viewing tools such as pan and zoom. In addition, one can select and remove points with a dragable rectangular selector to a selection and assign a flag value to the selection when it is complete (when assign
is clicked).
In "GUI" mode, the GUI is enriched with a TkInter based, scrollable view on the variables to flag. This is due to screensize limitation, working with more than 2 or 3 variables at a time, is not really practical. Also flagging of variables in parallel and switching between span and rectangular selector is enabled.
As a flagging function, the pop up GUI only supports the addition of one flags column (with a unitary level and label) in one session.
When setting the flag level to -np.inf
, the GUI may also be used to remove flags already set.
Run the following example to get an impression:
import pandas as pd
import numpy as np
import saqc
periods=1000
data = pd.DataFrame(
{f"d{k}": np.random.randint(0, 100, 100) for k in range(6)},
index=pd.date_range("2000", freq="1d", periods=100),
)
qc = saqc.SaQC(data)
qc = qc.flagRange('.', regex=True, max=70)
qc = qc.flagRange('.', regex=True, min=20, label='MINIMUM')
qc = qc.flagByClick('d1', regex=True, mode='overlay')
qc = qc.flagByClick('.', regex=True, mode='GUI')
User Manual:
- Left click and drag the rectangle over the points you want to add to selection.
- Right click and drag the rectangle over the points you want to remove from selection
- press 'enter' or click
Assign Flags
button in the toolbar to assign flags to the selected points - press 'shift' to switch selection tool between span and rectangular (GUI mode only)
- activate the sliders above the plots to flag variables synchroneously with the span selector (GUI mode only)
- scrollbar or mousewheel to scroll through variables (GUI mode only)