Detectors

Module for describing the detection of transmitted waves and different detector types.

class abtem.detect.AbstractDetector(max_detected_angle=None, save_file=None)[source]

Abstract base class for all detectors.

property save_file

The path to the file for saving the detector output.

Return type:

str

class abtem.detect.AnnularDetector(inner, outer, offset=None, save_file=None)[source]

Annular detector object.

The annular detector integrates the intensity of the detected wave functions between an inner and outer integration limit.

Parameters:
  • inner (float) – Inner integration limit [mrad].

  • outer (float) – Outer integration limit [mrad].

  • offset (two float, optional) – Center offset of integration region [mrad].

  • save_file (str, optional) – The path to the file for saving the detector output.

allocate_measurement(waves, scan=None)

Allocate a Measurement object or an hdf5 file.

Parameters:
  • waves (Waves object) – An example of the

  • scan (Scan object) – The scan object that will define the scan dimensions the measurement.

Returns:

The allocated measurement or path to hdf5 file with the measurement data.

Return type:

Measurement object or str

copy()[source]

Make a copy.

Return type:

AnnularDetector

detect(waves)[source]

Integrate the intensity of a the wave functions over the detector range.

Parameters:

waves (Waves object) – The batch of wave functions to detect.

Returns:

Detected values as a 1D array. The array has the same length as the batch size of the wave functions.

Return type:

1d array

property inner

Inner integration limit [mrad].

Return type:

float

integrate(diffraction_patterns)[source]

Integrate diffraction pattern measurements on the detector region.

Parameters:

diffraction_patterns (2d, 3d or 4d Measurement object) – The collection diffraction patterns to be integrated.

Returns:

Return type:

Measurement

property outer

Outer integration limit [mrad].

Return type:

float

property save_file

The path to the file for saving the detector output.

Return type:

str

show(waves, **kwargs)

Visualize the detector region(s) of the detector as applied to a specified wave function.

Parameters:
  • waves (Waves or SMatrix object) – The wave function the visualization will be created to match

  • kwargs – Additional keyword arguments for abtem.visualize.mpl.show_measurement_2d.

class abtem.detect.FlexibleAnnularDetector(step_size=1.0, save_file=None)[source]

Flexible annular detector object.

The FlexibleAnnularDetector object allows choosing the integration limits after running the simulation by radially binning the intensity.

Parameters:
  • step_size (float) – The radial separation between integration regions [mrad].

  • save_file (str) – The path to the file used for saving the detector output.

allocate_measurement(waves, scan=None)

Allocate a Measurement object or an hdf5 file.

Parameters:
  • waves (Waves object) – An example of the

  • scan (Scan object) – The scan object that will define the scan dimensions the measurement.

Returns:

The allocated measurement or path to hdf5 file with the measurement data.

Return type:

Measurement object or str

copy()[source]

Make a copy.

Return type:

FlexibleAnnularDetector

detect(waves)[source]

Integrate the intensity of a the wave functions over the detector range.

Parameters:

waves (Waves object) – The batch of wave functions to detect.

Returns:

Detected values. The array has shape of (batch size, number of bins).

Return type:

2d array

property save_file

The path to the file for saving the detector output.

Return type:

str

show(waves, **kwargs)

Visualize the detector region(s) of the detector as applied to a specified wave function.

Parameters:
  • waves (Waves or SMatrix object) – The wave function the visualization will be created to match

  • kwargs – Additional keyword arguments for abtem.visualize.mpl.show_measurement_2d.

property step_size

Step size [mrad].

Return type:

float

class abtem.detect.PixelatedDetector(max_angle='valid', resample=False, mode='intensity', save_file=None)[source]

Pixelated detector object.

The pixelated detector records the intensity of the Fourier-transformed exit wavefunction. This may be used for example for simulating 4D-STEM.

Parameters:
  • max_angle (str or float or None) – The diffraction patterns will be detected up to this angle. If set to a string it must be ‘limit’ or ‘valid’

  • resample ('uniform' or False) – If ‘uniform’, the diffraction patterns from rectangular cells will be downsampled to a uniform angular sampling.

  • mode ('intensity' or 'complex') –

  • save_file (str) – The path to the file used for saving the detector output.

allocate_measurement(waves, scan=None)[source]

Allocate a Measurement object or an hdf5 file.

Parameters:
  • waves (Waves or SMatrix object) – The wave function that will define the shape of the diffraction patterns.

  • scan (Scan object) – The scan object that will define the scan dimensions the measurement.

Returns:

The allocated measurement or path to hdf5 file with the measurement data.

Return type:

Measurement object or str

detect(waves)[source]

Calculate the far field intensity of the wave functions. The output is cropped to include the non-suppressed frequencies from the antialiased 2D fourier spectrum.

Parameters:

waves (Waves object) – The batch of wave functions to detect.

Return type:

ndarray

Returns:

  • Detected values. The first dimension indexes the batch size, the second and third indexes the two components

  • of the spatial frequency.

property save_file

The path to the file for saving the detector output.

Return type:

str

class abtem.detect.SegmentedDetector(inner, outer, nbins_radial, nbins_angular, rotation=0.0, save_file=None)[source]

Segmented detector object.

The segmented detector covers an annular angular range, and is partitioned into several integration regions divided to radial and angular segments. This can be used for simulating differential phase contrast (DPC) imaging.

Parameters:
  • inner (float) – Inner integration limit [mrad].

  • outer (float) – Outer integration limit [mrad].

  • nbins_radial (int) – Number of radial bins.

  • nbins_angular (int) – Number of angular bins.

  • save_file (str) – The path to the file used for saving the detector output.

allocate_measurement(waves, scan=None)

Allocate a Measurement object or an hdf5 file.

Parameters:
  • waves (Waves object) – An example of the

  • scan (Scan object) – The scan object that will define the scan dimensions the measurement.

Returns:

The allocated measurement or path to hdf5 file with the measurement data.

Return type:

Measurement object or str

copy()[source]

Make a copy.

Return type:

SegmentedDetector

detect(waves)[source]

Integrate the intensity of a the wave functions over the detector range.

Parameters:

waves (Waves object) – The batch of wave functions to detect.

Returns:

Detected values. The first dimension indexes the batch size, the second and third indexes the radial and angular bins, respectively.

Return type:

3d array

property inner

Inner integration limit [mrad].

Return type:

float

property nbins_angular

Number of angular bins.

Return type:

int

property nbins_radial

Number of radial bins.

Return type:

int

property outer

Outer integration limit [mrad].

Return type:

float

property save_file

The path to the file for saving the detector output.

Return type:

str

show(waves, **kwargs)

Visualize the detector region(s) of the detector as applied to a specified wave function.

Parameters:
  • waves (Waves or SMatrix object) – The wave function the visualization will be created to match

  • kwargs – Additional keyword arguments for abtem.visualize.mpl.show_measurement_2d.

class abtem.detect.WavefunctionDetector(save_file=None)[source]

Wave function detector object

The wave function detector records the raw exit wave functions.

Parameters:

save_file (str) – The path to the file used for saving the detector output.

allocate_measurement(waves, scan)[source]

Allocate a Measurement object or an hdf5 file.

Parameters:
  • waves (Waves or SMatrix object) – The wave function that will define the shape of the diffraction patterns.

  • scan (Scan object) – The scan object that will define the scan dimensions the measurement.

Returns:

The allocated measurement or path to hdf5 file with the measurement data.

Return type:

Measurement object or str

detect(waves)[source]

Detect the complex wave function.

Parameters:

waves (Waves object) – The batch of wave functions to detect.

Returns:

The arrays of the Waves object.

Return type:

3d complex array

property save_file

The path to the file for saving the detector output.

Return type:

str