|
36 | 36 | __contact__ = "Jerome.Kieffer@esrf.fr" |
37 | 37 | __license__ = "MIT" |
38 | 38 | __copyright__ = "2015-2025 European Synchrotron Radiation Facility, Grenoble, France" |
39 | | -__date__ = "20/11/2025" |
| 39 | +__date__ = "17/12/2025" |
40 | 40 |
|
41 | 41 | import sys |
42 | 42 | import os |
|
45 | 45 | import subprocess |
46 | 46 | import copy |
47 | 47 | import logging |
| 48 | +from math import pi |
48 | 49 | from .utilstest import UtilsTest |
49 | 50 | from ..utils import mathutil |
50 | 51 | import fabio |
51 | 52 | from .. import load |
52 | 53 | from ..integrator.azimuthal import AzimuthalIntegrator |
53 | 54 | from .. import detectors |
54 | 55 | from .. import units |
55 | | -from math import pi |
56 | 56 | from ..opencl import ocl |
| 57 | +from ..ext import splitPixel |
57 | 58 | logger = logging.getLogger(__name__) |
58 | 59 |
|
59 | 60 | try: |
@@ -691,6 +692,42 @@ def test_bug_2697(self): |
691 | 692 | res = numpy.isnan(ai.integrate1d(fimg.data, 300, method=("no","csr", "cython"), error_model="azimuth").sum_variance).sum() |
692 | 693 | self.assertEqual(res, 0, "No NaNs found in Cython") |
693 | 694 |
|
| 695 | + def test_bug_2736(self): |
| 696 | + """Checks the pixel splitting with boundaries, see tutorial entitled PixelSplitting""" |
| 697 | + ai = load({"dist":1, |
| 698 | + "poni1":2.2e-3, |
| 699 | + "poni2":2.8e-3, |
| 700 | + "rot3":-0.3, |
| 701 | + "detector":"Detector", |
| 702 | + "detector_config":{"pixel1":1e-3, |
| 703 | + "pixel2":1e-3, |
| 704 | + "max_shape":(5,5)} |
| 705 | + }) |
| 706 | + ai.setChiDiscAtPi() |
| 707 | + pos = numpy.array(ai.array_from_unit(typ="corner", unit="r_mm", scale=True), dtype="float64") |
| 708 | + self.assertEqual((pos[..., 1]< -pi).sum(), 0, "No pixels below pi azim angle") |
| 709 | + self.assertEqual((pos[..., 1]> +pi).sum(), 0, "No pixels above pi azim angle") |
| 710 | + for i0 in range(pos.shape[0]): |
| 711 | + for i1 in range(pos.shape[1]): |
| 712 | + p = pos[i0, i1] |
| 713 | + splitPixel.recenter(p, chiDiscAtPi=True) |
| 714 | + self.assertEqual((pos[..., 1]< -pi).sum(), 5, "5 pixels below pi azim angle") |
| 715 | + self.assertEqual((pos[..., 1]> +pi).sum(), 1, "1 pixels above pi azim angle") |
| 716 | + |
| 717 | + # Change origin to zero |
| 718 | + ai.setChiDiscAtZero() |
| 719 | + pos = numpy.array(ai.array_from_unit(typ="corner", unit="r_mm", scale=True), dtype="float64") |
| 720 | + self.assertEqual((pos[..., 1]< 0).sum(), 0, "No pixels below 0 azim angle") |
| 721 | + self.assertEqual((pos[..., 1]> 2*pi).sum(), 0, "No pixels above 2pi azim angle") |
| 722 | + for i0 in range(pos.shape[0]): |
| 723 | + for i1 in range(pos.shape[1]): |
| 724 | + p = pos[i0, i1] |
| 725 | + splitPixel.recenter(p, chiDiscAtPi=False) |
| 726 | + self.assertEqual((pos[..., 1]< 0).sum(), 1, "1 pixels below pi azim angle") |
| 727 | + self.assertEqual((pos[..., 1]> 2*pi).sum(), 3, "3 pixels above pi azim angle") |
| 728 | + |
| 729 | + |
| 730 | + |
694 | 731 | class TestBug1703(unittest.TestCase): |
695 | 732 | """ |
696 | 733 | Check the normalization affect properly the propagated errors/intensity |
|
0 commit comments