Waves

Contents

Waves#

class abtem.waves.Waves(array, energy, extent=None, sampling=None, reciprocal_space=False, ensemble_axes_metadata=None, metadata=None)[source]#

Bases: BaseWaves, 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 [1 / Å].

  • 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.

__init__(array, energy, extent=None, sampling=None, reciprocal_space=False, ensemble_axes_metadata=None, metadata=None)[source]#

Methods

__init__(array, energy[, extent, sampling, ...])

apply_ctf([ctf, max_batch])

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

apply_func(func, **kwargs)

rtype:

TypeVar(T, bound= ArrayObject)

apply_transform(transform[, max_batch])

Transform the wave functions by a given transformation.

compute([progress_bar, profiler, ...])

Turn a lazy abTEM object into its in-memory equivalent.

convolve(kernel[, axes_metadata, out_space, ...])

Convolve the wave-function array with a given array.

copy()

Make a copy.

copy_to_device(device)

Copy array to specified device.

diffraction_patterns([max_angle, ...])

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

downsample([max_angle, gpts, normalization])

Downsample the wave functions to a lower maximum scattering angle.

ensemble_blocks([chunks])

Split the ensemble into an array of smaller ensembles.

ensure_lazy([chunks])

Creates an equivalent lazy version of the array object.

ensure_real_space([overwrite_x])

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

ensure_reciprocal_space([overwrite_x])

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

expand_dims([axis, axis_metadata])

Expand the shape of the array object.

from_array_and_metadata(array, axes_metadata)

Creates wave functions from a given array and metadata.

from_zarr(url[, chunks])

Read wave functions from a hdf5 file.

generate_blocks([chunks])

Generate chunks of the ensemble.

generate_ensemble([keepdims])

Generate every member of the ensemble.

get_from_metadata(name[, broadcastable])

get_items(items[, keepdims])

Index the array and the corresponding axes metadata.

imag()

Calculate the imaginary part of the wave functions.

intensity()

Calculate the intensity of the wave functions.

lazy([chunks])

rtype:

TypeVar(T, bound= ArrayObject)

match_grid(other[, check_match])

Match the grid to another object with a Grid.

max([axis, keepdims, split_every])

Maximum of array object over one or more axes.

mean([axis, keepdims, split_every])

Mean of array object over one or more axes.

min([axis, keepdims, split_every])

Minmimum of array object over one or more axes.

multislice(potential[, detectors])

Propagate and transmit wave function through the provided potential using the multislice algorithm.

no_base_chunks()

Rechunk to remove chunks across the base dimensions.

normalize([space, in_place])

Normalize the wave functions in real or reciprocal space.

phase()

Calculate the phase of the wave functions.

phase_shift(amount)

Shift the phase of the wave functions.

real()

Calculate the real part of the wave functions.

rechunk(chunks, **kwargs)

Rechunk dask array.

scan(scan[, potential, detectors, max_batch])

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

select_block(index, chunks)

Select a block from the ensemble.

set_ensemble_axes_metadata(axes_metadata, axis)

Sets the axes metadata of an ensemble axis.

show([complex_images])

Show the wave-function intensities.

squeeze([axis])

Remove axes of length one from array object.

std([axis, keepdims, split_every])

Standard deviation of array object over one or more axes.

sum([axis, keepdims, split_every])

Sum of array object over one or more axes.

tile(repetitions[, renormalize])

Tile the wave functions.

to_cpu()

Move the array to the host memory from an arbitrary source array.

to_data_array()

Convert ArrayObject to a xarray DataArray.

to_gpu([device])

Move the array from the host memory to a gpu.

to_hyperspy()

Convert ArrayObject to a Hyperspy signal.

to_images([convert_complex])

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

to_tiff(filename, **kwargs)

Write data to a tiff file.

to_zarr(url[, compute, overwrite])

Write data to a zarr file.

transition_potential_multislice(potential, ...)

rtype:

Waves | BaseMeasurements

Attributes

accelerator

Accelerator object describing the acceleration energy.

angular_sampling

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

antialias_cutoff_gpts

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

antialias_valid_gpts

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.

array

Underlying array describing the array object.

axes_metadata

List of AxisMetadata.

base_axes_metadata

List of AxisMetadata for the base axes in real space.

base_dims

Number of base dimensions.

base_shape

Shape of the base axes of the underlying array.

base_tilt

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

cutoff_angles

Scattering angles at the antialias cutoff [mrad].

device

The device where the array is stored.

dtype

The datatype of waves.

energy

Electron acceleration energy in electron volts.

ensemble_axes_metadata

List of AxisMetadata of the ensemble axes.

ensemble_dims

Number of ensemble dimensions.

ensemble_shape

Shape of the ensemble axes of the underlying array.

extent

Extent of grid for each dimension in Ångstrom.

full_cutoff_angles

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

gpts

Number of grid points for each dimension.

grid

Simulation grid.

is_complex

True if array is complex.

is_lazy

True if array is lazy.

metadata

Metadata stored as a dictionary.

reciprocal_space

True if the waves are represented in reciprocal space.

reciprocal_space_axes_metadata

List of AxisMetadata for base axes in reciprocal space.

reciprocal_space_sampling

Reciprocal-space sampling in reciprocal Ångstrom.

rectangle_cutoff_angles

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

sampling

Grid sampling for each dimension in Ångstrom per grid point.

shape

Shape of the underlying array.

wavelength

Relativistic wavelength in Ångstrom.

property accelerator: Accelerator#

Accelerator object describing the acceleration energy.

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.

apply_ctf(ctf=None, max_batch='auto', **kwargs)[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

apply_transform(transform, max_batch='auto')#

Transform the wave functions by a given transformation.

Parameters:
  • transform (ArrayObjectTransform) – The array object transformation to apply.

  • 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”.

Returns:

transformed_array_object – The transformed array object.

Return type:

ArrayObjectTransform

property array: ndarray | Array#

Underlying array describing the array object.

property axes_metadata: AxesMetadataList#

List of AxisMetadata.

property base_axes_metadata: list[AxisMetadata]#

List of AxisMetadata for the base axes in real space.

property base_dims#

Number of base dimensions.

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

Shape of the base axes of the underlying array.

property base_tilt#

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

compute(progress_bar=None, profiler=False, resource_profiler=False, **kwargs)#

Turn a lazy abTEM object into its in-memory equivalent.

Parameters:
  • progress_bar (bool) – Display a progress bar in the terminal or notebook during computation. The progress bar is only displayed with a local scheduler.

  • profiler (bool) – Return Profiler class used to profile Dask’s execution at the task level. Only execution with a local is profiled.

  • resource_profiler (bool) – Return ResourceProfiler class is used to profile Dask’s execution at the resource level.

  • kwargs – Additional keyword arguments passes to dask.compute.

convolve(kernel, axes_metadata=None, out_space='in_space', in_place=False)[source]#

Convolve the wave-function array with a given array.

Parameters:
  • kernel (np.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

copy()#

Make a copy.

copy_to_device(device)#

Copy array to specified device.

Parameters:

device (str) –

Returns:

object_on_device

Return type:

T

property cutoff_angles: tuple[float, float]#

Scattering angles at the antialias cutoff [mrad].

property device: str#

The device where the array is stored.

diffraction_patterns(max_angle='cutoff', block_direct=False, fftshift=True, parity='odd', return_complex=False, renormalize=True)[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(max_angle='cutoff', gpts=None, normalization='values')[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

property dtype#

The datatype of waves.

property energy#

Electron acceleration energy in electron volts.

property ensemble_axes_metadata#

List of AxisMetadata of the ensemble axes.

ensemble_blocks(chunks=None)#

Split the ensemble into an array of smaller ensembles.

Parameters:

chunks (iterable of tuples) – Block sizes along each dimension.

Return type:

Array

property ensemble_dims#

Number of ensemble dimensions.

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

Shape of the ensemble axes of the underlying array.

ensure_lazy(chunks='auto')#

Creates an equivalent lazy version of the array object.

Parameters:

chunks (int or tuple or str) – How to chunk the array. See dask.array.from_array.

Returns:

lazy_array_object – Lazy version of the array object.

Return type:

ArrayObject or subclass of ArrayObject

ensure_real_space(overwrite_x=False)[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(overwrite_x=False)[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

expand_dims(axis=None, axis_metadata=None)#

Expand the shape of the array object.

Parameters:
  • axis (int or tuple of ints) – Position in the expanded axes where the new axis (or axes) is placed.

  • axis_metadata (AxisMetadata or List of AxisMetadata, optional) – The axis metadata describing the expanded axes. Default is UnknownAxis.

Returns:

expanded – View of array object with the number of dimensions increased.

Return type:

ArrayObject or subclass of ArrayObject

property extent: tuple[float] | tuple[float, float] | tuple[float, ...]#

Extent of grid for each dimension in Ångstrom.

classmethod from_array_and_metadata(array, axes_metadata, metadata=None)[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 (dict) – 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

classmethod from_zarr(url, chunks='auto')#

Read wave functions from a hdf5 file.

Return type:

TypeVar(T, bound= ArrayObject)

urlstr

Location of the data, typically a path to a local file. A URL can also include a protocol specifier like s3:// for remote data.

chunkstuple of ints or tuples of ints

Passed to dask.array.from_array(), allows setting the chunks on initialisation, if the chunking scheme in the on-disc dataset is not optimal for the calculations to follow.

property full_cutoff_angles: tuple[float, float]#

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

generate_blocks(chunks=1)#

Generate chunks of the ensemble.

Parameters:

chunks (iterable of tuples) – Block sizes along each dimension.

generate_ensemble(keepdims=False)#

Generate every member of the ensemble.

Parameters:

keepdims (bool, opptional) – If True, all ensemble axes are left in the result as dimensions with size one. Default is False.

Yields:

ArrayObject or subclass of ArrayObject – Member of the ensemble.

get_items(items, keepdims=False)#

Index the array and the corresponding axes metadata. Only ensemble axes can be indexed.

Parameters:
  • items (int or tuple of int or slice) – The array is indexed according to this.

  • keepdims (bool, optional) – If True, all ensemble axes are left in the result as dimensions with size one. Default is False.

Returns:

indexed_array – The indexed array object.

Return type:

ArrayObject or subclass of ArrayObject

property gpts: tuple[int] | tuple[int, int] | tuple[int, ...]#

Number of grid points for each dimension.

property grid: Grid#

Simulation grid.

imag()[source]#

Calculate the imaginary part of the wave functions.

Returns:

imaginary_images – The imaginary part of the wave functions.

Return type:

Images

intensity()[source]#

Calculate the intensity of the wave functions.

Returns:

intensity_images – The intensity of the wave functions.

Return type:

Images

property is_complex: bool#

True if array is complex.

property is_lazy: bool#

True if array is lazy.

match_grid(other, check_match=False)#

Match the grid to another object with a Grid.

max(axis=None, keepdims=False, split_every=2)#

Maximum of array object over one or more axes. Only ensemble axes can be reduced.

Parameters:
  • axis (int or tuple of ints, optional) – Axis or axes along which a maxima are calculated. The default is to compute the mean of the flattened array. If this is a tuple of ints, the maxima are calculated over multiple axes. The indicated axes must be ensemble axes.

  • keepdims (bool, optional) – If True, the reduced axes are left in the result as dimensions with size one. Default is False.

  • split_every (int) – Only used for lazy arrays. See dask.array.reductions.

Returns:

reduced_array – The reduced array object.

Return type:

ArrayObject or subclass of ArrayObject

mean(axis=None, keepdims=False, split_every=2)#

Mean of array object over one or more axes. Only ensemble axes can be reduced.

Parameters:
  • axis (int or tuple of ints, optional) – Axis or axes along which a means are calculated. The default is to compute the mean of the flattened array. If this is a tuple of ints, the mean is calculated over multiple axes. The indicated axes must be ensemble axes.

  • keepdims (bool, optional) – If True, the reduced axes are left in the result as dimensions with size one. Default is False.

  • split_every (int) – Only used for lazy arrays. See dask.array.reductions.

Returns:

reduced_array – The reduced array object.

Return type:

ArrayObject or subclass of ArrayObject

property metadata: dict#

Metadata stored as a dictionary.

min(axis=None, keepdims=False, split_every=2)#

Minmimum of array object over one or more axes. Only ensemble axes can be reduced.

Parameters:
  • axis (int or tuple of ints, optional) – Axis or axes along which a minima are calculated. The default is to compute the mean of the flattened array. If this is a tuple of ints, the minima are calculated over multiple axes. The indicated axes must be ensemble axes.

  • keepdims (bool, optional) – If True, the reduced axes are left in the result as dimensions with size one. Default is False.

  • split_every (int) – Only used for lazy arrays. See dask.array.reductions.

Returns:

reduced_array – The reduced array object.

Return type:

ArrayObject or subclass of ArrayObject

multislice(potential, detectors=None)[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.

Return type:

Waves

Returns:

  • detected_waves (BaseMeasurements or list of BaseMeasurement) – 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).

no_base_chunks()#

Rechunk to remove chunks across the base dimensions.

normalize(space='reciprocal', in_place=False)[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()[source]#

Calculate the phase of the wave functions.

Returns:

phase_images – The phase of the wave functions.

Return type:

Images

phase_shift(amount)[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

real()[source]#

Calculate the real part of the wave functions.

Returns:

real_images – The real part of the wave functions.

Return type:

Images

rechunk(chunks, **kwargs)#

Rechunk dask array.

chunksint or tuple or str

How to rechunk the array. See dask.array.rechunk.

kwargs :

Additional keyword arguments passes to dask.array.rechunk.

property reciprocal_space#

True if the waves are represented in reciprocal space.

property reciprocal_space_axes_metadata: list[AxisMetadata]#

List of AxisMetadata for base axes in reciprocal space.

property reciprocal_space_sampling: tuple[float] | tuple[float, float] | tuple[float, ...]#

Reciprocal-space sampling in reciprocal Ångstrom.

property rectangle_cutoff_angles: tuple[float, float]#

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

property sampling: tuple[float] | tuple[float, float] | tuple[float, ...]#

Grid sampling for each dimension in Ångstrom per grid point.

scan(scan, potential=None, detectors=None, max_batch='auto')[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”.

Return type:

BaseMeasurements | Waves | list[BaseMeasurements | Waves]

Returns:

  • detected_waves (BaseMeasurements or list of BaseMeasurement) – 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).

select_block(index, chunks)#

Select a block from the ensemble.

Parameters:
  • index (tuple of ints) – Index of selected block.

  • chunks (iterable of tuples) – Block sizes along each dimension.

set_ensemble_axes_metadata(axes_metadata, axis)#

Sets the axes metadata of an ensemble axis.

Parameters:
  • axes_metadata (AxisMetadata) – The new axis metadata.

  • axis (int) – The axis to set.

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

Shape of the underlying array.

show(complex_images=False, **kwargs)[source]#

Show the wave-function intensities.

kwargs :

Keyword arguments for abtem.measurements.Images.show.

squeeze(axis=None)#

Remove axes of length one from array object.

Parameters:

axis (int or tuple of ints, optional) – Selects a subset of the entries of length one in the shape.

Returns:

squeezed – The input array object, but with all or a subset of the dimensions of length 1 removed.

Return type:

ArrayObject or subclass of ArrayObject

std(axis=None, keepdims=False, split_every=2)#

Standard deviation of array object over one or more axes. Only ensemble axes can be reduced.

Parameters:
  • axis (int or tuple of ints, optional) – Axis or axes along which a standard deviations are calculated. The default is to compute the mean of the flattened array. If this is a tuple of ints, the standard deviations are calculated over multiple axes. The indicated axes must be ensemble axes.

  • keepdims (bool, optional) – If True, the reduced axes are left in the result as dimensions with size one. Default is False.

  • split_every (int) – Only used for lazy arrays. See dask.array.reductions.

Returns:

reduced_array – The reduced array object.

Return type:

ArrayObject or subclass of ArrayObject

sum(axis=None, keepdims=False, split_every=2)#

Sum of array object over one or more axes. Only ensemble axes can be reduced.

Parameters:
  • axis (int or tuple of ints, optional) – Axis or axes along which a sums are performed. The default is to compute the mean of the flattened array. If this is a tuple of ints, the sum is performed over multiple axes. The indicated axes must be ensemble axes.

  • keepdims (bool, optional) – If True, the reduced axes are left in the result as dimensions with size one. Default is False.

  • split_every (int) – Only used for lazy arrays. See dask.array.reductions.

Returns:

reduced_array – The reduced array object.

Return type:

ArrayObject or subclass of ArrayObject

tile(repetitions, renormalize=False)[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_cpu()#

Move the array to the host memory from an arbitrary source array.

Return type:

TypeVar(T, bound= ArrayObject)

to_data_array()#

Convert ArrayObject to a xarray DataArray.

to_gpu(device='gpu')#

Move the array from the host memory to a gpu.

Return type:

TypeVar(T, bound= ArrayObject)

to_hyperspy()#

Convert ArrayObject to a Hyperspy signal.

to_images(convert_complex=None)[source]#

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

Returns:

images – The wave functions as an image.

Return type:

Images

to_tiff(filename, **kwargs)#

Write data to a tiff file.

Parameters:
  • filename (str) – The filename of the file to write.

  • kwargs – Keyword arguments passed to tifffile.imwrite.

to_zarr(url, compute=True, overwrite=False, **kwargs)#

Write data to a zarr file.

Parameters:
  • url (str) – Location of the data, typically a path to a local file. A URL can also include a protocol specifier like s3:// for remote data.

  • compute (bool) – If true compute immediately; return dask.delayed.Delayed otherwise.

  • overwrite (bool) – If given array already exists, overwrite=False will cause an error, where overwrite=True will replace the existing data.

  • kwargs – Keyword arguments passed to dask.array.to_zarr.

property wavelength#

Relativistic wavelength in Ångstrom.