def test4d(self): Nx = 1000 Ny = 1024 y, x = numpy.mgrid[:Ny + 1, :Nx + 1] y = y.astype(float) x = x.astype(float) pos = bilinear.convert_corner_2D_to_4D(3, y, x) y1, x1, z1 = bilinear.calc_cartesian_positions(y.ravel(), x.ravel(), pos) self.assert_(numpy.allclose(y.ravel(), y1), "Maximum error on y is %s" % (abs(y.ravel() - y1).max())) self.assert_(numpy.allclose(x.ravel(), x1), "Maximum error on x is %s" % (abs(x.ravel() - x1).max())) self.assertEqual(z1, None, "flat detector") x = x[:-1, :-1] + 0.5 y = y[:-1, :-1] + 0.5 y1, x1, z1 = bilinear.calc_cartesian_positions((y).ravel(), (x).ravel(), pos) self.assert_( numpy.allclose(y.ravel(), y1), "Maximum error on y_center is %s" % (abs(y.ravel() - y1).max())) self.assert_( numpy.allclose(x.ravel(), x1), "Maximum error on x_center is %s" % (abs(x.ravel() - x1).max())) self.assertEqual(z1, None, "flat detector")
def build_detector(data, filename="filename.h5", flat=False): """ """ det = pyFAI.detectors.Xpad_flat() det._pixel_corners = numpy.zeros((det.shape[0], det.shape[1], 4, 3), dtype="float32") det.uniform_pixel = False det.IS_FLAT = flat det._pixel1 = pix det._pixel2 = pix det.mask = None for j in range(ny): for i in range(nx): k = j * nx + i module = bilinear.convert_corner_2D_to_4D(3, *one_module(data[2 * k], data[2 * k + 1], flat)) det._pixel_corners[(j * dy):(j + 1) * dy, i * dx:(i + 1) * dx, :, :] = module det.save(filename) return det
def build_detector(data, filename="filename.h5", flat=False): """ """ det = pyFAI.detectors.Xpad_flat() det._pixel_corners = numpy.zeros((det.shape[0], det.shape[1], 4, 3), dtype="float32") det.uniform_pixel = False det.IS_FLAT = flat det._pixel1 = pix det._pixel2 = pix det.mask = None for j in range(ny): for i in range(nx): k = j * nx + i module = bilinear.convert_corner_2D_to_4D(3, *one_module(data[2 * k], data[2 * k + 1], flat)) det._pixel_corners[(j * dy):(j + 1) * dy, i * dx:(i + 1) * dx, :, :] = module det.save(filename) return det
def test4d(self): Nx = 1000 Ny = 1024 y, x = numpy.mgrid[: Ny + 1, : Nx + 1] y = y.astype(float) x = x.astype(float) pos = bilinear.convert_corner_2D_to_4D(3, y, x) y1, x1, z1 = bilinear.calc_cartesian_positions(y.ravel(), x.ravel(), pos) self.assert_(numpy.allclose(y.ravel(), y1), "Maximum error on y is %s" % (abs(y.ravel() - y1).max())) self.assert_(numpy.allclose(x.ravel(), x1), "Maximum error on x is %s" % (abs(x.ravel() - x1).max())) self.assertEqual(z1, None, "flat detector") x = x[:-1, :-1] + 0.5 y = y[:-1, :-1] + 0.5 y1, x1, z1 = bilinear.calc_cartesian_positions((y).ravel(), (x).ravel(), pos) self.assert_(numpy.allclose(y.ravel(), y1), "Maximum error on y_center is %s" % (abs(y.ravel() - y1).max())) self.assert_(numpy.allclose(x.ravel(), x1), "Maximum error on x_center is %s" % (abs(x.ravel() - x1).max())) self.assertEqual(z1, None, "flat detector")