xrheed.kinematics.ewald

Classes

Ewald(lattice[, rheed_data, stack_index])

Class for calculating and analyzing the Ewald sphere construction in RHEED.

class Ewald(lattice, rheed_data=None, stack_index=0)[source]

Bases: object

Class for calculating and analyzing the Ewald sphere construction in RHEED.

This class combines experimental RHEED image metadata with a reciprocal lattice model to predict diffraction spot positions on the screen.

Azimuthal angle convention

Three azimuthal angles are distinguished:

  • image_azimuthal_angle

    Experimental azimuth of the RHEED image, read from image metadata. This value defines the reference frame and is treated as immutable.

  • ewald_azimuthal_rotation

    User-defined relative rotation of the Ewald construction with respect to the image azimuth. This does not modify the image metadata.

  • Ewald azimuthal angles (effective)

    The azimuthal angles actually used in the Ewald construction, derived as

    image_azimuthal_angle ± ewald_azimuthal_rotation

    When mirror symmetry is enabled, both ± rotations are used.

This separation preserves the experimental reference frame while allowing controlled relative rotation of the theoretical Ewald construction.

NO_IMAGE_DEFAULTS = {'azimuthal_angle': 0.0, 'beam_energy': 18600.0, 'incident_angle': 1.0, 'screen_roi_height': 80.0, 'screen_roi_width': 60.0, 'screen_sample_distance': 309.2, 'screen_scale': 9.5}
REQUIRED_IMAGE_ATTRS = ('beam_energy', 'screen_sample_distance', 'screen_scale', 'incident_angle', 'azimuthal_angle')
SPOT_HEIGHT_MM = 5.0
SPOT_WIDTH_MM = 1.5
__init__(lattice, rheed_data=None, stack_index=0)[source]
calculate_ewald(**kwargs)[source]

Calculate the Ewald construction and update spot positions.

Updates

self.ew_sxNDArray

Spot x-coordinates (mm).

self.ew_syNDArray

Spot y-coordinates (mm).

calculate_match(normalize=True)[source]
property ewald_azimuthal_angle
property ewald_azimuthal_rotation
property ewald_roi
image
property image_azimuthal_angle
property incident_angle
property lattice_scale
match_alpha(alpha_vector, normalize=True, tqdm_disable=True)[source]
match_alpha_scale(alpha_vector, scale_vector, normalize=True, flatten=True, tqdm_disable=True)[source]
match_scale(scale_vector, normalize=True, tqdm_disable=True)[source]
plot(ax=None, show_image=True, show_roi=False, auto_levels=0.0, show_center_lines=False, **kwargs)[source]

Plot the calculated spot positions and optionally the RHEED image.

Parameters:
  • ax (Optional[Axes], optional) – Matplotlib axes to plot on. If None, a new figure is created.

  • show_image (bool, optional) – If True, plot the RHEED image (default: True).

  • show_roi (bool, optional) – If True, overlay the ROI boundary (default: False).

  • auto_levels (float, optional) – Contrast enhancement factor for image plotting.

  • show_center_lines (bool, optional) – If True, plot center cross lines (default: False).

  • **kwargs – Additional keyword arguments for the scatter plot.

Returns:

The axes with the plotted data.

Return type:

matplotlib.axes.Axes

plot_spots(ax=None, show_image=False, **kwargs)[source]

Plot the spot mask used for spot matching on a RHEED image.

Parameters:
  • ax (matplotlib.axes.Axes, optional) – Matplotlib Axes to plot on. If None, a new figure and axes are created.

  • show_image (bool, default=False) – If True, overlay the spot mask on the original RHEED image. If False, only the mask is displayed.

  • **kwargs – Additional keyword arguments passed to ax.imshow(), e.g., cmap, alpha.

Returns:

The axes containing the plotted mask (and optionally the image).

Return type:

matplotlib.axes.Axes

Raises:

ValueError – If show_image=True but no RHEED image is attached (self.image is None).

Notes

  • The mask is automatically generated by self._generate_mask().

  • The image coordinates (sx, sy) are used to set the extent of the plot.

  • The default colormap for the mask is grayscale.

set_spot_size(width, height)[source]

Set the spot size used for mask generation.

Parameters:
  • width (float) – Spot width in mm.

  • height (float) – Spot height in mm.

property stack_index

Index of the current image in a stack.

Type:

int