silx-kit / pyFAI

Fast Azimuthal Integration in Python
Other
104 stars 94 forks source link

setting detector distortion array to same size as image causes ValueError #1378

Closed CPrescher closed 4 years ago

CPrescher commented 4 years ago

hi,

when I try to set dx and dy for a detector with arrays of the same size as the image, a ValueError is risen in the calc_cartesian_positions function:

Example code which reproduces the error:

import numpy as np
from pyFAI.detectors import Detector
from pyFAI.calibrant import CalibrantFactory
factory = CalibrantFactory()

img_shape=(2880, 2880)

detector = Detector(150e-6, 150e-6)
detector.max_shape = detector.shape = img_shape

dx = dy = np.ones(shape=img_shape)

detector.set_dx(dx)
detector.set_dy(dy)

from pyFAI.geometryRefinement import GeometryRefinement

pattern_geometry = GeometryRefinement([[1, 1, 0],[2,1,1]],
        dist=1,
        wavelength=0.3344e-10,
        detector=detector,
        calibrant=factory('CeO2'))
kif commented 4 years ago

I'll have a look. Those dx and dy are for the displacements provided by Dectris for their Pilatus detectors, but I know nobody using them, so I am not really surprised that there is a bug hidden there. They should be internally converted into the coordinated of the corners of pixels and this array should be used later on.

The bug you are facing is apparently related to as short-cut for calibration where this is not handled properly.