The geometry_utils Module

Geometry utilities.

This module contains functions that manipulate geometry information.

compute_pix_maps(geometry)[source]

Computes pixel maps from CrystFEL geometry information.

This function takes as input some geometry information read from a CrystFEL file, and returns a set of pre-computed pixel maps.

The origin and the orientation of the reference system for the pixel maps are set according to the same conventions as CrystFEL:

  • The center of the reference system is the beam interaction point.
  • +z is the beam direction, and points along the beam (i.e. away from the source).
  • +y points towards the zenith (ceiling).
  • +x completes the right-handed coordinate system.
Parameters:geometry (Dict[str, Any]) – a CrystFEL geometry object (A dictionary returned by the load_crystfel_geometry() function).
Returns:a named tuple storing the the pixel maps.
Return type:PixelMaps
compute_visualization_pix_maps(geometry)[source]

Computes pixel maps for data visualization from CrystFEL geometry information.

This function takes as input some geometry information read from a CrystFEL file, and returns a set of pre-computed pixel maps that can be used to display data in an ImageView widget (from the PyQtGraph library).

These pixel maps are different from the ones generated by the compute_pix_maps() function. The main differences are:

  • The origin of the reference system is not the beam interaction point, but the top left corner of the array used to visualize the data.
  • Only the x and y pixel maps are available. The other entries in the returned named tuple (z, r and phi) are set to None.
Parameters:geometry (Dict[str, Any]) – a CrystFEL geometry object (A dictionary returned by the load_crystfel_geometry() function).
Returns:a named tuple with the pixel maps.
Return type:PixelMaps
apply_geometry_to_data(data, geometry)[source]

Applies CrystFEL geometry information to some data.

This function takes as input some geometry information read from a CrystFEL file, and some data on which to apply the information. It returns an array that can be displayed using libraries like matplotlib or PyQtGraph.

The shape of the returned array is big enough to display all the pixel values in the input data, and is symmetric around the center of the reference system (i.e: the beam interaction point).

These restrictions often cause the returned array to be bigger than the minimum size needed to store the physical layout of the pixels in the detector, particularly if the detector is not centered at the beam interaction point.

Parameters:
  • data (numpy.ndarray) – the data on which the geometry information should be applied.
  • geometry (Dict[str, Any]) – a CrystFEL geometry object (A dictionary returned by the load_crystfel_geometry() function).
Returns:

an array containing the data with the geometry information applied.

Return type:

numpy.ndarray