Merge pull request #1249 from kif/ImageD11

Image d11
This commit is contained in:
Valentin Valls 2019-05-16 16:05:18 +02:00 committed by GitHub
commit fc6dbb64c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 127 additions and 4 deletions

View File

@ -1,13 +1,36 @@
:Author: Jérôme Kieffer
:Date: 19/12/2018
:Date: 16/05/2019
:Keywords: changelog
ChangeLog of Versions
=====================
0.18.0 15/05/2019
-----------------
* Last release with Valentin as he finishes his contract soon
* almost 800 commits, 60 PR since the last release: this is a huge release !
* Major rework on all GUIs, mainly pyFAI-calib2 and pyFAI-integrate.
* Possibility to integrate image stacks (i.e. from HDF5), ...
* Rework the *method* to specify the algorithm, pixel splitting and implementation
with sensible fall-backs. Also available via the different GUIs
* 3D visualization of detectors and experimental setup, useful for non flat detectors.
* `integrate1d_ng` is available with histogramming without pixel splitting in
Python, Cython and OpenCL. Now, propagates the variance properly !
* IO sub-packages with associated refactoring for ponifile, json, ...
* Improved management of OpenMP: simplify the code for histograms.
* Improved geometry description and tutorial for writing exchange with other
software (ImageD11, thanks to Carsten Detlefs).
* More reliable simple ellipse fitting with tests and doc.
* Better POCL integration (debugged on cuda, x87, Power9, ...)
* Rely on *silx* mechanics for the build, test, download, GUI, opencl ...
* Many new tutorials, now available on binder-hub: new calibrants, Pilatus calibration, ...
* Fix many issues reported in third-party software (Dioptas, ...)
* Drop support of debian8, Python 2.7 and Python 3.4 on all platforms.
It is likely most functionalities still work but without guaranty.
0.17.0 19/12/2018
-----------------
* Only 200 commits in a couple of month, this ia a small release
* Only 200 commits in a couple of month, this is a small release
* Fix major bugs in pyFAI-calib2 (double validator, initial guess, ring position)
* Constrains have been added to the geometry fitting of pyFAI-calib2
* New pyFAI-integrate graphical application

View File

@ -42,7 +42,7 @@ __author__ = "Jerome Kieffer"
__contact__ = "Jerome.Kieffer@ESRF.eu"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "09/05/2019"
__date__ = "16/05/2019"
__status__ = "production"
__docformat__ = 'restructuredtext'
@ -1439,6 +1439,91 @@ class Geometry(object):
logger.warning("Rotation conversion from pyFAI to SPD is not yet implemented")
return res
def getImageD11(self):
"""Export the current geometry in ImageD11 format.
Please refer to the documentation in doc/source/geometry_conversion.rst
for the orientation and units of those values.
:return: an Ordered dict with those parameters:
distance 294662.658 #in nm
o11 1
o12 0
o21 0
o22 -1
tilt_x 0.00000
tilt_y -0.013173
tilt_z 0.002378
wavelength 0.154
y-center 1016.328171
y-size 48.0815
z-center 984.924425
z-size 46.77648
"""
f2d = self.getFit2D()
distance = f2d.get("directDist", 0) * 1e3 # mm -> µm
y_center = f2d.get("centerX", 0) # in pixel
z_center = f2d.get("centerY", 0) # in pixel
tilt_x = self.rot3
tilt_y = self.rot2
tilt_z = -self.rot1
out = OrderedDict([("distance", distance),
("o11", 1),
("o12", 0),
("o21", 0),
("o22", -1),
("tilt_x", tilt_x),
("tilt_y", tilt_y),
("tilt_z", tilt_z),
])
if self._wavelength:
out["wavelength"] = self.wavelength * 1e9 # nm
if y_center:
out["y-center"] = y_center
out["y-size"] = self.detector.pixel2 * 1e6 # µm
if z_center:
out["z-center"] = z_center
out["z-size"] = self.detector.pixel1 * 1e6 # µm
return out
def setImageD11(self, param):
"""Set the geometry from the parameter set which contains distance,
o11, o12, o21, o22, tilt_x, tilt_y tilt_z, wavelength, y-center, y-size,
z-center and z-size.
Please refer to the documentation in doc/source/geometry_conversion.rst
for the orientation and units of those values.
:param param: dict with the values to set.
"""
o11 = param.get("o11")
if o11 is not None:
assert o11 == 1, "Only canonical orientation is supported"
o12 = param.get("o12")
if o12 is not None:
assert o12 == 0, "Only canonical orientation is supported"
o21 = param.get("o21")
if o21 is not None:
assert o21 == 0, "Only canonical orientation is supported"
o22 = param.get("o22")
if o22 is not None:
assert o22 == -1, "Only canonical orientation is supported"
self.rot3 = param.get("tilt_x", 0.0)
self.rot2 = param.get("tilt_y", 0.0)
self.rot1 = -param.get("tilt_z", 0.0)
distance = param.get("distance", 0.0) * 1e-6 # ->m
self.dist = distance * cos(self.rot2) * cos(self.rot1)
pixel_v = param.get("z-size", 0.0) * 1e-6
pixel_h = param.get("y-size", 0.0) * 1e-6
self.poni1 = -distance * sin(self.rot2) + pixel_v * param.get("z-center", 0.0)
self.poni2 = +distance * cos(self.rot2) * sin(self.rot1) + pixel_h * param.get("y-center", 0.0)
self.detector = detectors.Detector(pixel1=pixel_v, pixel2=pixel_h)
wl = param.get("wavelength")
if wl:
self.wavelength = wl * 1e-9
self.reset()
return self
def set_param(self, param):
"""set the geometry from a 6-tuple with dist, poni1, poni2, rot1, rot2,
rot3

View File

@ -34,7 +34,7 @@ __author__ = "Jérôme Kieffer"
__contact__ = "Jerome.Kieffer@ESRF.eu"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "10/01/2018"
__date__ = "16/05/2019"
import unittest
@ -100,6 +100,21 @@ class TestFIT2D(unittest.TestCase):
res = testExport(tilt=20, tpr=580)
self.assertFalse(res, res)
def test_ImageD11(self):
ai = AzimuthalIntegrator()
ai.setFit2D(100, centerX=900, centerY=1000, tilt=20, tiltPlanRotation=80, pixelX=50, pixelY=60)
ai.wavelength = 1.234e-10
param = ai.getImageD11()
ai2 = AzimuthalIntegrator()
ai2.setImageD11(param)
for key in ["dist", "poni1", "poni2", "rot1", "rot2", "rot3", "pixel1", "pixel2", "splineFile", "wavelength"]:
refv = ai.__getattribute__(key)
obtv = ai2.__getattribute__(key)
if refv is None:
self.assertEqual(refv, obtv, "%s: %s != %s" % (key, refv, obtv))
else:
self.assertAlmostEqual(refv, obtv, 4, "%s: %s != %s" % (key, refv, obtv))
class TestSPD(unittest.TestCase):
poniFile = "Pilatus1M.poni"