User Interface

This is a collection of modules concerned with visualizing and interacting with experiments and data.

cohesivm.data_stream

This module contains the classes which handle the data stream from measurement methods.

class DataStream[source]

Bases: ABC

Creates a multiprocessing.Queue object which is used to stream data from a Measurement. A child class implements the methods for pulling the data from the queue and processing it.

property data_stream: Queue

The multiprocessing.Queue object, where data is streamed to. Must be injected into the Measurement or the Experiment.

class FakeQueue[source]

Bases: object

Mimics the multiprocessing.Queue and can be used as default value for methods which implement an optional data stream. Simplifies the methods because they do not have to care if the queue is actually present and also prevents unnecessary data accumulation.

static put(data)[source]

Does nothing.

cohesivm.plots

This module contains plot classes which are used to (interactively) display the measurement progress and results.

class Plot[source]

Bases: ABC

This class serves as a blueprint for creating various plot types using Matplotlib. It ensures that derived classes implement methods for creating, updating, and clearing plots, and provides mechanisms for checking data compatibility.

property figure: Figure | None

The matplotlib.figure.Figure object which is populated with the data.

abstract make_plot() None[source]

Generates the canvas of the plot and populates the static elements.

abstract update_plot(*args, **kwargs) None[source]

Populates the figure with the data.

abstract clear_plot() None[source]

Restores the plot to its initial state and removes all displayed data.

property data_types: Tuple[Type]

A tuple of Numpy data types which corresponds to the expected shape of data points.

check_compatibility(data_dtype: dtype | List[Tuple[str, Type]]) None[source]

Checks if the types of the data are compatible with the plot.

Parameters:

data_dtype – The data type of the expected data.

Raises:

CompatibilityError – If the expected data is not compatible with the plot.

class XYPlot(figsize: Tuple[float, float] = (7, 5.5), origin: bool = True)[source]

Bases: Plot

Generates and updates a two-dimensional x-y-plot.

Parameters:
  • figsize – Size of the figure in inch (see matplotlib.figure.Figure).

  • origin – Flag if the origin (0, 0) should be displayed by a vertical and a horizontal line.

make_plot() None[source]

Generates the canvas of the plot and populates the static elements.

update_plot(data: ndarray) None[source]

Populates the figure with the data.

clear_plot() None[source]

Restores the plot to its initial state and removes all displayed data.

cohesivm.gui

class DataStreamPlot[source]

Bases: DataStream, Plot

A multiprocessing.Queue object which is used to stream data from a Measurement to a bqplot.Figure object where the streamed data is put into. A child class implements the methods for updating the data and the figure. Its intended use is within the ExperimentGUI.

abstract update_plot() None[source]

Fetches the data from the data_stream and puts it in the figure.

class XYDataStreamPlot(x_label: str, y_label: str, figsize: Tuple[float, float] = (7, 5.5))[source]

Bases: DataStreamPlot

Generates and updates a two-dimensional x-y-plot with the data which is put in the data_stream queue.

Parameters:
  • x_label – Label of the x-axis.

  • y_label – Label of the y-axis.

  • figsize – Size of the figure in inch (see matplotlib.figure.Figure).

property figure: Figure | None

The bqplot.Figure object which is populated with the data.

make_plot() None[source]

Generates the canvas of the plot and populates the static elements.

update_plot() None[source]

Fetches the data from the data_stream and puts it in the figure.

clear_plot() None[source]

Restores the plot to its initial state and removes all displayed data.

class ExperimentGUI(*args, **kwargs)[source]

Bases: _InterfacePlotGUI

A graphical user interface for monitoring and controlling an experiment within a Jupyter Notebook.

Parameters:
  • experiment – The Experiment which should be monitored.

  • plot – A DataStreamPlot object which is compatible with the experiment.

display() None[source]

Displays the ExperimentGUI widget and starts the update loop in a separate thread.

class AnalysisGUI(analysis: Analysis)[source]

Bases: _InterfacePlotGUI

A graphical user interface for plotting measurement data and displaying analysis results within a Jupyter Notebook.

Parameters:

analysis – An Analysis object which should be displayed.

display() None[source]

Displays the AnalysisGUI widget.

class DatabaseGUI(database: Database)[source]

Bases: object

A graphical user interface for displaying and filtering the contents of a database file within a Jupyter Notebook.

Parameters:

database – The Database object which should be displayed.

display() None[source]

Displays the DatabaseGUI widget.