-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1942 from silx-kit/1941_matplotlib37
Compatibility with matplotlib37
- Loading branch information
Showing
5 changed files
with
168 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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): | ||
|
@@ -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): | ||
|
@@ -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): | ||
|
@@ -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): | ||
|
@@ -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): | ||
|
@@ -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): | ||
|
@@ -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): | ||
|
@@ -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): | ||
|
@@ -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): | ||
|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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] | ||
|
@@ -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): | ||
|
@@ -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): | ||
|
@@ -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): | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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() | ||
|
@@ -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) | ||
|
@@ -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) | ||
|
@@ -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) | ||
|
Oops, something went wrong.