swaxs#

OnDA Monitor for Crystallography.

This module contains an OnDA Monitor for serial x-ray crystallography experiments.

class SwaxsProcessing(*, parameters)#

OnDA Monitor for Crystallography.

# TODO: Documentation

Parameters:
  • monitor_parameters – An object storing OM’s configuration parameters.

  • parameters (MonitorParameters)

initialize_processing_node(*, node_rank, node_pool_size)#

Initializes the processing nodes for the Crystallography Monitor.

This method overrides the corresponding method of the base class: please also refer to the documentation of that class for more information.

This function initializes the correction and peak finding algorithms, plus some internal counters.

Parameters:
  • node_rank (int) – The OM rank of the current node, which is an integer that unambiguously identifies the current node in the OM node pool.

  • node_pool_size (int) – The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

Return type:

None

initialize_collecting_node(*, node_rank, node_pool_size)#

Initializes the collecting node for the Crystallography Monitor.

This method overrides the corresponding method of the base class: please also refer to the documentation of that class for more information.

This function initializes the data accumulation algorithms and the storage buffers used to compute statistics on the detected Bragg peaks. Additionally, it prepares the data broadcasting socket to send data to external programs.

Parameters:
  • node_rank (int) – The OM rank of the current node, which is an integer that unambiguously identifies the current node in the OM node pool.

  • node_pool_size (int) – The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

Return type:

None

process_data(*, node_rank, node_pool_size, data)#

Processes a detector data frame and extracts Bragg peak information.

This method overrides the corresponding method of the base class: please also refer to the documentation of that class for more information.

This function processes retrieved data events, calibrating and correcting the detector data frames and extracting the Bragg peak information. Finally, it prepares the Bragg peak data (and optionally, the detector frame data) for transmission to to the collecting node.

Parameters:
  • node_rank (int) – The OM rank of the current node, which is an integer that unambiguously identifies the current node in the OM node pool.

  • node_pool_size (int) – The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

  • data (dict[str, Any]) –

    A dictionary containing the data that OM retrieved for the detector data frame being processed.

    • The dictionary keys describe the Data Sources for which OM has retrieved data. The keys must match the source names listed in the required_data entry of OM’s om configuration parameter group.

    • The corresponding dictionary values must store the the data that OM retrieved for each of the Data Sources.

Returns:

A tuple with two entries. The first entry is a dictionary storing the processed data that should be sent to the collecting node. The second entry is the OM rank number of the node that processed the information.

Return type:

tuple[dict[str, Any], int]

wait_for_data(*, node_rank, node_pool_size)#

Receives and handles requests from external programs.

This method overrides the corresponding method of the base class: please also refer to the documentation of that class for more information.

This function receives requests from external programs over a network socket and reacts according to the nature of the request, sending data back to the source of the request or modifying the internal behavior of the monitor.

Parameters:
  • node_rank (int) – The OM rank of the current node, which is an integer that unambiguously identifies the current node in the OM node pool.

  • node_pool_size (int) – The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

Return type:

None

collect_data(*, node_rank, node_pool_size, processed_data)#

Computes statistics on aggregated data and broadcasts them.

This method overrides the corresponding method of the base class: please also refer to the documentation of that class for more information.

This function collects Bragg peak information (and optionally, frame data) from the processing nodes. It computes a rolling average estimation of the hit rate and a virtual powder pattern. It then broadcasts the aggregated information over a network socket for visualization by external programs.

Parameters:
  • node_rank (int) – The OM rank of the current node, which is an integer that unambiguously identifies the current node in the OM node pool.

  • node_pool_size (int) – The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

  • processed_data (Tuple[Dict, int]) – A tuple whose first entry is a dictionary storing the data received from a processing node, and whose second entry is the OM rank number of the node that processed the information.

Return type:

dict[str, dict[str, Any]] | None

end_processing_on_processing_node(*, node_rank, node_pool_size)#

Ends processing actions on the processing nodes.

This method overrides the corresponding method of the base class: please also refer to the documentation of that class for more information.

This function prints a message on the console and ends the processing.

Parameters:
  • node_rank (int) – The OM rank of the current node, which is an integer that unambiguously identifies the current node in the OM node pool.

  • node_pool_size (int) – The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

Returns:

Usually nothing. Optionally, a dictionary storing information to be sent to the processing node.

Return type:

dict[str, Any] | None

end_processing_on_collecting_node(*, node_rank, node_pool_size)#

Ends processing on the collecting node.

This method overrides the corresponding method of the base class: please also refer to the documentation of that class for more information.

This function prints a message on the console and ends the processing.

Parameters:
  • node_rank (int) – The OM rank of the current node, which is an integer that unambiguously identifies the current node in the OM node pool.

  • node_pool_size (int) – The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

Return type:

None

class SwaxsCheetahProcessing(*, parameters)#

OnDA Monitor for Crystallography.

# TODO: Documentation

Parameters:
  • monitor_parameters – An object storing OM’s configuration parameters.

  • parameters (MonitorParameters)

initialize_processing_node(*, node_rank, node_pool_size)#

Initializes the processing nodes for the Crystallography Monitor.

This method overrides the corresponding method of the base class: please also refer to the documentation of that class for more information.

This function initializes the correction and peak finding algorithms, plus some internal counters.

Parameters:
  • node_rank (int) – The OM rank of the current node, which is an integer that unambiguously identifies the current node in the OM node pool.

  • node_pool_size (int) – The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

Return type:

None

initialize_collecting_node(*, node_rank, node_pool_size)#

Initializes the collecting node for the Crystallography Monitor.

This method overrides the corresponding method of the base class: please also refer to the documentation of that class for more information.

This function initializes the data accumulation algorithms and the storage buffers used to compute statistics on the detected Bragg peaks. Additionally, it prepares the data broadcasting socket to send data to external programs.

Parameters:
  • node_rank (int) – The OM rank of the current node, which is an integer that unambiguously identifies the current node in the OM node pool.

  • node_pool_size (int) – The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

Return type:

None

process_data(*, node_rank, node_pool_size, data)#

Processes a detector data frame and extracts Bragg peak information.

This method overrides the corresponding method of the base class: please also refer to the documentation of that class for more information.

This function processes retrieved data events, calibrating and correcting the detector data frames and extracting the Bragg peak information. Finally, it prepares the Bragg peak data (and optionally, the detector frame data) for transmission to to the collecting node.

Parameters:
  • node_rank (int) – The OM rank of the current node, which is an integer that unambiguously identifies the current node in the OM node pool.

  • node_pool_size (int) – The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

  • data (dict[str, Any]) –

    A dictionary containing the data that OM retrieved for the detector data frame being processed.

    • The dictionary keys describe the Data Sources for which OM has retrieved data. The keys must match the source names listed in the required_data entry of OM’s om configuration parameter group.

    • The corresponding dictionary values must store the the data that OM retrieved for each of the Data Sources.

Returns:

A tuple with two entries. The first entry is a dictionary storing the processed data that should be sent to the collecting node. The second entry is the OM rank number of the node that processed the information.

Return type:

tuple[dict[str, Any], int]

wait_for_data(*, node_rank, node_pool_size)#

Receives and handles requests from external programs.

This method overrides the corresponding method of the base class: please also refer to the documentation of that class for more information.

This function receives requests from external programs over a network socket and reacts according to the nature of the request, sending data back to the source of the request or modifying the internal behavior of the monitor.

Parameters:
  • node_rank (int) – The OM rank of the current node, which is an integer that unambiguously identifies the current node in the OM node pool.

  • node_pool_size (int) – The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

Return type:

None

collect_data(*, node_rank, node_pool_size, processed_data)#

Computes statistics on aggregated data and broadcasts them.

This method overrides the corresponding method of the base class: please also refer to the documentation of that class for more information.

This function collects Bragg peak information (and optionally, frame data) from the processing nodes. It computes a rolling average estimation of the hit rate and a virtual powder pattern. It then broadcasts the aggregated information over a network socket for visualization by external programs.

Parameters:
  • node_rank (int) – The OM rank of the current node, which is an integer that unambiguously identifies the current node in the OM node pool.

  • node_pool_size (int) – The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

  • processed_data (Tuple[Dict, int]) – A tuple whose first entry is a dictionary storing the data received from a processing node, and whose second entry is the OM rank number of the node that processed the information.

Return type:

dict[str, dict[str, Any]] | None

end_processing_on_processing_node(*, node_rank, node_pool_size)#

Ends processing actions on the processing nodes.

This method overrides the corresponding method of the base class: please also refer to the documentation of that class for more information.

This function prints a message on the console and ends the processing.

Parameters:
  • node_rank (int) – The OM rank of the current node, which is an integer that unambiguously identifies the current node in the OM node pool.

  • node_pool_size (int) – The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

Returns:

Usually nothing. Optionally, a dictionary storing information to be sent to

the processing node.

Return type:

dict[str, Any] | None

end_processing_on_collecting_node(*, node_rank, node_pool_size)#

Ends processing on the collecting node.

This method overrides the corresponding method of the base class: please also refer to the documentation of that class for more information.

This function prints a message on the console and ends the processing.

Parameters:
  • node_rank (int) – The OM rank of the current node, which is an integer that unambiguously identifies the current node in the OM node pool.

  • node_pool_size (int) – The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

Return type:

None