Skip to content

Commit

Permalink
Merge pull request #528 from vallsv/backport-to-0.13
Browse files Browse the repository at this point in the history
Backport from 0.14-dev to 0.13
  • Loading branch information
kif authored Jan 30, 2017
2 parents 852e542 + 6751433 commit d83592f
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 18 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ addons:
- libqtcore4
#For OpenCL:
- libboost1.48-dev
- libboost-python-dev
- libboost-python1.48
- opencl-headers
- python-pyopencl
Expand Down
8 changes: 8 additions & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
ChangeLog of Versions
=====================

0.13.1: 30/01/2017
------------------

* Backport critical bug fix from 0.14-dev
- Convert matplotlib mouse input into pixel coordinates (fix issue with numpy 0.12)
- Fix eiger-mask script if h5py is not installed
- Use "/usr/bin/env python" for scripts

0.13.0: 01/12/2016
------------------
* Global improvement of tests, packaging, code quality, documentation and project tools
Expand Down
5 changes: 3 additions & 2 deletions pyFAI/massif.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
__contact__ = "[email protected]"
__license__ = "GPLv3+"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "24/11/2016"
__date__ = "12/12/2016"
__status__ = "production"

import sys
Expand Down Expand Up @@ -113,7 +113,8 @@ def find_peaks(self, x, nmax=200, annotate=None, massif_contour=None, stdout=sys
"""
All in one function that finds a maximum from the given seed (x)
then calculates the region extension and extract position of the neighboring peaks.
:param x: seed for the calculation, input coordinates
:param x: coordinates of the peak, seed for the calculation
:type x: tuple of integer
:param nmax: maximum number of peak per region
:param annotate: call back method taking number of points + coordinate as input.
:param massif_contour: callback to show the contour of a massif with the given index.
Expand Down
29 changes: 19 additions & 10 deletions pyFAI/peak_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
__contact__ = "[email protected]"
__license__ = "GPLv3+"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "27/10/2016"
__date__ = "12/12/2016"
__status__ = "production"

import os
Expand Down Expand Up @@ -413,23 +413,28 @@ def common_creation(points, gpt=None):
return gpt

def new_grp(event):
" * Right-click (click+n): try an auto find for a ring"
points = self.massif.find_peaks([event.ydata, event.xdata],
" * new_grp Right-click (click+n): try an auto find for a ring"
# ydata is a float, and matplotlib display pixels centered.
# we use floor (int cast) instead of round to avoid use of
# banker's rounding
ypix, xpix = int(event.ydata + 0.5), int(event.xdata + 0.5)
points = self.massif.find_peaks([ypix, xpix],
self.defaultNbPoints,
None, self.massif_contour)
if points:
gpt = common_creation(points)
annontate(points[0], [event.ydata, event.xdata], gpt=gpt)
annontate(points[0], [ypix, xpix], gpt=gpt)
logger.info("Created group #%2s with %i points", gpt.label, len(gpt))
else:
logger.warning("No peak found !!!")

def single_point(event):
" * Right-click + Ctrl (click+b): create new group with one single point"
newpeak = self.massif.nearest_peak([event.ydata, event.xdata])
ypix, xpix = int(event.ydata + 0.5), int(event.xdata + 0.5)
newpeak = self.massif.nearest_peak([ypix, xpix])
if newpeak:
gpt = common_creation([newpeak])
annontate(newpeak, [event.ydata, event.xdata], gpt=gpt)
annontate(newpeak, [ypix, xpix], gpt=gpt)
logger.info("Create group #%2s with single point x=%5.1f, y=%5.1f", gpt.label, newpeak[1], newpeak[0])
else:
logger.warning("No peak found !!!")
Expand All @@ -445,8 +450,10 @@ def append_more_points(event):
self.ax.lines.remove(gpt.plot[0])

update_fig(self.fig)
# matplotlib coord to pixel coord, avoinding use of banker's round
ypix, xpix = int(event.ydata + 0.5), int(event.xdata + 0.5)
# need to annotate only if a new group:
listpeak = self.massif.find_peaks([event.ydata, event.xdata],
listpeak = self.massif.find_peaks([ypix, xpix],
self.defaultNbPoints, None,
self.massif_contour)
if listpeak:
Expand All @@ -466,7 +473,9 @@ def append_1_point(event):
if gpt.plot[0] in self.ax.lines:
self.ax.lines.remove(gpt.plot[0])
update_fig(self.fig)
newpeak = self.massif.nearest_peak([event.ydata, event.xdata])
# matplotlib coord to pixel coord, avoinding use of banker's round
ypix, xpix = int(event.ydata + 0.5), int(event.xdata + 0.5)
newpeak = self.massif.nearest_peak([ypix, xpix])
if newpeak:
gpt.points.append(newpeak)
logger.info("x=%5.1f, y=%5.1f added to group #%2s", newpeak[1], newpeak[0], gpt.label)
Expand Down Expand Up @@ -511,8 +520,8 @@ def erase_1_point(event):
self.ax.lines.remove(gpt.plot[0])
if len(gpt) > 1:
# delete single closest point from current group
x0 = event.xdata
y0 = event.ydata
# matplotlib coord to pixel coord, avoinding use of banker's round
y0, x0 = int(event.ydata + 0.5), int(event.xdata + 0.5)
distsq = [((p[1] - x0) ** 2 + (p[0] - y0) ** 2) for p in gpt.points]
# index and distance of smallest distance:
indexMin = min(enumerate(distsq), key=operator.itemgetter(1))
Expand Down
21 changes: 18 additions & 3 deletions scripts/eiger-mask
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,28 @@ __author__ = "Jerome Kieffer"
__contact__ = "[email protected]"
__license__ = "GPLv3+"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "28/11/2016"
__date__ = "05/12/2016"
__satus__ = "development"


import os
import sys
import h5py
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("eiger-mask")
import numpy
import fabio

try:
from argparse import ArgumentParser
except ImportError:
from pyFAI.third_party.argparse import ArgumentParser

try:
import h5py
except ImportError:
h5py = None


def extract_mask(infile):
"""
Expand All @@ -65,11 +73,18 @@ def extract_mask(infile):

if __name__ == "__main__":
description = "A tool to extract the mask from an Eiger detector file."
parser = ArgumentParser(description=description)
epilog = None
if h5py is None:
epilog = "Python h5py module is missing. It have to be installed to use this application"
parser = ArgumentParser(description=description, epilog=epilog)
parser.add_argument('input_file', help='Input file. Must be an HDF5 file.')
parser.add_argument('output_file', nargs="?", help='Output file. It can be an msk, tif, or an edf file.')
options = parser.parse_args()

if h5py is None:
logger.error("Python h5py module is expected to use this script")
sys.exit(1)

infile = os.path.abspath(options.input_file)
if options.output_file is not None:
outfile = options.output_file
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
#For Windows with Cuda 64 bits:
#include-dirs: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\include
#library-dirs: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\lib\x64
[build]
executable = /usr/bin/env python
4 changes: 2 additions & 2 deletions version.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
__authors__ = ["Jérôme Kieffer"]
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "02/12/2016"
__date__ = "30/01/2017"
__status__ = "production"
__docformat__ = 'restructuredtext'
__all__ = ["date", "version_info", "strictversion", "hexversion", "debianversion", "calc_hexversion"]
Expand All @@ -67,7 +67,7 @@

MAJOR = 0
MINOR = 13
MICRO = 0
MICRO = 1
RELEV = "final" # <16
SERIAL = 0 # <16

Expand Down

0 comments on commit d83592f

Please sign in to comment.