<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""SpecfileData object mapped with a stack of EDF images

Description
===========

Utility object to connect a given scan in a SPEC file with a series
(stack) of EDF (ESRF data format) images, usually collected with a
two-dimensional detector (2D detector) during a scan
(e.g. monochromator energy scan).


STATUS
======

The current version is not generic nor stable. It should not be used
as it is, but only considered as an example. Here an elastic peak scan
from a crystal analyzer is evaluated. It permits to make/plot/save an
animation with Matplotlib.

Related
=======

- XRStools

"""

__author__ = "<NAME>"
__email__ = "<EMAIL>"
__credits__ = "<NAME> (ESRF)"
__license__ = "BSD license <http://opensource.org/licenses/BSD-3-Clause>"
__organization__ = "European Synchrotron Radiation Facility"
__year__ = "2015"

import os, sys
import copy
import numpy as np
import weakref

### Matplotlib imports
import matplotlib.pyplot as plt
from matplotlib import cm, animation
from matplotlib import gridspec

### PyMca5 imports
from PyMca5.PyMcaIO import EdfFile
from PyMca5.PyMcaGui import PyMcaQt as qt
from PyMca5.PyMcaGui.plotting import MaskImageWidget, ImageView

### local imports
from specfiledata import SpecfileData

### UTIL CLASS ###
class RadarViewWithOverlay(ImageView.RadarView):
    """RadarView subclass adding a text overlay and a limitsChanged
listener."""

    def __init__(self, imageView, *args, **kwargs):
        self._imageView = weakref.proxy(imageView)
        self._text = ''
        self._imageView._imagePlot.sigPlotSignal.connect(self.limitsChanged)

        super(RadarViewWithOverlay, self).__init__(*args, **kwargs)

    def limitsChanged(self, event):
        if event['event'] != 'limitsChanged':
            return

        # Get histogram info for each axis
        histoX = self._imageView.getHistogram('x')
        xHisto = histoX['data']  # histogram<commit_msg>bug fix + plot_stack w silx<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""SpecfileData object mapped with a stack of EDF images

Description
===========

Utility object to connect a given scan in a SPEC file with a series
(stack) of EDF (ESRF data format) images, usually collected with a
two-dimensional detector (2D detector) during a scan
(e.g. monochromator energy scan).


STATUS
======

The current version is not generic nor stable. It should not be used
as it is, but only considered as an example. Here an elastic peak scan
from a crystal analyzer is evaluated. It permits to make/plot/save an
animation with Matplotlib.

Related
=======

- XRStools

"""

__author__ = "<NAME>"
__email__ = "<EMAIL>"
__credits__ = "<NAME> (ESRF)"
__license__ = "BSD license <http://opensource.org/licenses/BSD-3-Clause>"

import os, sys
import copy
import numpy as np
import weakref

### Matplotlib imports
import matplotlib.pyplot as plt
from matplotlib import cm, animation
from matplotlib import gridspec

### PyMca5 imports
from PyMca5.PyMcaIO import EdfFile
from PyMca5.PyMcaGui import PyMcaQt as qt
from PyMca5.PyMcaGui.plotting import MaskImageWidget, ImageView

### SILX imports
HAS_SILX = False
try:
    from silx.gui.plot.StackView import StackViewMainWindow
    HAS_SILX = True
except:
    pass

### local imports
from .specfile_reader import SpecfileData

### UTIL CLASS ###
class RadarViewWithOverlay(ImageView.RadarView):
    """RadarView subclass adding a text overlay and a limitsChanged
listener."""

    def __init__(self, imageView, *args, **kwargs):
        self._imageView = weakref.proxy(imageView)
        self._text = ''
        self._imageView._imagePlot.sigPlotSignal.connect(self.limitsChanged)

        super(RadarViewWithOverlay, self).__init__(*args, **kwargs)

    def limitsChanged(self, event):
        if event['event'] != 'limitsChanged':
            return

        # Get histogram info for each axis
        histoX = self._imageView.getHistogram('x')
        xHisto = histoX['data']  # histogram
{'fraction_non_alphanumeric': 0.10134797803295058, 'fraction_numerical': 0.0044932601098352475, 'mean_word_length': 4.03391959798995, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5507709', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1197, 'n_words': 419}