Reference/API

Baseline-determination

Please refer to the tutorial on baseline-determination for some examples.

baseline_dt Iterative method of baseline-determination based on the dual-tree complex wavelet transform.
baseline_dwt Iterative method of baseline determination, based on the discrete wavelet transform.
dtcwt 1D Dual-tree complex wavelet transform [1]_ along an axis.
idtcwt 1D Inverse dual-tree complex wavelet transform [1]_ along an axis.
available_dt_filters Iterable of available wavelet filters compatible with the dual-tree complex wavelet transform.
available_first_stage_filters Iterable of available wavelet filters compatible with the first stage of dual-tree complex wavelent transform.

Structure manipulation

Structure manipulation is done through the following classes:

Crystal The Crystal class is a set-like container that represent crystalline structures.
Atom Container object for atomic data.

Bases classes

The Lattice class allows for manipulating lattice information separately from atomic information.

Lattice Container class for lattice information and manipulations.
LatticeSystem Lattice system enumeration.
AtomicStructure Base class for atomic structures.

Utilities

To help with fleshing out unit cell atoms from symmetry operators:

symmetry_expansion Generate a set of unique atoms from an asymmetric cell and symmetry operators.
lattice_system Determine the lattice system.

Parsers

Structure parsers are used to build Crystal instances, mostly through Crystal class methods.

CIFParser Collection of methods that parses CIF files based on cif2cell.
CODParser Collection of methods that parses CIF files retrieved from the Crystallography Open Database.
PDBParser Collection of methods that parses PDB files.

Time-series Analysis

Time-series exploration and analysis.

Time-zero tracking

Measurement of time-shifts between physically-equivalent time traces:

register_time_shift Measure the time shift between a time trace and a reference trace by normalized cross correlation.
register_time_shifts Measure the time shifts between time traces and a reference by cross-correlation.

Robust statistics

mad Element-wise median absolute deviation (MAD) of a signal.

Fitting

exponential_decay Exponential decay curve with onset.
biexponential_decay Bi-exponential decay curve with onset.

Non-uniform Fast Fourier Transform

nfft Non-uniform Fast Fourier Transform (NFFT) computed on a uniform frequency grid.
nfftfreq Compute the frequency range used in nfft for M frequency bins.

Image Analysis

Combine the routines below with npstreams to process diffraction data in parallel. Refer to the tutorial on image manipulation for some examples.

Symmetry

nfold Returns an images averaged according to n-fold rotational symmetry.
reflection Symmetrize an image according to a reflection plane.

Polycrystalline diffraction

azimuthal_average This function returns an azimuthally-averaged pattern computed from an image, e.g.
powder_center Finds the center of a powder diffraction pattern by comparing the correlation between the input and its image.

Calibrations

powder_calq Determine the scattering vector q corresponding to a polycrystalline diffraction pattern and a known crystal structure.

Image alignment

align Align a diffraction image to a reference.
ialign Generator of aligned diffraction images.
diff_register Register translation of diffraction patterns by masked normalized cross-correlation.
shift_image Shift an image.
itrack_peak Generator function that tracks a diffraction peak in a stream of images.

Correlations

xcorr Cross-correlation between two N-dimensional arrays.
mnxc2 Masked normalized cross-correlation (MNXC) between two images or stacks of images.

Image masking

mask_from_collection Determine binary mask from a set of images.
combine_masks Combine multiple pixel masks into one.
mask_image Fill invalid pixels in an image with another value, according to a pixel mask.

Image noise

snr_from_collection Signal-to-noise ratio (SNR) on a per-pixel basis, for images in a collection.
isnr Streaming, pixelwise signal-to-noise ratio (SNR).
triml Trim values in an array that fall below (i.e.
trimr Trim values in an array that fall above (i.e.

Simulation

structure_factor Computation of the static structure factor for electron diffraction.
affe Atomic form factors for electrons, for neutral atoms.
powdersim Simulates polycrystalline diffraction pattern.
electrostatic Electrostatic potential from a crystal calculated on a real-space mesh, assuming an infinite crystal.
pelectrostatic Projected electrostatic potential from a crystal calculated on a real-space mesh, assuming an infinite crystal in x and y.
bounded_reflections Returns iterable of reflections (hkl) with norm(G) < nG

Visualization

potential_map Compute the electrostatic potential from powder diffraction data.

Input/Output

General diffraction image I/O and plotting. Note that for diffshow(), the packages PyQtGraph and PyQt5 must be installed.

diffread Load an image from a file.
diffshow Display an image (from an array or from a file) in an interactive window.

Note

You should prefer to use diffread() to the specific format functions like mibread() and dmread()

Digital Micrograph DM3/DM4:

dmread Read a DM3/DM4 (Digital Micrograph) file into a NumPy array.

Merlin Image Binary (.mib) files:

mibheader Get an image header from a Merlin Image Binary file.
mibread Read a MIB (Merlin Image Binary) file into a NumPy array.
imibread Generator of images contained in a Merlin Image Binary file as NumPy arrays.

Plot Utilities

spectrum_colors Generates a set of RGB colors corresponding to the visible spectrum (i.e.
rgb_sweep Generate a set of RGB colors as a linear sweep between two RGB colors source and dest.

Array Utilities

mirror Reverse array over many axes.
repeated_array Create a composite array from repeated copies of an array
cart2polar Transform cartesian coordinates to polar coordinates.
polar2cart Transform polar coordinates to cartesian coordinates.
cart2spherical Transform cartesian coordinates into spherical coordinates .
spherical2cart Transform spherical coordinates into cartesian coordinates.
plane_mesh Generate a spatial mesh for a plane defined by two vectors.

Electron Properties

electron_wavelength Relativistic wavelength \(\lambda\) of an accelerated electron.
electron_velocity Relativistic velocity \(v_e\) of an accelerated electron.
interaction_parameter Interaction parameter from relativistic electron wavelength.
lorentz Relativistic factor \(\gamma\), defined as \(\gamma = \frac{1}{\sqrt{1 - v^2/c^2}}\)

Thin Film Optical Properties

film_optical_coefficients Calculate the reflection, transmission, and absorption coefficients of a thin-film (possibly on a substrate).

Voigt Profile

gaussian Unit integral Gaussian function.
lorentzian Unit integral Lorenzian function.
pseudo_voigt Unit integral pseudo-Voigt profile.

Affine Transforms

affine_map Extends 3x3 transform matrices to 4x4, i.e.
transform Applies a matrix transform on an array.
change_of_basis Returns the matrix that goes from one basis to the other.
change_basis_mesh Changes the basis of meshgrid arrays.
is_basis Returns true if the set of vectors forms a basis.
is_rotation_matrix Checks whether a matrix is orthogonal with unit determinant (1 or -1), properties of rotation matrices.
minimum_image_distance Returns a periodic array according to the minimum image convention.
rotation_matrix Return matrix to rotate about axis defined by direction around the origin [0,0,0].
translation_matrix Return matrix to translate by direction vector.
translation_rotation_matrix Returns a 4x4 matrix that includes a rotation and a translation.