Fast visualization library for interactive online analysis at scientific user facilities
Project description
foamgraph
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 PlotWidgetF
. The following code snippet
shows how to create a double-y plot with a title, axis labels and a legend:
from foamgraph import FColor, PlotWidgetF
class DoubleYPlot(PlotWidgetF):
def __init__(self, *, parent=None):
super().__init__(parent=parent)
self.setTitle('Double-y plot')
self.setLabel('bottom', "x (arb. u.)")
self.setLabel('left', "y (arb. u.)")
self.setLabel('right', "y2 (arg. u.)")
self._plot = self.plotCurve(name="Data", pen=FColor.mkPen('w'))
self._plot2 = self.plotBar(
name="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 ImageViewF
. The following
code snippet shows how to create a simple widget for displaying an image:
from foamgraph import ImageViewF
class ImageAnalysis(ImageViewF):
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
Built Distribution
Hashes for foamgraph-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bae32170301fa8a17daad7c25a902c4b3d240e3bbc4ab8a7d593a1cadeeacc4 |
|
MD5 | 5164d6d869889e83796e8d55d96d7517 |
|
BLAKE2b-256 | a9063de8a671041992edb0bf7bafc1ed40bbb1bcb5f0f6dc4aaf9b59e5621e16 |