qem.probe

Functions for emulating electron optics of a TEM.

Functions

Cc_defocus_spread(df, Cc, deltaE, eV, deltaEconv)

Calculate the defocus spread for chromatic aberration.

Cc_integration_points(Cc, deltaE, eV[, ...])

Calculate the defocus integration points for simulating chromatic aberration.

aberration_starter_pack()

Create the set of aberrations up to fifth order.

chi(q, qphi, lam[, df, aberrations])

Calculate the aberration function, chi.

convert_deltaE(deltaE, deltaEconv)

Convert the energy spread input to a 1/e spread.

convert_tilt_angles(tilt, tilt_units, rsize, eV)

Convert tilt to pixel or inverse Angstroms units regardless of input units.

depth_of_field(eV, alpha)

Calculate the probe depth of field (z-resolution) for a probe.

focused_probe(gridshape, rsize, eV, app[, ...])

Make a focused electron probe wave function.

make_contrast_transfer_function(pix_dim, ...)

Make an electron lens contrast transfer function.

plane_wave_illumination(gridshape, gridsize, eV)

Generate plane wave illumination for input to multislice.

q_space_array(pixels, gridsize[, meshed])

Return the appropriately scaled 2D reciprocal space coordinates.

relativistic_mass_correction(E)

Evaluate the relativistic mass correction for electron with energy E in eV.

simulation_result_with_Cc(func, Cc, deltaE, eV)

Perform a simulation using function, taking into account chromatic aberration.

wavev(E)

Evaluate the relativistically corrected wavenumber of an electron with energy E.

Classes

aberration(Krivanek, Haider, Description, ...)

A class describing electron lens aberrations.

class qem.probe.aberration(Krivanek, Haider, Description, amplitude, angle, n, m)[source]

A class describing electron lens aberrations.

__init__(Krivanek, Haider, Description, amplitude, angle, n, m)[source]

Intialize the lens aberration object.

Parameters:
  • Krivanek (str) – A string describing the aberration coefficient in Krivanek notation (C_mn)

  • Haider (str) – A string describing the aberration coefficient in Haider notation (ie. A1, A2, B2)

  • Description (str) – A string describing the colloqiual name of the aberration ie. 2-fold astig.

  • amplitude (float) – The amplitude of the aberration in Angstrom

  • angle (float) – The angle of the aberration in radians

  • n (int) – The principle aberration order

  • m (int) – The rotational order of the aberration.

qem.probe.depth_of_field(eV, alpha)[source]

Calculate the probe depth of field (z-resolution) for a probe.

Parameters:
  • eV (float) – Probe accelerating voltage in electron volts

  • alpha (float) – Probe forming semi-angle in mrad

Returns:

dof (float) – The probe full-width-at-half-maximum (FWHM) depth of field

qem.probe.aberration_starter_pack()[source]

Create the set of aberrations up to fifth order.

qem.probe.chi(q, qphi, lam, df=0.0, aberrations=None)[source]

Calculate the aberration function, chi.

Parameters:
  • q (float or array_like) – Reciprocal space extent (Inverse angstroms).

  • qphi (float or array_like) – Azimuth of grid in radians

  • lam (float) – Wavelength of electron (Inverse angstroms).

  • df (float, optional) – Defocus in Angstrom

  • aberrations (list, optional) – A list containing a set of the class aberration, pass an empty list for an unaberrated contrast transfer function.

Returns:

chi (float or array_like) – The aberration function, will be the same shape as q. This is used to calculate the probe wave function in reciprocal space.

qem.probe.make_contrast_transfer_function(pix_dim, real_dim, eV, app, optic_axis=None, aperture_shift=None, tilt_units='mrad', df=0, aberrations=None, q=None, app_units='mrad')[source]

Make an electron lens contrast transfer function.

Parameters:
  • pix_dim ((2,) int array_like) – The pixel size of the grid

  • real_dim ((2,) float array_like) – The size of the grid in Angstrom

  • eV (float) – The energy of the probe electrons in eV

  • app (float or None) – The aperture in units specified by app_units, pass app = None for no aperture

  • optic_axis ((2,) array_like, optional) – allows the user to specify a different optic axis in units specified by tilt_units

  • aperture_shift ((2,) array_like, optional) – Shift of the objective aperture relative to the center of the array

  • tilt_units (string) – Units of the optic_axis or aperture_shift values, default is mrad

  • df (float) – Probe defocus in A, a negative value indicate overfocus

  • aberrations (array_like of aberration objects) – List containing instances of class aberration

  • q – Precomputed reciprocal space array, allows the user to reduce computation time somewhat

  • app_units (string) – The units of app (A^-1 or mrad)

Returns:

ctf (array_like) – The lens contrast transfer function in reciprocal space

qem.probe.focused_probe(gridshape, rsize, eV, app, beam_tilt=None, aperture_shift=None, tilt_units='mrad', df=0, aberrations=None, q=None, app_units='mrad', qspace=False)[source]

Make a focused electron probe wave function.

Parameters:
  • gridshape ((2,) array_like) – The pixel size of the grid

  • rsize ((2,) array_like) – The size of the grid in Angstrom

  • eV (float) – The energy of the probe electrons in electron volts

  • app (float) – The probe-forming apperture in units specified by app_units, pass None if no probe forming aperture is to be used

  • beam_tilt (array_like, optional) – Allows the user to simulate a (small < 50 mrad) beam tilt. To maintain periodicity of the wave function at the boundaries this tilt is rounded to the nearest pixel value.

  • aperture_shift (array_like, optional) – Allows the user to simulate a (small < 50 mrad) aperture shift. To maintain periodicity of the wave function at the boundaries this tilt is rounded to the nearest pixel value.

  • tilt_units (string, optional) – Units of beam tilt and aperture shift, can be ‘mrad’,’pixels’ or ‘invA’

  • df (float, optional) – Probe defocus in A, a negative value indicate overfocus

  • aberrations (list, optional) – A list of of probe aberrations of class pyms.Probe.aberration, pass an empty list for an un-aberrated probe

  • app_units (string, optional) – The units of the aperture size (“invA”, “pixels” or “mrad”)

  • qspace (bool, optional) – If True return the probe in reciprocal space

Returns:

probe (complex (Y,X) np.ndarray) – The requested electron probe wave function

qem.probe.plane_wave_illumination(gridshape, gridsize, eV, tilt=None, tilt_units='mrad', qspace=False)[source]

Generate plane wave illumination for input to multislice.

The wave function will be normalized such that sum of intensity is unity in real space.

Parameters:
  • gridshape ((2,) array_like) – Pixel dimensions of the 2D grid

  • gridsize ((2,) array_like) – Size of the grid in real space

  • eV (float) – Probe energy in electron volts (irrelevant for untilted illumination)

  • tilt (array_like, optional) – Allows the user to simulate a (small < 50 mrad) beam tilt, To maintain periodicity of the wave function at the boundaries this tilt is rounded to the nearest pixel value.

  • tilt_units (string, optional) – Units of beam tilt, can be ‘mrad’,’pixels’ or ‘invA’

  • qspace (bool, optional) – Pass qspace = True to get the probe in momentum (q) space

Returns:

illum (np.ndarray (Y,X))

qem.probe.wavev(E)[source]

Evaluate the relativistically corrected wavenumber of an electron with energy E.

Energy E must be in electron-volts, see Eq. (2.5) in Kirkland’s Advanced Computing in electron microscopy

qem.probe.relativistic_mass_correction(E)[source]

Evaluate the relativistic mass correction for electron with energy E in eV.

See Eq. (2.2) in Kirkland’s Advanced Computing in electron microscopy.

qem.probe.simulation_result_with_Cc(func, Cc, deltaE, eV, args=None, kwargs=None, npoints=7, deltaEconv='1/e')[source]

Perform a simulation using function, taking into account chromatic aberration.

Pass in the function that simulates the multislice result, it is assumed that defocus is a variable named ‘df’ somewhere in the keyword argument list.

Parameters:
  • func (function) – Function that simulates the result of interest, ie. pyms.HRTEM. The defocus must be present in the keyword argument list as ‘df’

  • Cc (float) – Chromatic aberration coefficient in Angstroms

  • deltaE (float) – Energy spread in electron volts using 1/e measure of spread (to convert from FWHM divide by 1.655, and divide by sqrt(2) to convert from standard deviation )

  • eV (float) – (Mean) beam energy in electron volts

  • args (list, optional) – Arguments for the method function used to propagate probes to the exit surface

  • kwargs (Dict, optional) – Keyword arguments for the method function used to propagate probes to the exit surface

  • npoints (int,optional) – Number of integration points in the Cc numerical integration

Returns:

average (dict or array_like) – The simulation requested but averaged over the different defocus values to account for chromatic aberration.

qem.probe.Cc_integration_points(Cc, deltaE, eV, npoints=7, deltaEconv='1/e')[source]

Calculate the defocus integration points for simulating chromatic aberration.

The integration points are selected by dividing the assumed gaussian defocus spread into npoints regions of equal probability, then finding the mean defocus in each of those regions.

Parameters:
  • Cc (float) – Chromatic aberration coefficient in Angstroms

  • deltaE (float) – Energy spread in electron volts using 1/e measure of spread (to convert from FWHM divide by 1.655, and divide by sqrt(2) to convert from standard deviation )

  • eV (float) – (Mean) beam energy in electron volts

  • npoints (int,optional) – Number of integration points in the Cc numerical integration

  • deltaEconv (float,optional) – The convention for deltaE, the energy spread, acceptable inputs are ‘1/e’ the energy point that the probability density function drops to 1/e times its maximum value, ‘std’ for standard deviation and ‘FWHM’ for the full width at half maximum of the energy spread.

Returns:

defocii ((`npoints,) array_like`) – The defocus integration points

qem.probe.Cc_defocus_spread(df, Cc, deltaE, eV, deltaEconv)[source]

Calculate the defocus spread for chromatic aberration.

Evaluates the probability density function at defocus df for the defocus spread of a chromatic aberration (Cc) for (1/e) energy spread deltaE and beam energy eV in electron volts.

Parameters:
  • df (float or array_like) – defocus or defocii at which to evaluate the probability density function

  • Cc (float) – Chromatic aberration coefficient in Angstroms

  • deltaE (float) – Energy spread in electron volts using the measure given by deltaEconv (1/e measure of spread is default)

  • eV (float) – (Mean) beam energy in electron volts

  • deltaEconv (string,optional) – The convention for deltaE, the energy spread, acceptable inputs are ‘1/e’ the energy point that the probability density function drops to 1/e times its maximum value, ‘std’ for standard deviation and ‘FWHM’ for the full width at half maximum of the energy spread

Returns:

Cc_pdf (float or array_like) – the probability density function, will be the same size and shape as df

qem.probe.convert_deltaE(deltaE, deltaEconv)[source]

Convert the energy spread input to a 1/e spread.

Parameters:
  • deltaE (float) – Energy spread in electron volts using the measure given by deltaEconv

  • deltaEconv (string) – The convention for deltaE, the energy spread, acceptable inputs are ‘1/e’ the energy point that the probability density function drops to 1/e times its maximum value, ‘std’ for standard deviation and ‘FWHM’ for the full width at half maximum of the energy spread

qem.probe.convert_tilt_angles(tilt, tilt_units, rsize, eV, invA_out=False)[source]

Convert tilt to pixel or inverse Angstroms units regardless of input units.

Input units can be mrad, pixels or inverse Angstrom

Parameters:
  • tilt (array_like) – Tilt in units of mrad, pixels or inverse Angstrom

  • tilt_units (string) – Units of specimen and beam tilt, can be ‘mrad’,’pixels’ or ‘invA’

  • rsize ((2,) array_like) – The size of the grid in Angstrom

  • eV (float) – Probe energy in electron volts

  • invA_out (bool) – Pass True if inverse Angstrom units are desired.