Skip to content

pypty.dpc

get_curl

Compute the standard deviation of the curl of a rotated DPC vector field. This is the objective function for minimization. This particular function was copied from a DPC plugin written by Jordan Hachtel.

PARAMETER DESCRIPTION
angle

Rotation angle in radians.

TYPE: float

dpcx

X-component of the DPC signal.

TYPE: ndarray

dpcy

Y-component of the DPC signal.

TYPE: ndarray

RETURNS DESCRIPTION
float

Standard deviation of the curl after rotation.

get_curl_derivative

Compute the derivative of the curl-based objective function with respect to rotation angle.

PARAMETER DESCRIPTION
angle

Rotation angle in radians.

TYPE: float

dpcx

X-component of the DPC signal.

TYPE: ndarray

dpcy

Y-component of the DPC signal.

TYPE: ndarray

RETURNS DESCRIPTION
float

Derivative of the curl-based objective function.

GetPLRotation

Estimate rotation angle that minimizes the curl of the DPC signal.

PARAMETER DESCRIPTION
dpcx

X-component of the DPC signal (2D array).

TYPE: ndarray

dpcy

Y-component of the DPC signal (2D array).

TYPE: ndarray

RETURNS DESCRIPTION
float

Optimal rotation angle in radians.

fft_based_dpc

FFT-based DPC phase reconstruction. If you setted up the pypty_params properly, you would only need to specify the hpass and lpass values, both are non-negative floats.

PARAMETER DESCRIPTION
pypty_params

PyPty parameter dictionary with dataset and calibration settings.

TYPE: dict

hpass

High-pass filtering coefficient (default is 0).

TYPE: float DEFAULT: 0

lpass

Low-pass filtering coefficient (default is 0).

TYPE: float DEFAULT: 0

save

Whether to save the reconstructed phase (default is False).

TYPE: bool DEFAULT: False

comx

Precomputed center-of-mass x-component.

TYPE: ndarray or None DEFAULT: None

comy

Precomputed center-of-mass y-component.

TYPE: ndarray or None DEFAULT: None

plot

If True, display the phase reconstruction.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
pot

Reconstructed 2D phase image.

TYPE: ndarray

pypty_params

Updated parameter dictionary with computed COM and rotation angle.

TYPE: dict

iterative_dpc

Iterative DPC phase reconstruction. If you setted up the pypty_params properly, you would only need to specify the hpass and lpass values, both are non-negative floats.

PARAMETER DESCRIPTION
pypty_params

PyPty parameter dictionary.

TYPE: dict

num_iterations

Number of gradient descent iterations (default is 100).

TYPE: int DEFAULT: 100

beta

Step reduction factor for backtracking (default is 0.5).

TYPE: float DEFAULT: 0.5

hpass

High-pass filtering coefficient (default is 0).

TYPE: float DEFAULT: 0

lpass

Low-pass filtering coefficient (default is 0).

TYPE: float DEFAULT: 0

step_size

Initial gradient descent step size (default is 0.1).

TYPE: float DEFAULT: 0.1

COMx

X-component of COM map.

TYPE: ndarray or None DEFAULT: None

COMy

Y-component of COM map.

TYPE: ndarray or None DEFAULT: None

px_size

Scan step size in Ångströms.

TYPE: float or None DEFAULT: None

print_flag

Whether to print progress information (default is False).

TYPE: bool DEFAULT: False

save

Whether to save the result to disk (default is False).

TYPE: bool DEFAULT: False

select

Optional binary mask to constrain reconstruction.

TYPE: ndarray or None DEFAULT: None

plot

If True, plot the reconstruction result.

TYPE: bool DEFAULT: True

use_backtracking

Whether to use backtracking line search (default is True).

TYPE: bool DEFAULT: True

pad_width

Padding width to suppress FFT boundary artifacts (default is 5).

TYPE: int DEFAULT: 5

RETURNS DESCRIPTION
padded_phase

Reconstructed 2D phase image.

TYPE: ndarray

iterative_poisson_solver

Iterative solver for Poisson equation given a Laplacian map.

PARAMETER DESCRIPTION
laplace

Input 2D array representing the Laplacian of the desired phase.

TYPE: ndarray

num_iterations

Number of iterations (default is 100).

TYPE: int DEFAULT: 100

beta

Step size reduction factor (default is 0.5).

TYPE: float DEFAULT: 0.5

hpass

High-pass filtering parameter (default is 0).

TYPE: float DEFAULT: 0

lpass

Low-pass filtering parameter (default is 0).

TYPE: float DEFAULT: 0

select

Optional binary mask to restrict updates.

TYPE: ndarray or None DEFAULT: None

px_size

Pixel size in Ångströms (default is 1).

TYPE: float DEFAULT: 1

print_flag

If True, print convergence status (default is False).

TYPE: bool DEFAULT: False

step_size

Initial gradient descent step size (default is 0.1).

TYPE: float DEFAULT: 0.1

use_backtracking

Whether to use backtracking line search (default is True).

TYPE: bool DEFAULT: True

pad_width

Number of pixels to pad around the solution (default is 1).

TYPE: int DEFAULT: 1

xp

Backend array library (NumPy or CuPy, default is NumPy).

TYPE: module DEFAULT: numpy

RETURNS DESCRIPTION
ndarray

Reconstructed 2D phase from the input Laplacian.