Skip to content

Commit

Permalink
Merge pull request #1942 from silx-kit/1941_matplotlib37
Browse files Browse the repository at this point in the history
Compatibility with matplotlib37
  • Loading branch information
kif authored Sep 8, 2023
2 parents 6db733e + b6acee4 commit 4c716be
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 152 deletions.
46 changes: 23 additions & 23 deletions pyFAI/detectors/_adsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
__contact__ = "[email protected]"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "16/10/2020"
__date__ = "07/09/2023"
__status__ = "production"

from collections import OrderedDict
Expand All @@ -53,8 +53,8 @@ class _ADSC(Detector):
"""
MANUFACTURER = "ADSC"

def __init__(self, pixel1=51e-6, pixel2=51e-6):
Detector.__init__(self, pixel1=pixel1, pixel2=pixel2)
def __init__(self, pixel1=51e-6, pixel2=51e-6, max_shape=None):
Detector.__init__(self, pixel1=pixel1, pixel2=pixel2, max_shape=max_shape)

def get_config(self):
"""Return the configuration with arguments to the constructor
Expand All @@ -78,8 +78,8 @@ class ADSC_Q315(_ADSC):
MAX_SHAPE = (6144, 6144)
aliases = ["Quantum 315"]

def __init__(self, pixel1=51e-6, pixel2=51e-6):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2)
def __init__(self, pixel1=51e-6, pixel2=51e-6, max_shape=None):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2, max_shape=max_shape)


class ADSC_Q210(_ADSC):
Expand All @@ -95,8 +95,8 @@ class ADSC_Q210(_ADSC):
MAX_SHAPE = (4096, 4096)
aliases = ["Quantum 210"]

def __init__(self, pixel1=51e-6, pixel2=51e-6):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2)
def __init__(self, pixel1=51e-6, pixel2=51e-6, max_shape=None):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2, max_shape=max_shape)


class ADSC_Q270(_ADSC):
Expand All @@ -112,8 +112,8 @@ class ADSC_Q270(_ADSC):
MAX_SHAPE = (4168, 4168)
aliases = ["Quantum 270"]

def __init__(self, pixel1=64.8e-6, pixel2=64.8e-6):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2)
def __init__(self, pixel1=64.8e-6, pixel2=64.8e-6, max_shape=None):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2, max_shape=max_shape)


class ADSC_Q4(_ADSC):
Expand All @@ -129,8 +129,8 @@ class ADSC_Q4(_ADSC):
MAX_SHAPE = (2304, 2304)
aliases = ["Quantum 4"]

def __init__(self, pixel1=82e-6, pixel2=82e-6):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2)
def __init__(self, pixel1=82e-6, pixel2=82e-6, max_shape=None):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2, max_shape=max_shape)


class HF_130K(_ADSC):
Expand All @@ -145,8 +145,8 @@ class HF_130K(_ADSC):
MAX_SHAPE = (256, 512)
aliases = ["HF-130k"]

def __init__(self, pixel1=150e-6, pixel2=150e-6):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2)
def __init__(self, pixel1=150e-6, pixel2=150e-6, max_shape=None):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2, max_shape=max_shape)


class HF_262k(_ADSC):
Expand All @@ -162,8 +162,8 @@ class HF_262k(_ADSC):
MAX_SHAPE = (512, 512)
aliases = ["HF-262k"]

def __init__(self, pixel1=150e-6, pixel2=150e-6):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2)
def __init__(self, pixel1=150e-6, pixel2=150e-6, max_shape=None):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2, max_shape=max_shape)


class HF_1M(_ADSC):
Expand All @@ -179,8 +179,8 @@ class HF_1M(_ADSC):
MAX_SHAPE = (1024, 1024)
aliases = ["HF-1M"]

def __init__(self, pixel1=150e-6, pixel2=150e-6):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2)
def __init__(self, pixel1=150e-6, pixel2=150e-6, max_shape=None):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2, max_shape=max_shape)


class HF_2M(_ADSC):
Expand All @@ -196,8 +196,8 @@ class HF_2M(_ADSC):
MAX_SHAPE = (1536, 1536)
aliases = ["HF-2.4M"]

def __init__(self, pixel1=150e-6, pixel2=150e-6):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2)
def __init__(self, pixel1=150e-6, pixel2=150e-6, max_shape=None):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2, max_shape=max_shape)


class HF_4M(_ADSC):
Expand All @@ -211,8 +211,8 @@ class HF_4M(_ADSC):
MAX_SHAPE = (2048, 2048)
aliases = ["HF-4M"]

def __init__(self, pixel1=150e-6, pixel2=150e-6):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2)
def __init__(self, pixel1=150e-6, pixel2=150e-6, max_shape=None):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2, max_shape=max_shape)


class HF_9M(_ADSC):
Expand All @@ -227,5 +227,5 @@ class HF_9M(_ADSC):
MAX_SHAPE = (3072, 3072)
aliases = ["HF-9.4M"]

def __init__(self, pixel1=150e-6, pixel2=150e-6):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2)
def __init__(self, pixel1=150e-6, pixel2=150e-6, max_shape=None):
_ADSC.__init__(self, pixel1=pixel1, pixel2=pixel2, max_shape=max_shape)
110 changes: 55 additions & 55 deletions pyFAI/detectors/_imxpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
__contact__ = "[email protected]"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "16/10/2020"
__date__ = "08/09/2023"
__status__ = "production"

import functools
Expand Down Expand Up @@ -162,14 +162,14 @@ def get_pixel_corners(self, correct_binning=False):
p2 = mathutil.expand2d(edges2, self.shape[0] + 1, True)
# p3 = None
self._pixel_corners = numpy.zeros((self.shape[0], self.shape[1], 4, 3), dtype=numpy.float32)
self._pixel_corners[:, :, 0, 1] = p1[:-1, :-1]
self._pixel_corners[:, :, 0, 2] = p2[:-1, :-1]
self._pixel_corners[:, :, 1, 1] = p1[1:, :-1]
self._pixel_corners[:, :, 1, 2] = p2[1:, :-1]
self._pixel_corners[:, :, 2, 1] = p1[1:, 1:]
self._pixel_corners[:, :, 2, 2] = p2[1:, 1:]
self._pixel_corners[:, :, 3, 1] = p1[:-1, 1:]
self._pixel_corners[:, :, 3, 2] = p2[:-1, 1:]
self._pixel_corners[:,:, 0, 1] = p1[:-1,:-1]
self._pixel_corners[:,:, 0, 2] = p2[:-1,:-1]
self._pixel_corners[:,:, 1, 1] = p1[1:,:-1]
self._pixel_corners[:,:, 1, 2] = p2[1:,:-1]
self._pixel_corners[:,:, 2, 1] = p1[1:, 1:]
self._pixel_corners[:,:, 2, 2] = p2[1:, 1:]
self._pixel_corners[:,:, 3, 1] = p1[:-1, 1:]
self._pixel_corners[:,:, 3, 2] = p2[:-1, 1:]
# if p3 is not None:
# # non flat detector
# self._pixel_corners[:, :, 0, 0] = p3[:-1, :-1]
Expand Down Expand Up @@ -273,8 +273,8 @@ class ImXPadS70(ImXPadS10):
aliases = ["Imxpad S70"]
PIXEL_EDGES = None # array of size max_shape+1: pixels are contiguous

def __init__(self, pixel1=130e-6, pixel2=130e-6):
ImXPadS10.__init__(self, pixel1=pixel1, pixel2=pixel2)
def __init__(self, pixel1=130e-6, pixel2=130e-6, max_shape=None, module_size=None):
ImXPadS10.__init__(self, pixel1=pixel1, pixel2=pixel2, max_shape=max_shape, module_size=module_size)


class ImXPadS70V(ImXPadS10):
Expand All @@ -289,8 +289,8 @@ class ImXPadS70V(ImXPadS10):
aliases = ["Imxpad S70 V"]
PIXEL_EDGES = None # array of size max_shape+1: pixels are contiguous

def __init__(self, pixel1=130e-6, pixel2=130e-6):
ImXPadS10.__init__(self, pixel1=pixel1, pixel2=pixel2)
def __init__(self, pixel1=130e-6, pixel2=130e-6, max_shape=None, module_size=None):
ImXPadS10.__init__(self, pixel1=pixel1, pixel2=pixel2, max_shape=max_shape, module_size=module_size)


class ImXPadS140(ImXPadS10):
Expand All @@ -304,8 +304,8 @@ class ImXPadS140(ImXPadS10):
force_pixel = True
aliases = ["Imxpad S140"]

def __init__(self, pixel1=130e-6, pixel2=130e-6):
ImXPadS10.__init__(self, pixel1=pixel1, pixel2=pixel2)
def __init__(self, pixel1=130e-6, pixel2=130e-6, max_shape=None, module_size=None):
ImXPadS10.__init__(self, pixel1=pixel1, pixel2=pixel2, max_shape=max_shape, module_size=module_size)


class Xpad_flat(ImXPadS10):
Expand Down Expand Up @@ -361,8 +361,8 @@ def calc_mask(self):
mask = numpy.zeros(self.max_shape, dtype=numpy.int8)
# workinng in dim0 = Y
for i in range(0, self.max_shape[0], self.module_size[0]):
mask[i, :] = 1
mask[i + self.module_size[0] - 1, :] = 1
mask[i,:] = 1
mask[i + self.module_size[0] - 1,:] = 1
# workinng in dim1 = X
for i in range(0, self.max_shape[1], self.module_size[1]):
mask[:, i] = 1
Expand Down Expand Up @@ -407,14 +407,14 @@ def calc_cartesian_positions(self, d1=None, d2=None, center=True, use_cython=Tru
delta1 = d1 - i1
delta2 = d2 - i2
pixels = corners[i1, i2]
A1 = pixels[:, :, 0, 1]
A2 = pixels[:, :, 0, 2]
B1 = pixels[:, :, 1, 1]
B2 = pixels[:, :, 1, 2]
C1 = pixels[:, :, 2, 1]
C2 = pixels[:, :, 2, 2]
D1 = pixels[:, :, 3, 1]
D2 = pixels[:, :, 3, 2]
A1 = pixels[:,:, 0, 1]
A2 = pixels[:,:, 0, 2]
B1 = pixels[:,:, 1, 1]
B2 = pixels[:,:, 1, 2]
C1 = pixels[:,:, 2, 1]
C2 = pixels[:,:, 2, 2]
D1 = pixels[:,:, 3, 1]
D2 = pixels[:,:, 3, 2]
# points A and D are on the same dim1 (Y), they differ in dim2 (X)
# points B and C are on the same dim1 (Y), they differ in dim2 (X)
# points A and B are on the same dim2 (X), they differ in dim1
Expand Down Expand Up @@ -474,14 +474,14 @@ def get_pixel_corners(self, correct_binning=False):
pixel_size2.strides = 0, pixel_size2.strides[1]

corners = numpy.zeros((self.shape[0], self.shape[1], 4, 3), dtype=numpy.float32)
corners[:, :, 0, 1] = pixel_center1 - pixel_size1 / 2.0
corners[:, :, 0, 2] = pixel_center2 - pixel_size2 / 2.0
corners[:, :, 1, 1] = pixel_center1 + pixel_size1 / 2.0
corners[:, :, 1, 2] = pixel_center2 - pixel_size2 / 2.0
corners[:, :, 2, 1] = pixel_center1 + pixel_size1 / 2.0
corners[:, :, 2, 2] = pixel_center2 + pixel_size2 / 2.0
corners[:, :, 3, 1] = pixel_center1 - pixel_size1 / 2.0
corners[:, :, 3, 2] = pixel_center2 + pixel_size2 / 2.0
corners[:,:, 0, 1] = pixel_center1 - pixel_size1 / 2.0
corners[:,:, 0, 2] = pixel_center2 - pixel_size2 / 2.0
corners[:,:, 1, 1] = pixel_center1 + pixel_size1 / 2.0
corners[:,:, 1, 2] = pixel_center2 - pixel_size2 / 2.0
corners[:,:, 2, 1] = pixel_center1 + pixel_size1 / 2.0
corners[:,:, 2, 2] = pixel_center2 + pixel_size2 / 2.0
corners[:,:, 3, 1] = pixel_center1 - pixel_size1 / 2.0
corners[:,:, 3, 2] = pixel_center2 + pixel_size2 / 2.0
self._pixel_corners = corners
if correct_binning and self._pixel_corners.shape[:2] != self.shape:
return self._rebin_pixel_corners()
Expand Down Expand Up @@ -541,8 +541,8 @@ def _rotation(md, rot):
def _translation(md, u):
return md + u

def __init__(self, pixel1=130e-6, pixel2=130e-6):
ImXPadS10.__init__(self, pixel1=pixel1, pixel2=pixel2)
def __init__(self, pixel1=130e-6, pixel2=130e-6, max_shape=None, module_size=None):
ImXPadS10.__init__(self, pixel1=pixel1, pixel2=pixel2, max_shape=max_shape, module_size=module_size)

def _calc_pixels_size(self, length, module_size, pixel_size):
size = numpy.ones(length)
Expand Down Expand Up @@ -590,14 +590,14 @@ def _get_pixel_corners(self):

# Position of the first module
corners = numpy.zeros((self.MEDIUM_MODULE_SIZE[0], self.MEDIUM_MODULE_SIZE[1], 4, 3), dtype=numpy.float32)
corners[:, :, 0, 1] = pixel_center1 - pixel_size1 / 2.0
corners[:, :, 0, 2] = pixel_center2 - pixel_size2 / 2.0
corners[:, :, 1, 1] = pixel_center1 + pixel_size1 / 2.0
corners[:, :, 1, 2] = pixel_center2 - pixel_size2 / 2.0
corners[:, :, 2, 1] = pixel_center1 + pixel_size1 / 2.0
corners[:, :, 2, 2] = pixel_center2 + pixel_size2 / 2.0
corners[:, :, 3, 1] = pixel_center1 - pixel_size1 / 2.0
corners[:, :, 3, 2] = pixel_center2 + pixel_size2 / 2.0
corners[:,:, 0, 1] = pixel_center1 - pixel_size1 / 2.0
corners[:,:, 0, 2] = pixel_center2 - pixel_size2 / 2.0
corners[:,:, 1, 1] = pixel_center1 + pixel_size1 / 2.0
corners[:,:, 1, 2] = pixel_center2 - pixel_size2 / 2.0
corners[:,:, 2, 1] = pixel_center1 + pixel_size1 / 2.0
corners[:,:, 2, 2] = pixel_center2 + pixel_size2 / 2.0
corners[:,:, 3, 1] = pixel_center1 - pixel_size1 / 2.0
corners[:,:, 3, 2] = pixel_center2 + pixel_size2 / 2.0

modules = [self._passage(corners, [self.ROT[0], self.ROT[1], self.ROT[2] * i]) for i in range(20)]
result = numpy.concatenate(modules, axis=0)
Expand Down Expand Up @@ -649,18 +649,18 @@ def calc_cartesian_positions(self, d1=None, d2=None, center=True, use_cython=Tru
D1 = pixels[:, 3, 1]
D2 = pixels[:, 3, 2]
else:
A0 = pixels[:, :, 0, 0]
A1 = pixels[:, :, 0, 1]
A2 = pixels[:, :, 0, 2]
B0 = pixels[:, :, 1, 0]
B1 = pixels[:, :, 1, 1]
B2 = pixels[:, :, 1, 2]
C0 = pixels[:, :, 2, 0]
C1 = pixels[:, :, 2, 1]
C2 = pixels[:, :, 2, 2]
D0 = pixels[:, :, 3, 0]
D1 = pixels[:, :, 3, 1]
D2 = pixels[:, :, 3, 2]
A0 = pixels[:,:, 0, 0]
A1 = pixels[:,:, 0, 1]
A2 = pixels[:,:, 0, 2]
B0 = pixels[:,:, 1, 0]
B1 = pixels[:,:, 1, 1]
B2 = pixels[:,:, 1, 2]
C0 = pixels[:,:, 2, 0]
C1 = pixels[:,:, 2, 1]
C2 = pixels[:,:, 2, 2]
D0 = pixels[:,:, 3, 0]
D1 = pixels[:,:, 3, 1]
D2 = pixels[:,:, 3, 2]

# points A and D are on the same dim1 (Y), they differ in dim2 (X)
# points B and C are on the same dim1 (Y), they differ in dim2 (X)
Expand Down
Loading

0 comments on commit 4c716be

Please sign in to comment.