Skip to content

Commit

Permalink
Merge pull request #245 from European-XFEL/dev
Browse files Browse the repository at this point in the history
0.9.0
  • Loading branch information
zhujun98 authored Jun 30, 2020
2 parents f8f2502 + 679427e commit 03117a2
Show file tree
Hide file tree
Showing 250 changed files with 5,843 additions and 19,321 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
env: PYTHON_VERSION="3.7.5" COMPILER="gcc" GCCv="7"
- stage: full linux
os: linux
env: PYTHON_VERSION="3.7.5" COMPILER="gcc" GCCv="7"
env: PYTHON_VERSION="3.7.5" COMPILER="gcc" GCCv="8"
- stage: full linux
os: linux
env: PYTHON_VERSION="3.7.5" COMPILER="gcc" GCCv="6"
env: PYTHON_VERSION="3.7.5" COMPILER="gcc" GCCv="7"
- stage: full linux
os: linux
env: PYTHON_VERSION="3.6.9" COMPILER="gcc" GCCv="7"
env: PYTHON_VERSION="3.7.5" COMPILER="gcc" GCCv="6"
- stage: full linux
os: linux
env: PYTHON_VERSION="3.6.9" COMPILER="gcc" GCCv="6"
Expand Down Expand Up @@ -86,7 +86,7 @@ before_install:
install:
- conda install -y python=$PYTHON_VERSION
- echo $PYTHON_VERSION
- conda install -y cmake libstdcxx-ng numpy -c anaconda
- conda install -y cmake numpy -c anaconda
- conda install -y -c conda-forge tbb-devel
- export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
- pip install -e .[test]
Expand Down
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ if(FOAM_USE_TBB OR XTENSOR_USE_TBB)
set(TBB_REQUIRED_VERSION 2020.1)
string(REPLACE "." "_U" TBB_REQUIRED_VERSION_STR ${TBB_REQUIRED_VERSION})

add_compile_definitions(TBB_SUPPRESS_DEPRECATED_MESSAGES)

find_package(TBB QUIET)
if(TBB_FOUND AND ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} VERSION_EQUAL TBB_REQUIRED_VERSION)
set(TBB_LIBRARY ${TBB_LIBRARIES_RELEASE})
Expand Down Expand Up @@ -146,6 +148,17 @@ if(BUILD_FOAM_TESTS)
add_subdirectory(test)
endif()

# ============
# Build flags
# ============

if(CMAKE_CXX_COMPILER_VERSION)
set(FOAM_COMPILER_STR "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} (version ${CMAKE_CXX_COMPILER_VERSION})")
else()
set(FOAM_COMPILER_STR "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}")
endif()
string(STRIP "${FOAM_COMPILER_STR}" FOAM_COMPILER_STR)

# ============
# Installation
# ============
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ EXtra-foam
![Language](https://img.shields.io/badge/language-c++-red)
[![Qt 5](https://img.shields.io/badge/Qt-5-brightgreen)](https://doc.qt.io/qt-5/)

![Overview](docs/images/extra_foam_0.9.0.jpg)

*EXtra-foam* (previously known as *[karaboFAI](https://in.xfel.eu/readthedocs/docs/karabofai/en/latest/)*) is a
framework that provides super fast on-line (real-time) and off-line data analysis and visualization for
experiments at European XFEL that using 2D detectors (e.g. AGIPD, DSSC, LPD, ePix100, FastCCD, JungFrau,
Expand Down
55 changes: 55 additions & 0 deletions benchmarks/gui/benchmark_imageview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
Distributed under the terms of the BSD 3-Clause License.
The full license is in the file LICENSE, distributed with this software.
Author: Jun Zhu <[email protected]>
Copyright (C) European X-Ray Free-Electron Laser Facility GmbH.
All rights reserved.
"""
import time

import numpy as np

from PyQt5.QtCore import QTimer

from extra_foam.gui import mkQApp
from extra_foam.gui.plot_widgets import ImageViewF

app = mkQApp()


class BenchmarkImageViewSpeed:
def __init__(self):
self._timer = QTimer()
self._timer.timeout.connect(self.update)

self._data = np.random.normal(size=(50, 1024, 1280))
self._prev_t = None
self._count = 0

self._view = ImageViewF()
self._view.show()

def start(self):
self._prev_t = time.time()
self._timer.start(0)

def update(self):
self._view.setImage(self._data[self._count % 10])
self._count += 1

now = time.time()
dt = now - self._prev_t
self._prev_t = now
fps = 1.0/dt

self._view.setTitle(f"{fps:.2f} fps")

app.processEvents() # force complete redraw for every plot


if __name__ == '__main__':
bench = BenchmarkImageViewSpeed()
bench.start()
app.exec_()
92 changes: 92 additions & 0 deletions benchmarks/gui/benchmark_plotwidget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
"""
Distributed under the terms of the BSD 3-Clause License.
The full license is in the file LICENSE, distributed with this software.
Author: Jun Zhu <[email protected]>
Copyright (C) European X-Ray Free-Electron Laser Facility GmbH.
All rights reserved.
"""
import time
from enum import IntEnum

import numpy as np

from PyQt5.QtCore import QTimer

from extra_foam.gui import mkQApp
from extra_foam.gui.plot_widgets import PlotWidgetF

app = mkQApp()


class PlotType(IntEnum):
Line = 0
Bar = 1
StatisticsBar = 2
Scatter = 3


class BenchmarkPlotItemSpeed:
def __init__(self, plot_type=PlotType.Line):
self._timer = QTimer()
self._timer.timeout.connect(self.update)

self._widget = PlotWidgetF()

if plot_type == PlotType.Line:
self._graph = self._widget.plotCurve()
n_pts = 5000
elif plot_type == PlotType.Bar:
self._graph = self._widget.plotBar()
n_pts = 300
elif plot_type == PlotType.StatisticsBar:
self._graph = self._widget.plotStatisticsBar()
self._graph.setBeam(1)
n_pts = 500
elif plot_type == PlotType.Scatter:
self._graph = self._widget.plotScatter()
n_pts = 3000
else:
raise ValueError(f"Unknown plot type: {plot_type}")

self._x = np.arange(n_pts)
self._data = 100 * np.random.normal(size=(50, n_pts))
if plot_type == PlotType.StatisticsBar:
self._y_min = self._data - 20
self._y_max = self._data + 20
self._plot_type = plot_type

self._prev_t = None
self._count = 0

self._widget.show()

def start(self):
self._prev_t = time.time()
self._timer.start(0)

def update(self):
idx = self._count % 10
if self._plot_type == PlotType.StatisticsBar:
self._graph.setData(self._x, self._data[idx],
y_min=self._y_min[idx], y_max=self._y_max[idx])
else:
self._graph.setData(self._x, self._data[idx])

self._count += 1

now = time.time()
dt = now - self._prev_t
self._prev_t = now
fps = 1.0 / dt

self._widget.setTitle(f"{fps:.2f} fps")

app.processEvents() # force complete redraw for every plot


if __name__ == '__main__':
bench = BenchmarkPlotItemSpeed(PlotType.Line)
bench.start()
app.exec_()
33 changes: 33 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
CHANGELOG
=========

0.9.0 (30 June 2020)
------------------------

- **Bug Fix**

- Fix bug in data source tree introduced in 0.8.4. #235
- Fix transparent Nan pixel with the latest pyqtgraph version. #231

- **Improvement**

- Improve performance of PlotCurveItem and add benchmarks for PlotItems and ImageViewF. #243
- Make ctrl widgets in Imagetool more compact. #241
- Improve C++ code quality and suppress TBB deprecate warning. #239
- Add meter bar to plot area. #236
- Reimplement ImageItem and PlotItem to replace the pyqtgraph ones. #232 #242
- Improve data source updating and color encoding matched source items in
the data source tree. #230 #234
- Rename configurator to analysis setup manager and allow take snapshot for
each setup. #228
- Update data source and trouble shooting in documentation. #227
- Add summary of compiler flags for EXtra-foam-python. #226
- Update installation (gcc7) and CI (gcc8). #226
- Rename misleading mouse mode in the right-click context menu. #211
- Update pyqtgraph to the latest master branch. #206 #211 #233

- **New Feature**

- Annotate peaks in azimuthal integration view. #240
- Enable Legend for all the plot items. #206 #237
- Implement logarithmic X/Y scale in right-click context menu. #206
- Enable C++ API installation and add examples. #227


0.8.4 (8 June 2020)
------------------------

Expand Down
6 changes: 5 additions & 1 deletion docs/config_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ CONFIG FILE
Users from different instruments should use the corresponding config file to config
the instrument specific data sources, the detector specific setups and so on.

Each instrument has a default config file, which can be found in the
`github repository <https://github.com/European-XFEL/EXtra-foam/tree/dev/extra_foam/configs>`__.
We appreciate if the beamline scientists can help us keep the default config file updated.

Let's take *FXE* for example, when one starts a detector on topic *FXE* for the first by
time:

.. code-block:: bash
extra-foam LPD FXE
, the system will create a new config file `$HOME/.EXtra-foam/fxe.config.yaml`.
, the system will create a new config file `$HOME/.EXtra-foam/fxe.config.yaml` using the default one.
The first block of the config file looks like the following:

.. code-block:: yaml
Expand Down
27 changes: 25 additions & 2 deletions docs/image_tool.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _Image tool:

IMAGE TOOL
==========

Expand Down Expand Up @@ -247,8 +249,8 @@ aforementioned coordinate system, respectively.
.. image:: images/pyFAI_PONI.png
:width: 800

.. image:: images/azimuthal_integ_1D.png
:width: 800
.. image:: images/azimuthal_integ_1D.jpg


+----------------------------+--------------------------------------------------------------------+
| Input | Description |
Expand Down Expand Up @@ -288,6 +290,27 @@ aforementioned coordinate system, respectively.
| | azimuthal integration result. |
+----------------------------+--------------------------------------------------------------------+

By default, peak finding is activated and peak positions will be annotated along the scattering
curve if the number of detected peaks is between 1 and 10. There is no special reason for choosing
10 as the upper limit. Nevertheless, if there are two many peaks found, it may be due to a noisy
scattering curve or some unreasonable peak-finding parameters.

For now, users can set prominence to refine the number of detected peaks and use a slicer to select
part of them. The prominence of a peak measures how much a peak stands out from the surrounding
baseline of the signal and is defined as the vertical distance between the peak and its lowest
contour line. The slicer is useful when the scattering curve has some undesired structure, especially
at the start and/or end of the curve.

+----------------------------+--------------------------------------------------------------------+
| Input | Description |
+============================+====================================================================+
| ``Peak finding`` | Check to activate real-time peak finding and annotating. |
+----------------------------+--------------------------------------------------------------------+
| ``Peak prominence`` | Minimum prominence of peaks. |
+----------------------------+--------------------------------------------------------------------+
| ``Peak slicer`` | Pixel size along the detector's 2nd dimension. |
+----------------------------+--------------------------------------------------------------------+


.. _Geometry:

Expand Down
Binary file added docs/images/1d_binning.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/analysis_setup_manager.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/azimuthal_integ_1D.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/azimuthal_integ_1D.png
Binary file not shown.
Binary file removed docs/images/binning_setup.png
Binary file not shown.
Binary file removed docs/images/binning_window.png
Binary file not shown.
Binary file removed docs/images/configurator.png
Binary file not shown.
Binary file added docs/images/correlation.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/correlation_setup.png
Binary file not shown.
Binary file removed docs/images/correlation_window.png
Binary file not shown.
Binary file modified docs/images/data_source_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/extra_foam_0.9.0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/main_gui_action_bar.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/source_monitor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/special_suite_camera_view.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/special_suite_gotthard.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/special_suite_gotthard_pump_probe.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Contents:
introduction
installation
start
trouble_shooting
config_file
main_gui
image_tool
Expand Down
17 changes: 12 additions & 5 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@ In your Anaconda_ environment, run the following commands:

.. code-block:: bash
$ conda install -c anaconda cmake libstdcxx-ng numpy
# install gcc-6.1
$ conda install -c omgarcia gcc-6
$ conda install -c conda-forge tbb
$ conda install -c anaconda libstdcxx-ng
# install gcc-7.5 (experimenting)
# $ conda install -c conda-forge gxx_linux-64
# $ ln -s ${CONDA_PREFIX}/bin/x86_64-conda_cos6-linux-gnu-gcc ${CONDA_PREFIX}/bin/gcc
# $ ln -s ${CONDA_PREFIX}/bin/x86_64-conda_cos6-linux-gnu-g++ ${CONDA_PREFIX}/bin/g++
# install cmake and dependencies
$ conda install -c anaconda cmake numpy
$ conda install -c conda-forge tbb-devel
Install **EXtra-foam**
----------------------
Expand Down Expand Up @@ -55,7 +64,5 @@ Install C++ API of **EXtra-foam** only
.. code-block:: bash
$ mkdir build && cd build
$ cmake -DFOAM_USE_TBB=ON -DXTENSOR_USE_TBB=ON
-DFOAM_USE_XSIMD=ON -DXTENSOR_USE_XSIMD=ON -march=native
-DCMAKE_INSTALL_PREFIX=/YOUR/INSTALL/PREFIX
$ cmake -DFOAM_USE_XSIMD=ON -DCMAKE_INSTALL_PREFIX=/YOUR/INSTALL/PREFIX
$ make && make install
34 changes: 3 additions & 31 deletions docs/introduction.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
INTRODUCTION
============

.. image:: images/extra_foam_0.9.0.jpg


**EXtra-foam** ( **F**\ ast **O**\ nline **A**\ nalysis **M**\ onitor) is a tool that provides
real-time and off-line data analysis (**azimuthal integration**, **ROI**, **correlation**,
**binning**, etc.) and visualization for experiments using **2D area detectors** (*AGIPD*,
Expand Down Expand Up @@ -75,34 +78,3 @@ can be preprocessed and analysed per second.
Due to the limited performance of `PyQt`, the visualization rate could be slower
than the processing rate if there are too many plots to render, especially for
train-resolved detectors.


Galleries
---------

.. image:: images/MainGUI.png
:width: 800

.. image:: images/ImageTool.png
:width: 800

.. image:: images/pump_probe_window.png
:width: 800

.. image:: images/correlation_window.png
:width: 800

.. image:: images/histogram_window.png
:width: 800

.. image:: images/binning_window.png
:width: 800

.. image:: images/special_suite_tr_xas.png
:width: 800

.. image:: images/special_suite_xas_tim.png
:width: 800

.. image:: images/special_suite_xas_tim_xmcd.png
:width: 800
Loading

0 comments on commit 03117a2

Please sign in to comment.