exitwave#
Functions related to creating and manipulating ptychographic exitwave arrays.
Ptychographic exitwaves are stored as a single complex array which represent the wavefield after any and all interaction with the sample and thus there’s just free space propagation to the detector.
- class tike.ptycho.exitwave.ExitWaveOptions[source]#
Bases:
object
Manage data and setting related to exitwave updates.
New in version 0.25.0.
- __init__(measured_pixels, noise_model='gaussian', step_length_weight=0.5, step_length_usemodes='all_modes', step_length_start=0.5, unmeasured_pixels_scaling=1.0, propagation_normalization='ortho')#
- Parameters
measured_pixels (numpy.typing.NDArray.numpy.bool_) –
noise_model (str) –
step_length_weight (float) –
step_length_usemodes (str) –
step_length_start (float) –
unmeasured_pixels_scaling (float) –
propagation_normalization (str) –
- Return type
None
- measured_pixels: numpy.typing.NDArray.numpy.bool_#
A boolean array that defines spatial regions on the detector where we have measured pixels. False for bad pixels and True for good pixels.
- noise_model: str = 'gaussian'#
‘gaussian’ OR ‘poisson’ The noise model for the exitwave updates
- propagation_normalization: str = 'ortho'#
Choose the scaling of the FFT in the forward model:
“ortho” - the forward and adjoint operations are divided by sqrt(n)
“forward” - the forward operation is divided by n
“backward” - the backard operation is divided by n
- resample(factor)[source]#
Return a new ExitWaveOptions with the parameters rescaled.
- Parameters
factor (float) –
- Return type
- step_length_start: float = 0.5#
We use an iterative/recursive method for finding the steplengths, and this is what we use as initialization for that method.
- step_length_usemodes: str = 'all_modes'#
When computing steplength for exitwave updates, there are two ways we do this:
“dominant_mode” - use the dominant mode to compute the steplength and use that steplength for the other less dominant modes
“all_modes” - compute the steplength for each mode independently
- step_length_weight: float = 0.5#
When computing steplength, we use a weighted average of the previous calculated step and the current calculated step, options are 0.0 <= step_length_weight <= 1.0, with being closer to 1.0 favoring the current calculated step
- unmeasured_pixels_scaling: float = 1.0#
Depending on how we control scaling for the exitwaves, we might need to scale up or down the number of photons in the unmeasured regions for the exitwave updates in Fourier space. 1.0 for no scaling.
- tike.ptycho.exitwave.crop_fourier_space(x, w)[source]#
Crop x assuming a 2D frequency space image with zero frequency in corner.
- Parameters
x (numpy.ndarray) –
w (int) –
- Return type
numpy.ndarray
- tike.ptycho.exitwave.poisson_steplength_all_modes(xi, abs2_Psi, I_e, I_m, measured_pixels, step_length, weight_avg)[source]#
Compute the optimal steplength for each exitwave mode independently.
- Parameters
xi ((FRAME, 1, 1, WIDE, HIGH) float32) – xi = 1 - I_m / I_e
abs2_Psi ((FRAME, 1, SHARED, WIDE, HIGH ) float32) – the squared absolute value of the calulated exitwaves
I_m ((FRAME, WIDE, HIGH) float32) – measured diffraction intensity
I_e ((FRAME, WIDE, HIGH) float32) – calculated diffraction intensity
measured_pixels ((WIDE, HIGH) float32) – the regions on the detector where we have defined measurements
step_length ((FRAME, 1, SHARED, 1, 1) float32) – the steplength initializations
weight_avg (float) – the weight we use when computing a weighted average with ( 0.0 <= weight_avg <= 1.0 )
- tike.ptycho.exitwave.poisson_steplength_dominant_mode(xi, I_e, I_m, measured_pixels, step_length, weight_avg)[source]#
Compute the optimal steplength for each exitwave mode using only the dominant mode.
- Parameters
xi ((FRAME, 1, 1, WIDE, HIGH) float32) – xi = 1 - I_m / I_e
I_m ((FRAME, WIDE, HIGH) float32) – measured diffraction intensity
I_e ((FRAME, WIDE, HIGH) float32) – calculated diffraction intensity
measured_pixels ((WIDE, HIGH) float32) – the regions on the detector where we have defined measurements
step_length ((FRAME, 1, SHARED, 1, 1) float32) – the steplength initializations
weight_avg (float) – the weight we use when computing a weighted average with ( 0.0 <= weight_avg <= 1.0 )