abtem.waves

Contents

abtem.waves#

Module for describing wave functions of the electron beam and the exit wave.

Module Contents#

Classes#

BaseWaves

Base class of all wave functions.

EnergyEnsemble

Wraps electron energy for use inside the WavesBuilder ensemble machinery.

PlaneWave

Represents electron probe wave functions for simulating experiments with a plane- wave probe, such as HRTEM and SAED.

Probe

Represents electron-probe wave functions for simulating experiments with a convergent beam, such as CBED and STEM.

Waves

Waves define a batch of arbitrary 2D wave functions defined by a complex array.

WavesBuilder

Functions#

reduce_ensemble

Reduce an ensemble of wave functions or measurements by squeezing or averaging ensemble axes tagged for reduction with the “_squeeze” or “_ensemble_mean” attribute of the axis metadata.

validate_energy

Convert energy (float, list, distribution, or EnergyEnsemble) to EnergyEnsemble.

API#

class abtem.waves.BaseWaves[source]#

Bases: abtem.core.grid.HasGrid2DMixin, abtem.core.energy.HasAcceleratorMixin

Base class of all wave functions.

Documented in the subclasses.

property angular_sampling: tuple[float, float]#

Reciprocal-space sampling in units of scattering angles [mrad].

property antialias_cutoff_gpts: tuple[int, int]#

The number of grid points along the x and y direction in the simulation grid at the antialiasing cutoff scattering angle.

property antialias_valid_gpts: tuple[int, int]#

The number of grid points along the x and y direction in the simulation grid for the largest rectangle that fits within antialiasing cutoff scattering angle.

property base_axes_metadata: list[AxisMetadata]#

List of AxisMetadata for the base axes in real space.

property cutoff_angles: tuple[float, float]#

Scattering angles at the antialias cutoff [mrad].

property cutoff_frequencies: tuple[float, float]#

Spatial frequencies at the antialias cutoff [1/Å].

abstract property device: str#

The device where the waves are built or stored.

property dtype: dtype#

The datatype of waves.

property full_cutoff_angles: tuple[float, float]#

Scattering angles corresponding to the full wave function size [mrad].

abstract property metadata: dict#

Metadata stored as a dictionary.

property reciprocal_space_axes_metadata: list[AxisMetadata]#

List of AxisMetadata for base axes in reciprocal space.

property rectangle_cutoff_angles: tuple[float, float]#

Scattering angles corresponding to the sides of the largest rectangle within the antialias cutoff [mrad].

class abtem.waves.EnergyEnsemble(...)[source]#

Bases: abtem.distributions.EnsembleFromDistributions

Wraps electron energy for use inside the WavesBuilder ensemble machinery.

Accepts a scalar float, a list/array of floats, or a BaseDistribution. When a single value is given, the object behaves like a plain scalar. When multiple values are given, it acts as an ensemble axis and causes WavesBuilder subclasses to produce output with a leading EnergyAxis.

The energy property returns:

  • float — for a scalar energy or a single-element sequence.

  • BaseDistribution — for a genuine multi-energy ensemble.

  • None — if no energy has been set.

Initialization

property energy#

Return the energy value(s).

Returns:

  • float – The scalar energy [eV] if a single value was given.

  • BaseDistribution – The full distribution if multiple values were given.

  • None – If no energy has been set.

property ensemble_axes_metadata: list#
class abtem.waves.PlaneWave(...)[source]#

Bases: abtem.waves.WavesBuilder

Represents electron probe wave functions for simulating experiments with a plane- wave probe, such as HRTEM and SAED.

Parameters:
  • extent (two float, optional) – Lateral extent of the wave function [Å].

  • gpts (two int, optional) – Number of grid points describing the wave function.

  • sampling (two float, optional) – Lateral sampling of the wave functions [Å]. If ‘gpts’ is also given, will be ignored.

  • energy (float or list of float, optional) – Electron energy [eV]. A single float gives a standard single-energy simulation. A list or array of floats runs the simulation at each energy in turn and returns output with a leading EnergyAxis ensemble dimension. If not provided, the energy must be inferred from attached wave functions.

  • normalize (bool, optional) – If true, normalizes the wave function such that its reciprocal space intensity sums to one. If false, the wave function takes a value of one everywhere.

  • tilt (two float, optional) – Small-angle beam tilt [mrad] (default is (0., 0.)). Implemented by shifting the wave functions at every slice.

  • device (str, optional) – The wave functions are stored on this device (‘cpu’ or ‘gpu’). The default is determined by the user configuration.

Initialization

build(...) Waves[source]#

Build plane-wave wave functions.

Parameters:
  • lazy (bool, optional) – If True, create the wave functions lazily, otherwise, calculate instantly. If not given, defaults to the setting in the user configuration file.

  • max_batch (int or str, optional) – The number of wave functions in each chunk of the Dask array. If ‘auto’ (default), the batch size is automatically chosen based on the abtem user configuration settings “dask.chunk-size” and “dask.chunk-size-gpu”.

Returns:

plane_waves – The wave functions.

Return type:

Waves

check_can_build()[source]#
property energy#
property metadata#
multislice(...) BaseMeasurements | Waves | list[BaseMeasurements | Waves][source]#

Run the multislice algorithm, after building the plane-wave wave function as needed. The grid of the wave functions will be set to the grid of the potential.

Parameters:
  • potential (BasePotential, Atoms) – The potential through which to propagate the wave function. Optionally atoms can be directly given.

  • detectors (Detector, list of detectors, optional) – A detector or a list of detectors defining how the wave functions should be converted to measurements after running the multislice algorithm.

  • max_batch (int, optional) – The number of wave functions in each chunk of the Dask array. If ‘auto’ (default), the batch size is automatically chosen based on the abtem user configuration settings “dask.chunk-size” and “dask.chunk-size-gpu”.

  • lazy (bool, optional) – If True, create the wave functions lazily, otherwise, calculate instantly. If None, this defaults to the setting in the user configuration file.

  • potential_chunk_size (int or str, optional) – Number of potential slices to build and hold in memory at once. "auto" (default) selects a size based on the available memory budget. Smaller values reduce peak memory at the cost of more build overhead. Can be set globally via the potential.slice-chunk-size configuration key.

  • **multislice_func_kwargs – Additional keyword arguments passed to the multislice function.

Returns:

  • measurements (BaseMeasurements or ComputableList of BaseMeasurements) – The detected measurement (if detector(s) given).

  • exit_waves (Waves) – Wave functions at the exit plane(s) of the potential (if no detector(s) given).

property normalize#

True if the created waves are normalized in reciprocal space.

property tilt#

The small-angle tilt of applied to the Fresnel propagator [mrad].

class abtem.waves.Probe(...)[source]#

Bases: abtem.waves.WavesBuilder

Represents electron-probe wave functions for simulating experiments with a convergent beam, such as CBED and STEM.

Parameters:
  • semiangle_cutoff (float, optional) – The cutoff semiangle of the aperture [mrad]. Ignored if a custom aperture is given.

  • extent (float or two float, optional) – Lateral extent of wave functions [Å] in x and y directions. If a single float is given, both are set equal.

  • gpts (two ints, optional) – Number of grid points describing the wave functions.

  • sampling (two float, optional) – Lateral sampling of wave functions [Å]. If ‘gpts’ is also given, will be ignored.

  • energy (float or list of float, optional) – Electron energy [eV]. A single float gives a standard single-energy simulation. A list or array of floats runs the simulation at each energy in turn and returns output with a leading EnergyAxis ensemble dimension. If not provided, the energy must be inferred from attached wave functions.

  • soft (bool, optional) – If True, the edge of the default aperture is softened (default is True). Ignored if a custom aperture is given.

  • tilt (two float, two 1D BaseDistribution, 2D BaseDistribution,)

  • optional – Small-angle beam tilt [mrad]. This value should generally not exceed one degree.

  • device (str, optional) – The probe wave functions will be build and stored on this device (‘cpu’ or ‘gpu’). The default is determined by the user configuration.

  • aperture (BaseAperture, optional) – An optional custom aperture. The provided aperture should be a subtype of BaseAperture.

  • aberrations (dict or Aberrations) – The phase aberrations as a dictionary.

  • transforms (list of WaveTransform) – A list of additional wave function transforms which will be applied after creation of the probe wave functions.

  • kwargs – Provide the aberrations as keyword arguments, forwarded to the Aberrations.

Initialization

property aberrations: Aberrations#

Phase aberrations of the probe wave functions.

property aperture: BaseAperture#

Condenser or probe-forming aperture.

build(...) Waves[source]#

Build probe wave functions at the provided positions.

Parameters:
  • scan (array of xy-positions or BaseScan, optional) – Positions of the probe wave functions. If not given, scans across the entire potential at Nyquist sampling.

  • max_batch (int, optional) – The number of wave functions in each chunk of the Dask array. If ‘auto’ (default), the batch size is automatically chosen based on the abtem user configuration settings “dask.chunk-size” and “dask.chunk-size-gpu”.

  • lazy (bool, optional) – If True, create the wave functions lazily, otherwise, calculate instantly. If not given, defaults to the setting in the user configuration file.

Returns:

probe_wave_functions – The built probe wave functions.

Return type:

Waves

check_can_build()[source]#
property ctf#

Contrast transfer function describing the probe.

property energy#
property metadata: dict#

Metadata describing the probe wave functions.

multislice(...) Waves | BaseMeasurements | list[Waves | BaseMeasurements][source]#

Run the multislice algorithm for probe wave functions at the provided positions.

Parameters:
  • potential (BasePotential or Atoms) – The scattering potential. Optionally atoms can be directly given.

  • scan (array of xy-positions or BaseScan, optional) – Positions of the probe wave functions. If not given, scans across the entire potential at Nyquist sampling.

  • detectors (BaseDetector or list of BaseDetector, optional) – A detector or a list of detectors defining how the wave functions should be converted to measurements after running the multislice algorithm. If not given, defaults to the flexible annular detector.

  • max_batch (int, optional) – The number of wave functions in each chunk of the Dask array. If ‘auto’ (default), the batch size is automatically chosen based on the abtem user configuration settings “dask.chunk-size” and “dask.chunk-size-gpu”.

  • lazy (bool, optional) – If True, create the wave functions lazily, otherwise, calculate instantly. If None, this defaults to the setting in the user configuration file.

  • **multislice_func_kwargs – Additional keyword arguments passed to the multislice function.

Returns:

measurements

Return type:

BaseMeasurements or Waves or list of BaseMeasurements

profiles(...) RealSpaceLineProfiles[source]#

Create a line profile through the center of the probe.

Parameters:

angle (float, optional) – Angle with respect to the x-axis of the line profile [degree].

scan(...) BaseMeasurements | Waves | list[BaseMeasurements | Waves][source]#

Run the multislice algorithm from probe wave functions over the provided scan.

Parameters:
  • potential (BasePotential or Atoms) – The scattering potential.

  • scan (BaseScan) – Positions of the probe wave functions. If not given, scans across the entire potential at Nyquist sampling.

  • detectors (BaseDetector, list of BaseDetector, optional) – A detector or a list of detectors defining how the wave functions should be converted to measurements after running the multislice algorithm. See abtem.measurements.detect for a list of implemented detectors.

  • max_batch (int, optional) – The number of wave functions in each chunk of the Dask array. If ‘auto’ (default), the batch size is automatically chosen based on the abtem user configuration settings “dask.chunk-size” and “dask.chunk-size-gpu”.

  • lazy (bool, optional) – If True, create the measurements lazily, otherwise, calculate instantly. If None, this defaults to the value set in the configuration file.

  • **multislice_func_kwargs – Additional keyword arguments passed to the multislice function.

Returns:

  • detected_waves (BaseMeasurements or list of BaseMeasurements) – The detected measurement (if detector(s) given).

  • exit_waves (Waves) – Wave functions at the exit plane(s) of the potential (if no detector(s) given).

property scan_positions: BaseScan#

The position(s) of the probe.

property semiangle_cutoff#

The semiangle cutoff [mrad].

show(...) abtem.visualize.Visualization[source]#

Show the intensity of the probe wave function.

Parameters:
  • complex_images (bool) – If true shows complex images using domain-coloring instead of the intensity.

  • kwargs (Keyword arguments for the Images.show() function.)

property soft#

True if the aperture has a soft edge.

transition_potential_scan(...) Waves | BaseMeasurements | list[Waves | BaseMeasurements][source]#

Run the inelastic multislice algorithm for probe wave functions over the provided scan, using transition potentials to model core-loss excitations.

Parameters:
  • potential (BasePotential or Atoms) – The scattering potential through which to propagate the probe.

  • transition_potentials (BaseTransitionPotential or list of BaseTransitionPotential) – The transition potential(s) describing the core-loss excitation(s).

  • scan (array of xy-positions or BaseScan, optional) – Positions of the probe wave functions. If not given, scans across the entire potential at Nyquist sampling.

  • detectors (BaseDetector or list of BaseDetector, optional) – A detector or list of detectors defining how the wave functions are converted to measurements. If not given, defaults to FlexibleAnnularDetector. See abtem.measurements for the implemented detectors.

  • sites (SliceIndexedAtoms or Atoms, optional) – The sites at which inelastic scattering events are evaluated. If not given, all atoms of the species matching the transition potential are used.

  • max_batch (int or str, optional) – The number of probe wave functions in each chunk of the Dask array. If ‘auto’ (default), the batch size is chosen from the abtem configuration (dask.chunk-size / dask.chunk-size-gpu).

  • lazy (bool, optional) – If True, build measurements lazily; otherwise compute eagerly. Defaults to the value set in the user configuration file.

  • **multislice_func_kwargs – Additional keyword arguments forwarded to the inelastic multislice function (e.g. double_channel, threshold).

Returns:

measurements – The detected measurements for each scan position. If multiple transition potentials are given, an additional ensemble axis distinguishes them.

Return type:

BaseMeasurements or Waves or list of BaseMeasurements

class abtem.waves.Waves(...)[source]#

Bases: abtem.waves.BaseWaves, abtem.array.ArrayObject

Waves define a batch of arbitrary 2D wave functions defined by a complex array.

Parameters:
  • array (array) – Complex array defining one or more 2D wave functions. The second-to-last and last dimensions are the wave function y- and x-axes, respectively.

  • energy (float) – Electron energy [eV].

  • extent (one or two float) – Extent of wave functions in x and y [Å].

  • sampling (one or two float) – Sampling of wave functions in x and y [Å].

  • reciprocal_space (bool, optional) – If True, the wave functions are assumed to be represented in reciprocal space instead of real space (default is False).

  • ensemble_axes_metadata (list of AxesMetadata) – Axis metadata for each ensemble axis. The axis metadata must be compatible with the shape of the array.

  • metadata (dict) – A dictionary defining wave function metadata. All items will be added to the metadata of measurements derived from the waves.

Initialization

property angular_sampling: tuple[float, float]#

Reciprocal-space sampling in units of scattering angles [mrad].

For a single-energy object the exact energy is used. For an indexed member of an energy ensemble the per-member energy stored in metadata["energy"] is used. For the full multi-member ensemble the maximum energy (shortest wavelength) is used so that the grid is conservative — it covers all members without aliasing.

apply_ctf(...) Waves[source]#

Apply the aberrations and apertures of a contrast transfer function to the wave functions.

Parameters:
  • ctf (CTF, optional) – Contrast transfer function to be applied.

  • max_batch (int, optional) – The number of wave functions in each chunk of the Dask array. If ‘auto’ (default), the batch size is automatically chosen based on the abtem user configuration settings “dask.chunk-size” and “dask.chunk-size-gpu”.

  • kwargs – Provide the parameters of the contrast transfer function as keyword arguments (see CTF).

Returns:

aberrated_waves – The wave functions with the contrast transfer function applied.

Return type:

Waves

property base_tilt: tuple[float, float]#

The base small-angle beam tilt (i.e. the beam tilt not associated with an ensemble axis) applied to the Fresnel propagator [mrad].

convolve(...) Waves[source]#

Convolve the wave-function array with a given array.

Parameters:
  • kernel (ndarray) – Array to be convolved with.

  • axes_metadata (list of AxisMetadata, optional) – Metadata for the resulting convolved array. Needed only if the given array has more than two dimensions.

  • out_space (str, optional) – Space in which the convolved array is represented. Options are ‘reciprocal_space’ and ‘real_space’ (default is the space of the wave functions).

  • in_place (bool, optional) – If True, the array representing the waves may be modified in-place.

Returns:

convolved – The convolved wave functions.

Return type:

Waves

depth_profile(...) Images[source]#

Create a depth profile by projecting wave functions along a spatial axis.

Requires wave functions with a thickness dimension, i.e. from a multislice simulation with exit_planes.

Parameters:
  • projection_axis (str) – Spatial axis to project (sum) along. "y" (default) produces an x–z cross-section; "x" produces a y–z cross-section.

  • depth (float, optional) – If given, project only over a finite slab of this thickness [Å], centered on the midpoint of the projected axis. The number of grid points is rounded to the nearest integer. If None, the full extent is projected.

  • convert_complex (str) – How to convert the complex wave function before projecting. One of "intensity" (default), "phase", "real", or "imag".

Returns:

depth_profile – 2D image(s) with the depth (z) as the first base axis and the remaining spatial axis as the second. Any additional ensemble axes (e.g. scan positions) are preserved.

Return type:

Images

property device: str#

The device where the array is stored.

diffraction_patterns(...) DiffractionPatterns[source]#

Calculate the intensity of the wave functions at the diffraction plane.

Parameters:
  • max_angle ({'cutoff', 'valid', 'full'} or float) –

    Control the maximum scattering angle of the diffraction patterns.

    cutoff :

    Downsample to the antialias cutoff scattering angle (default).

    valid :

    Downsample to the largest rectangle that fits inside the circle with a radius defined by the antialias cutoff scattering angle.

    full :

    The diffraction patterns are not cropped, and hence the antialiased region is included.

    float :

    Downsample to a maximum scattering angle specified by a float [mrad].

  • block_direct (bool or float, optional) – If True the direct beam is masked (default is False). If given as a float, masks up to that scattering angle [mrad].

  • fftshift (bool, optional) – If False, do not shift the direct beam to the center of the diffraction patterns (default is True).

  • parity ({'same', 'even', 'odd', 'none'}) – The parity of the shape of the diffraction patterns. Default is ‘odd’, so that the shape of the diffraction pattern is odd with the zero at the middle.

  • renormalize (bool, optional) – If true and the wave function intensities were normalized to sum to the number of pixels in real space, i.e. the default normalization of a plane wave, the intensities are to sum to one in reciprocal space.

  • return_complex (bool) – If True, return complex-valued diffraction patterns (i.e. the wave function in reciprocal space) (default is False).

Returns:

diffraction_patterns – The diffraction pattern(s).

Return type:

DiffractionPatterns

downsample(...) Waves[source]#

Downsample the wave functions to a lower maximum scattering angle.

Parameters:
  • max_angle ({'cutoff', 'valid'} or float, optional) –

    Controls the downsampling of the wave functions.

    cutoff :

    Downsample to the antialias cutoff scattering angle (default).

    valid :

    Downsample to the largest rectangle that fits inside the circle with a radius defined by the antialias cutoff scattering angle.

    float :

    Downsample to a maximum scattering angle specified by a float [mrad].

  • gpts (two int, optional) – Number of grid points of the wave functions after downsampling. If given, max_angle is not used.

  • normalization ({'values', 'amplitude'}) –

    The normalization parameter determines the preserved quantity after normalization.

    values :

    The pixel-wise values of the wave function are preserved (default).

    amplitude :

    The total amplitude of the wave function is preserved.

Returns:

downsampled_waves – The downsampled wave functions.

Return type:

Waves

ensure_real_space(...) Waves[source]#

Transform to real space if the wave functions are represented in reciprocal space.

Parameters:

overwrite_x (bool, optional) – If True, modify the array in place; otherwise a copy is created (default is False).

Returns:

waves_in_real_space – The wave functions in real space.

Return type:

Waves

ensure_reciprocal_space(...) Waves[source]#

Transform to reciprocal space if the wave functions are represented in real space.

Parameters:

overwrite_x (bool, optional) – If True, modify the array in place; otherwise a copy is created (default is False).

Returns:

waves_in_reciprocal_space – The wave functions in reciprocal space.

Return type:

Waves

classmethod from_array_and_metadata(...) Waves[source]#

Creates wave functions from a given array and metadata.

Parameters:
  • array (array) – Complex array defining one or more 2D wave functions. The second-to-last and last dimensions are the wave function y- and x-axis, respectively.

  • axes_metadata (list of AxesMetadata) – Axis metadata for each axis. The axis metadata must be compatible with the shape of the array. The last two axes must be RealSpaceAxis.

  • metadata – A dictionary defining wave function metadata. All items will be added to the metadata of measurements derived from the waves. The metadata must contain the electron energy [eV].

Returns:

wave_functions – The created wave functions.

Return type:

Waves

imag() Images[source]#

Calculate the imaginary part of the wave functions.

Returns:

imaginary_images – The imaginary part of the wave functions.

Return type:

Images

intensity() Images[source]#

Calculate the intensity of the wave functions.

Returns:

intensity_images – The intensity of the wave functions.

Return type:

Images

property metadata: dict#
multislice(...) Waves | BaseMeasurements | list[Waves | BaseMeasurements][source]#

Propagate and transmit wave function through the provided potential using the multislice algorithm. When detector(s) are given, output will be the corresponding measurement.

Parameters:
  • potential (BasePotential or ASE.Atoms) – The potential through which to propagate the wave function. Optionally atoms can be directly given.

  • detectors (BaseDetector or list of BaseDetector, optional) – A detector or a list of detectors defining how the wave functions should be converted to measurements after running the multislice algorithm. See abtem.measurements.detect for a list of implemented detectors. If not given, returns the wave functions themselves.

  • potential_chunk_size (int or str, optional) – Number of potential slices to build and hold in memory at once. "auto" (default) selects a size based on the available memory budget. Smaller values reduce peak memory at the cost of more build overhead. Can be set globally via the potential.slice-chunk-size configuration key.

  • **multislice_func_kwargs – Additional keyword arguments passed to the multislice function.

Returns:

  • detected_waves (BaseMeasurements or list of BaseMeasurements) – The detected measurement (if detector(s) given).

  • exit_waves (Waves) – Wave functions at the exit plane(s) of the potential (if no detector(s) given).

normalize(...) Waves[source]#

Normalize the wave functions in real or reciprocal space.

Parameters:
  • space (str) – Should be one of ‘real’ or ‘reciprocal’ (default is ‘reciprocal’). Defines whether the wave function should be normalized such that the intensity sums to one in real or reciprocal space.

  • in_place (bool, optional) – If True, the array representing the waves may be modified in-place.

Returns:

normalized_waves – The normalized wave functions.

Return type:

Waves

phase() Images[source]#

Calculate the phase of the wave functions.

Returns:

phase_images – The phase of the wave functions.

Return type:

Images

phase_shift(...) Waves[source]#

Shift the phase of the wave functions.

Parameters:

amount (float) – Amount of phase shift [rad].

Returns:

phase_shifted_waves – The shifted wave functions.

Return type:

Waves

phonon_loss_diffraction_patterns(...)[source]#

Compute inelastic (TDS) diffraction patterns from energy-resolved frozen-phonon exit waves. See abtem.measurements.phonon_loss_diffraction_patterns() for full documentation.

real() Images[source]#

Calculate the real part of the wave functions.

Returns:

real_images – The real part of the wave functions.

Return type:

Images

property reciprocal_space: bool#

True if the waves are represented in reciprocal space.

scan(...) Waves | BaseMeasurements | list[Waves | BaseMeasurements][source]#

Run the multislice algorithm from probe wave functions over the provided scan.

Parameters:
  • potential (BasePotential or Atoms) – The scattering potential.

  • scan (BaseScan) – Positions of the probe wave functions. If not given, scans across the entire potential at Nyquist sampling.

  • detectors (BaseDetector, list of BaseDetector, optional) – A detector or a list of detectors defining how the wave functions should be converted to measurements after running the multislice algorithm. See abtem.measurements.detect for a list of implemented detectors.

  • max_batch (int, optional) – The number of wave functions in each chunk of the Dask array. If ‘auto’ (default), the batch size is automatically chosen based on the abtem user configuration settings “dask.chunk-size” and “dask.chunk-size-gpu”.

  • **multislice_func_kwargs – Additional keyword arguments passed to the multislice function.

Returns:

  • detected_waves (BaseMeasurements or list of BaseMeasurements) – The detected measurement (if detector(s) given).

  • exit_waves (Waves) – Wave functions at the exit plane(s) of the potential (if no detector(s) given).

show(...) abtem.visualize.Visualization[source]#

Show the wave-function intensities.

kwargs :

Keyword arguments for abtem.measurements.Images.show.

show_depth_profile(...) abtem.visualize.Visualization[source]#

Show a depth propagation profile of the wave functions.

Requires wave functions with a thickness dimension, i.e. from a multislice simulation with exit_planes.

Parameters:
  • projection_axis (str) – Spatial axis to project (sum) along. "y" (default) produces an x–z cross-section; "x" produces a y–z cross-section.

  • depth (float, optional) – If given, project only over a finite slab of this thickness [Å], centered on the midpoint of the projected axis. The number of grid points is rounded to the nearest integer. If None, the full extent is projected.

  • convert_complex (str) – How to convert the complex wave function before projecting. One of "intensity" (default), "phase", "real", or "imag".

  • z_scale (float) – Scaling factor for the z-axis relative to the spatial axis. Values less than 1 compress the z-axis, making panels of thick specimens more compact. Default is 1.0 (equal scaling).

  • slice_lines (bool) – If True, draw horizontal lines at slice boundaries. Default is False.

  • ax (matplotlib.axes.Axes, optional) – If given the plot is added to the axis.

  • cbar (bool, optional) – Add a colorbar to the plot. Default is False.

  • cmap (str, optional) – Matplotlib colormap name.

  • vmin (float, optional) – Minimum of the intensity color scale.

  • vmax (float, optional) – Maximum of the intensity color scale.

  • power (float) – Show image on a power scale.

  • common_color_scale (bool, optional) – If True, all images in a grid share the same color scale.

  • explode (bool or sequence of int, optional) – If True, create a grid of images for ensemble items.

  • figsize (two int, optional) – Figure size as (width, height) in inches.

  • title (bool or str, optional) – Column title for the images.

  • **kwargs – Additional keyword arguments passed to the show method.

Returns:

visualization

Return type:

Visualization

tile(...) Waves[source]#

Tile the wave functions. Can only be applied in real space.

Parameters:
  • repetitions (two int) – The number of repetitions of the wave functions along the x- and y-axes.

  • renormalize (bool, optional) – If True, preserve the total intensity of the wave function (default is False).

Returns:

tiled_wave_functions – The tiled wave functions.

Return type:

Waves

to_images(...) Images[source]#

The complex array of the wave functions at the image plane.

Returns:

images – The wave functions as an image.

Return type:

Images

transition_potential_multislice(...) Waves | BaseMeasurements[source]#
property wavelength: float#

Relativistic electron wavelength [Å].

Resolves the per-member energy (metadata["energy"] or a single-value EnergyAxis) for an indexed energy-ensemble member, mirroring angular_sampling. A full multi-energy ensemble has no single wavelength and raises EnergyUndefinedError.

class abtem.waves.WavesBuilder(...)[source]#

Bases: abtem.waves.BaseWaves, abtem.core.ensemble.Ensemble, abtem.core.utils.CopyMixin, abtem.core.utils.EqualityMixin

apply_transform(...)[source]#
property axes_metadata: AxesMetadataList#

List of AxisMetadata.

property base_shape: tuple[int, int]#

Shape of the base axes of the waves.

abstract build(...) Waves[source]#
check_can_build()[source]#

Check whether the wave functions can be built.

property device: str#

The device where the waves are created.

property ensemble_axes_metadata: list[AxisMetadata]#

List of AxisMetadata of the ensemble axes.

property ensemble_shape#

Shape of the ensemble axes of the waves.

property shape: tuple[int, ...]#

Shape of the waves.

property tilt#

The small-angle tilt of applied to the Fresnel propagator [mrad].

abtem.waves.reduce_ensemble(...) Waves | BaseMeasurements | list[Waves | BaseMeasurements][source]#

Reduce an ensemble of wave functions or measurements by squeezing or averaging ensemble axes tagged for reduction with the “_squeeze” or “_ensemble_mean” attribute of the axis metadata.

Parameters:

ensemble (Waves, BaseMeasurements, list[Waves | BaseMeasurements]) – The ensemble to reduce.

Returns:

reduced_output – The reduced ensemble.

Return type:

Waves, BaseMeasurements, list[Waves | BaseMeasurements]

abtem.waves.validate_energy(...) EnergyEnsemble[source]#

Convert energy (float, list, distribution, or EnergyEnsemble) to EnergyEnsemble.