Skip to content

crystallography

Classes and function for processing of crystallography data.

This module contains classes and functions that perform common data processing operations for Serial Crystallography (peak finding, radial profile analysis, plot generation, etc.).

CrystallographyPeakFinding

See documentation for the __init__ function.

__init__(*, monitor_parameters, geometry_information)

Crystallography Bragg peak detection.

This class stores all the information required to perform crystallography Bragg peak detection on a detector data frame, using one of the strategies available in OM.

After the class has been initialized, it can be invoked to detect peaks in a data frame.

Parameters:

Name Type Description Default
monitor_parameters MonitorParameters

An object storing OM's configuration parameters. The set of parameters must include a group called crystallography, which in turn must contain the following entries:

  • peakfinding_algorithm: The detection strategy that should be used to detect the Bragg peaks in a detector data frame. Currently, the following strategies are available:

    • peakfinder8_peak_detection: Instructs OM to use the peakfinder8 peak detection strategy. If this strategy is selected, the set of OM's configuration parameters must include a parameter group called peakfinder8_peak_detection with the entries required to fine-tune the peak-finding strategy. Please refer to the documentation of the Peakfinder8PeakDetection algorithm).
  • min_num_peaks_for_hit: The minimum number of peaks that must be identified in a detector data frame for the related data event to be considered a hit.

  • max_num_peaks_for_hit: The maximum number of peaks that must be identified in a detector data frame for the related data event to be considered a hit.

required

find_peaks(detector_data)

Finds peaks in a detector data frame.

This function detects peaks in the provided detector data frame, using the strategy that was selected when the class was initialized. The function returns information about the location, size and intensity of the peaks.

Parameters:

Name Type Description Default
detector_data Union[NDArray[numpy.int_], NDArray[numpy.float_]]

The detector data frame on which the peak-finding operation must be performed.

required

Returns:

Type Description
TypePeakList

A dictionary storing information about the detected peaks.

CrystallographyPlots

See documentation for the __init__ function.

__init__(*, parameters, data_visualizer, pump_probe_experiment, bin_size)

Plots for crystallography data.

This class stores all the information needed to generate and update three plots that summarize the state of a Serial Crystallography experiment: a Virtual Powder Pattern plot, a Hit Rate History plot and a Peakogram plot. Separate Hit Rate History plots for dark and pumped events can be generated for pump-probe experiment.

After the class has been initialized, data event information can be added, and the updated plots can be retrieved and sent to external programs for visualization.

Parameters:

Name Type Description Default
parameters Dict[str, Any]

A set of OM configuration parameters collected together in a parameter group. The parameter group must contain the following entries:

  • peakogram_intensity_bin_size: The size, in ADU units, for each of the intensity bins in the Peakogram plot.

  • peakogram_radius_bin_size: The size, in degrees, for each of the radius bins in the Peakogram plot.

  • running_average_window_size: The size, in number of processed events, of the running window used to compute the smoothed Hit Rate History plot.

required

update_plots(*, timestamp, peak_list, frame_is_hit, optical_laser_active)

Updates and recovers the crystallography data plots.

This function uses the provided information to update all the crystallography data plots generated by this class. The function assumes that all the provided information refers to the same data event.

After updating the data plots, the function returns all the information needed to display them in a graphical interface, in the format of a tuple containing the following entries:

  • A list of timestamps for the events in the Hit Rate History plot. For pump-probe experiments, this list only includes events with an active optical laser.

  • The Hit Rate for all the events in the Hit Rate History plot. For pump-probe experiments, this list only includes events with an active optical laser.

  • A list of timestamps for events without an active optical laser in pump-probe experiments. For non-pump-probe experiments, this list just stores zero values.

  • The Hit Rate for all the events without an active optical laser in the Hit Rate History plot of a pump-probe experiment. For non-pump-probe experiments, this list just stores zero values.

  • A 2D array storing the pixel values of a Virtual Powder Plot image.

  • A 2D array storing the pixel values of a Peakogram Plot image.

  • The size, in degrees, for each of the radius bins in the Peakogram plot

  • The size, in ADU units, for each of the intensity bins in the Peakogram plot.

  • A list storing the x visualization coordinate of each Bragg peak identified in the data event provided to the update function . The coordinate refers to an array storing the assembled detector image, with the origin in the top left corner of the image.

  • A list storing the y visualization coordinate of each Bragg peak identified in the data event provided to the update function . The coordinate refers to an array storing the assembled detector image, with the origin in the top left corner of the image.

Parameters:

Name Type Description Default
timestamp float

The timestamp of the event to which the provided data is attached.float,

required
peak_list TypePeakList

Information about the Bragg peaks identified in the detector data frame attached to the data event.

required
frame_is_hit bool

Whether the data event should be considered a hit, or not.

required
optical_laser_active bool

Whether the optical laser is active or not in the provided data event. This information is only relevant for pump-probe experiments.

required

Returns:

Type Description
Tuple[Deque[float], Deque[float], Deque[float], Deque[float], NDArray[numpy.int_], NDArray[numpy.float_], float, float, List[float], List[float]]

The information needed to display the plots in a graphical interface.

clear_plots()

TODO: Add documentation.