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 data-intensive
photon science experiments at the state-of-art free-electron laser (FEL) facility -
European XFEL. It was originally implemented on top of the famous Python graphics
and GUI library PyQtGraph. The following
features made foamgraph
stand out:
- The widgets are dedicated for photon science experiments.
- The performance has been significantly improved.
As of now, foamgraph
has almost evolved into its own implementation completely.
It's time to decide the direction for future development. Since there are already
many excellent GUI libraries around, foamgraph
should and will do something different.
Getting started
Imaging you have a data producer which streams data continuously and you would like to build a GUI to visualize the data and perform interactive analysis while the data is updating. Eventually, what you need is something shown in the code snippet below: a consumer consumers the data generated by the producer and then passes the data to the GUI.
gui = PlotGalleryWindow()
consumer = Consumer(gui.queue) # the queue is used to store data streams
gui.start()
consumer.start()
The class PlotGalleryWindow
can be conveniently implemented as follows:
class PlotGalleryWindow(LiveWindow):
def __init__(self):
super().__init__("Plot gallery")
# define your plots
self._plots = [
ShadedPlot(parent=self),
ScatterPlot(parent=self),
BarPlot(parent=self),
ErrorbarPlot(parent=self),
MultiLinePlot(parent=self),
DoubleYPlot(parent=self),
LinePlotWithAnnotation(parent=self),
CandlestickPlot(parent=self),
StemPlot(parent=self)
]
# init your GUI layout and Qt signal-slot connection
self.init()
For more details of the above use case, please check here.
In foamgraph
, 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'])
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
Benchmarks
The benchmark was performed on a Apple M1 Pro 16GB with the GUI geometry of 800 x 600.
Plot Type | Description | FPS |
---|---|---|
Curve | 10000 points | 300 |
Scatter | 10000 points | 140 |
Bar | 500 bars | 350 |
Image | 1280 x 1024 | 92 |
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
File details
Details for the file foamgraph-0.2.4.tar.gz
.
File metadata
- Download URL: foamgraph-0.2.4.tar.gz
- Upload date:
- Size: 76.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a7b1de9cf7d5f64fb2d52cd64da8529b16ff24344f5017a05b227bfe672167a |
|
MD5 | e9c9d7bbf6e4070e6c07aa305b559ad4 |
|
BLAKE2b-256 | 543e4b79d094aab85df78530e0e88de760543ad8d041cf0e7c38ba5318bf56f8 |
File details
Details for the file foamgraph-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: foamgraph-0.2.4-py3-none-any.whl
- Upload date:
- Size: 112.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 706bd9502361eb5bb52fdd60e1166fdb9423108158dac25b78739be1b933b32e |
|
MD5 | 91812ddb7eba1d02f7460565954ab2de |
|
BLAKE2b-256 | 6702671b238918c541146993a8701328f83c6771d8bb3ab4e5d8304c5a62dabc |