Skip to main content

Fast visualization library for interactive online analysis at scientific user facilities

Project description

foamgraph

PyPi Build status Total alerts Language grade: Python

Language Qt 5 Qt 6

foamgraph was originally developed as part of the online analysis framework EXtra-foam to provide fast display (10 Hz) and interactive data analysis for photon science experiments at the state-of-art free-electron laser (FEL) facility - European XFEL. It was implemented on top of the famous Python graphics and GUI library PyQtGraph. The following features make foamgraph stand out:

  • The widgets and graphics objects are dedicated for photon science experiments.
  • The performance has been significantly improved.
  • It trades flexibility for an easy-to-use and unified API.

It must be emphasized that foamgraph is only a GUI library. It does not provide any interfaces for data and metadata exchange between the backend and the GUI because it is facility and experiment specific.

Nevertheless, when integrating GUI into a real-time data analysis pipeline, there are a couple of things to be taken into account:

  • The GUI in principle should not perform any number crunching jobs, otherwise it will be slowed down because it is written in Python.
  • Light computation tasks can be performed in a Python thread and the communication between the GUI and the processor can still be fulfilled using Qt's signal-slot connections.

Getting started

Every plot widget should inherit from GraphView. The following code snippet shows how to create a double-y plot with a title, axis labels and a legend:

from foamgraph import FColor, GraphView


class DoubleYPlot(GraphView):
    def __init__(self, *, parent=None):
        super().__init__(parent=parent)

        self.setTitle('Double-y plot')
        self.setXYLabels("x (arb. u.)", "y (arb. u.)", y2="y2 (arg. u.)")

        self._plot = self.addCurvePlot(label="Data", pen=FColor.mkPen('w'))
        self._plot2 = self.addBarPlot(
            label="Count", y2=True, brush=FColor.mkBrush('i', alpha=150))
        self.addLegend()

    def updateF(self, data):
        """Override."""
        self._plot.setData(data['x'], data['y'])
        self._plot2.setData(data['x'], data['y2'])

Every widget for image analysis should inherit from ImageView. The following code snippet shows how to create a simple widget for displaying an image:

from foamgraph import ImageView


class ImageAnalysis(ImageView):
    def updateF(self, data):
        """Override."""
        self.setImage(data['image']['data'])

Examples

  • Open a terminal and start the producer:
python examples/producer.py
  • Open another terminal and start the plot gallery example
python examples/plot_gallery.py

  • Open another terminal and start the image analysis example
python examples/image_analysis.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

foamgraph-0.2.2.tar.gz (80.3 kB view hashes)

Uploaded Source

Built Distribution

foamgraph-0.2.2-py3-none-any.whl (104.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page