get_pattern_from_pixel_coordinates_and_intensities#

diffsims.pattern.detector_functions.get_pattern_from_pixel_coordinates_and_intensities(coordinates: ndarray, intensities: ndarray, shape: Tuple[int, int], sigma: float, clip_threshold: float = 1) ndarray[source]#

Generate a diffraction pattern from spot pixel-coordinates and intensities, using a gaussian blur. This is subpixel-precise, meaning the coordinates can be floats. Values less than clip_threshold are rounded down to 0 to simplify computation.

Parameters:
coordinatesnp.ndarray

Coordinates of reflections, in pixels. Shape (n, 2) or (n, 3). Can be floats

intensitiesnp.ndarray

Intensities of each reflection. Must have same same first dimension as coordinates

shapetuple[int, int]

Output shape

sigmafloat

For Gaussian blur

intensity_scalefloat

Scale to multiply the final diffraction pattern with

Returns:
np.ndarray

dtype int

Notes

Not all values below the clipping threshold are ignored. The threshold is used to estimate a radius (box) around each reflection where the pixel intensity is greater than the threshold. As the radius is rounded up and as the box is square rather than circular, some values below the threshold can be included.

When using float coordinates, the intensity is spread as if the edge was not there. This is in line with what should be expected from a beam on the edge of the detector, as part of the beam is simply outside the detector area. However, when using integer coordinates, the total intensity is preserved for the pixels in the pattern. This means that the intensity contribution from parts of the beam which would hit outside the detector are now kept in the pattern. Thus, reflections wich are partially outside the detector will have higher intensities than expected, when using integer coordinates.