xrheed.xarray_accessors
Xarray accessors for RHEED (Reflection High-Energy Electron Diffraction) data.
Accessors
ri: for manipulating and analyzing RHEED images, including plotting and image centering.
rp: for manipulating RHEED intensity profiles.
These accessors extend xarray’s DataArray objects with domain-specific methods for RHEED analysis.
Classes
|
Xarray accessor for RHEED images. |
|
Xarray accessor for RHEED intensity profiles. |
- class RHEEDAccessor(xarray_obj)[source]
Bases:
objectXarray accessor for RHEED images.
Provides convenient access to RHEED-specific metadata, image manipulation, centering, rotation, and profile extraction methods.
- property alpha
Alias for azimuthal_angle (read/write).
- property azimuthal_angle
Azimuthal angle in degrees. Stored in attrs as ‘azimuthal_angle’. If present as a coordinate ‘alpha’, returns that instead.
- property beam_energy
Beam energy in eV, if set.
- property beta
Alias for incident_angle (read/write).
- property ewald_radius
Compute the Ewald sphere radius in reciprocal space (k-space).
- Returns:
Ewald sphere radius in 1/Å.
- Return type:
float
- get_profile(center, width, height, stack_index=0, reduce_over='sy', method='mean', show_origin=False, **kwargs)[source]
Extract an intensity profile from the RHEED image or stack.
- Parameters:
center (tuple[float, float]) – Center coordinates (sx, sy) in mm.
width (float) – Width of the profile window in mm.
height (float) – Height of the profile window in mm.
stack_index (int) – Frame index for stacks (default=0).
reduce_over ({'sy', 'sx', 'both'}) – Dimension(s) over which to reduce intensity (default=’sy’).
method ({'mean', 'sum'}) – Reduction method (default=’mean’).
show_origin (bool) – If True, display a rectangle showing the profile window.
- Returns:
Profile data with metadata preserved.
- Return type:
xr.DataArray
- get_roi_image()[source]
Return a copy of the image restricted to the screen ROI.
The ROI is defined by the attributes ‘screen_roi_width’ and ‘screen_roi_height’ (in mm).
- property incident_angle
Incident angle in degrees. Stored in attrs as ‘incident_angle’. If present as a coordinate ‘beta’, returns that instead.
- plot_image(ax=None, auto_levels=0.0, show_center_lines=False, show_specular_spot=False, stack_index=0, **kwargs)[source]
Plot a RHEED image or stack frame.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axes to plot on. If None, a new figure is created.
auto_levels (float) – Automatic contrast adjustment level (default=0.0).
show_center_lines (bool) – If True, show horizontal and vertical center lines.
show_specular_spot (bool) – If True, highlight the specular spot.
stack_index (int) – Frame index for stacks (default=0).
- Returns:
The axes containing the plot.
- Return type:
matplotlib.axes.Axes
- rotate(angle)[source]
Rotate the image or stack of images by a specified angle.
- Parameters:
angle (float) – Rotation angle in degrees. Positive values rotate counterclockwise.
- property screen_roi_height
Height of the region of interest (ROI) on the screen in mm.
- property screen_roi_width
Width of the region of interest (ROI) on the screen in mm.
- property screen_sample_distance
1.0 mm.
- Type:
Distance between sample and screen in mm. Default
- property screen_scale
1.0.
- Type:
Screen scale in px/mm. Default
- property screen_width
Screen width in mm, if set.
- set_center_auto(update_incident_angle=False, stack_index=0)[source]
Automatically determine and apply the image center.
- Parameters:
update_incident_angle (bool, default False) – If True, recomputes and updates the incident angle after centering.
stack_index (int, default 0) – Frame index to use if the data is a stack; ignored otherwise.
- set_center_manual(center_x=0.0, center_y=0.0, method='linear')[source]
Manually shift the image center for a single image or a stack.
- Parameters:
center_x (float or sequence) – Horizontal shift(s). Scalar applied to all frames; array-like must match stack length.
center_y (float or sequence) – Vertical shift(s). Same logic as center_x.
method ({'linear', 'nearest', 'cubic'}, optional) – Interpolation method for per-frame shifts (default=’linear’).
- class RHEEDProfileAccessor(xarray_obj)[source]
Bases:
objectXarray accessor for RHEED intensity profiles.
Provides profile plotting and conversion to reciprocal space.
- convert_to_k()[source]
Convert profile coordinates from screen units (sx) to reciprocal space (ky).
- Returns:
Profile with ‘sx’ replaced by ‘ky’.
- Return type:
xr.DataArray
- plot_profile(ax=None, transform_to_k=True, normalize=True, **kwargs)[source]
Plot a RHEED intensity profile.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axes to plot on. If None, a new figure is created.
transform_to_k (bool) – If True, convert sx to ky using the Ewald sphere.
normalize (bool) – If True, normalize intensity to [0, 1].
- Returns:
The axes containing the plot.
- Return type:
matplotlib.axes.Axes