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 provided by the crystals library. A summary of the documentation is provided below.

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.

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 Protein DataBank (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

Exponential curve with onset.

biexponential

Bi-exponential curve with onset.

with_irf

This decorator factory that applies a Gaussian impulse response function (IRF) to a fitting function.

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.

Time-series Selections

Selection

Abstract base class for time-series selection masks.

RectSelection

Rectangular selection mask.

DiskSelection

Disk selection mask.

RingSelection

Ring selection mask, i.e. 2-torus.

RingArcSelection

Selection patch for a partial 2-torus.

ArbitrarySelection

Arbirary selection mask, represented by a boolean array.

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.

Calibrations

powder_calq

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

Center-finding

autocenter

Find the center of a diffraction pattern automatically.

Image alignment

align

Align a diffraction image to a reference.

ialign

Generator of aligned diffraction images.

itrack_peak

Generator function that tracks a diffraction peak in a stream 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.

Single-crystal indexing

bragg_peaks

Extract the position of Bragg peaks in a single-crystal diffraction pattern.

bragg_peaks_persistence

Extract the position of Bragg peaks in a single-crystal diffraction pattern using 2D persistence of the image landscape.

brillouin_zones

Generate Brillouin zone projections in the particular 2D geometry based on Bragg peak locations.

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.

kinematicsim

Propagate a plane wave through a crystal and compute the resulting diffraction pattern, in the kinematic approximation (thin specimen).

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.

Visualization

potential_map

Compute the electrostatic potential from powder diffraction data.

potential_synthesis

Synthesize the electrostatic potential from a list of experimental reflections and associated diffracted intensities.

patterson

Computation of the patterson pair-distribution function from azimuthally-averaged diffraction pattern.

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.

spectrum_cmap

Rainbow-style Matplotlib colormap generated from skued.spectrum_colors().

rgb_sweep

Generate a set of RGB colors as a linear sweep between two RGB colors source and dest.

indices_to_text

Returns a Matplotlib-compatible string representation of Miller indices, in LaTeX/Mathjax format.

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. general affine transforms.

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.