pyextal.potentialMap.analysis

Peak shifts, Poisson charge density and line profiles of a map.

Classes

PeakShift

A reference-map peak and the refined-map maximum near it.

Functions

find_atom_peaks(result[, threshold_rel, min_distance, ...])

Peaks of the reference map, each paired with the refined maximum nearby.

_laplacian_spectral(volume, steps)

Laplacian of a periodic map on a (possibly oblique) uniform grid.

charge_density(volume[, steps, spacings])

-laplacian(volume): the charge density, up to a constant, of a potential.

charge_from_potential(result[, method, spacings])

Converts a potential MapResult into charge density by Poisson's equation.

_periodic_interpolator(volume)

line_profile(volume, start, end[, num_points])

Values of a 3D periodic map along a straight line.

integrated_profile(volume, start, end, radius[, ...])

A 3D map integrated over discs perpendicular to a line, along that line.

Module Contents

class pyextal.potentialMap.analysis.PeakShift

A reference-map peak and the refined-map maximum near it.

Variables:
  • ref (tuple) – Grid index of the reference peak.

  • refined (tuple) – Grid index of the refined maximum.

  • refined_val (ref_val,) – Map values there.

  • shift (tuple) – Signed index offset, refined minus reference, wrapped to the nearest image.

  • distance_A (float) – Length of shift in Angstrom, through the map’s grid steps (right for non-orthogonal axes).

ref: tuple
refined: tuple
ref_val: float
refined_val: float
shift: tuple
distance_A: float
property distance_px

Length of shift in grid steps.

pyextal.potentialMap.analysis.find_atom_peaks(result, threshold_rel=0.5, min_distance=5, search_radius=5)

Peaks of the reference map, each paired with the refined maximum nearby.

Works on 2D and 3D maps; the grid is periodic.

Parameters:
  • result (MapResult) – The maps.

  • threshold_rel (float) – Keep reference maxima above this fraction of the reference map’s maximum.

  • min_distance (int) – Size of the local-maximum filter, in grid steps.

  • search_radius (int) – Half-width of the window searched in the refined map, in grid steps.

Returns:

list of PeakShift

pyextal.potentialMap.analysis._laplacian_spectral(volume, steps)

Laplacian of a periodic map on a (possibly oblique) uniform grid.

pyextal.potentialMap.analysis.charge_density(volume, steps=None, spacings=None)

-laplacian(volume): the charge density, up to a constant, of a potential.

Parameters:
  • volume (np.ndarray) – Periodic potential map.

  • steps (np.ndarray, optional) – (ndim, 3) Cartesian grid steps (MapResult.steps). Uses an exact spectral Laplacian, right for oblique axes; result in map units per Angstrom^2.

  • spacings (tuple, optional) – Per-axis spacing for the original 3-point finite-difference Laplacian, which assumes orthogonal axes. Used when steps is None (all 1.0 if both are None).

Returns:

Same shape as volume.

Return type:

np.ndarray

pyextal.potentialMap.analysis.charge_from_potential(result, method='spectral', spacings=None)

Converts a potential MapResult into charge density by Poisson’s equation.

Parameters:
  • result (MapResult) – Potential maps.

  • method (str) – ‘spectral’ (exact, uses the grid geometry) or ‘finite_difference’ (the original 3-point stencil with spacings, default 1.0 per axis).

  • spacings (tuple, optional) – For ‘finite_difference’.

Returns:

kind='charge', the maps replaced by -laplacian.

Return type:

MapResult

pyextal.potentialMap.analysis._periodic_interpolator(volume)
pyextal.potentialMap.analysis.line_profile(volume, start, end, num_points=100)

Values of a 3D periodic map along a straight line.

Parameters:
  • volume (np.ndarray) – 3D map on a fractional grid.

  • start (array-like) – End points in fractional coordinates (any image; wrapped into the cell).

  • end (array-like) – End points in fractional coordinates (any image; wrapped into the cell).

  • num_points (int) – Samples along the line.

Returns:

(distance, values), the distance in fractional units.

Return type:

tuple

pyextal.potentialMap.analysis.integrated_profile(volume, start, end, radius, num_points=100, grid_points=21, lattice=None)

A 3D map integrated over discs perpendicular to a line, along that line.

Parameters:
  • volume (np.ndarray) – 3D map on a fractional grid.

  • start (array-like) – End points in fractional coordinates.

  • end (array-like) – End points in fractional coordinates.

  • radius (float) – Disc radius: fractional units, or Angstrom when lattice is given.

  • num_points (int) – Steps along the line.

  • grid_points (int) – Samples across each disc diameter.

  • lattice (np.ndarray, optional) – (3, 3) Cartesian lattice vectors. With it the discs are perpendicular, and round, in real space – needed for a non-cubic cell. Without it they are built in fractional coordinates (the original behaviour).

Returns:

(distance, profile, points). distance along the line (as the radius), points the fractional sampling positions before wrapping, shape (num_points, grid_points, grid_points, 3).

Return type:

tuple