foamgraph-0.2.4
توضیحات
Fast visualization library for interactive online analysis at scientific user facilities
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | foamgraph-0.2.4 |
| نام | foamgraph |
| نسخه کتابخانه | 0.2.4 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | - |
| ایمیل نویسنده | Jun Zhu <zhujun981661@gmail.com> |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/foamgraph/ |
| مجوز | BSD 3-Clause License Copyright (c) 2022, Jun Zhu All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
foamgraph
=========
[](https://pypi.org/project/foamgraph/)



[](https://doc.qt.io/qt-5/)
[](https://doc.qt.io/qt-6/)
`foamgraph` was originally developed as part of the online analysis framework
[EXtra-foam](https://github.com/European-XFEL/EXtra-foam.git)
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](https://github.com/pyqtgraph/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.
<img src="usecase.png" width="640"/>
## 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.
```py
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:
```py
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](examples/plot_gallery.py).
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:
```py
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:
```sh
python examples/producer.py
```
* Open another terminal and start the plot gallery example
```sh
python examples/plot_gallery.py
```
<img src="https://github.com/zhujun98/foam-demo/blob/main/foamgraph/plot_galary.gif" width="640"/>
* Open another terminal and start the image analysis example
```sh
python examples/image_analysis.py
```
<img src="https://github.com/zhujun98/foam-demo/blob/main/foamgraph/image_analysis-1.gif" width="320"/> <img src="https://github.com/zhujun98/foam-demo/blob/main/foamgraph/image_analysis-2.gif" width="320"/>
## 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 |
نیازمندی
| مقدار | نام |
|---|---|
| >=1.21.5 | numpy |
| - | pytest |
| - | pytest-qt |
| - | pytest-cov |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.9 | Python |
نحوه نصب
نصب پکیج whl foamgraph-0.2.4:
pip install foamgraph-0.2.4.whl
نصب پکیج tar.gz foamgraph-0.2.4:
pip install foamgraph-0.2.4.tar.gz