probe

Functions related to creating and manipulating probe arrays.

Ptychographic probes are represented as two separate components: a shared probe whose values are the same for all positions and the varying component. The former is required as it provides the shared probe constraint for ptychography and the later relaxes the former constraint to accomodate real-world illuminations which may vary with time.

The shared component consist of a single array representing at least one probe each of which may have an accompanying varying component.

The varying components are stored sparsely as two arrays, and the full representation of the varying comonents are only combined as needed. The first array is an array of eigen probes (principal components) spanning the space of the probe variation of all positions and the second is an array of weights that map the variation for each position into this space.

Each probe may have its own set of eigen probes. The unique probe at a given position is reconstructed by adding the shared probe to a weighted sum of the eigen probes.

varying_probe = probe + np.sum(weights * eigen_probes)

Design comments

In theory, the probe representation could be implemented in as little as two arrays: one with all of the shared components where the probe becomes the first eigen probe and and one with the weights. Choosing to keep the eigen probes separate from the probe as a third array provides backwards compatability and allows for storing fewer eigen probes in the case when only some probes are allowed to vary.

tike.ptycho.probe.add_modes_random_phase(probe, nmodes)[source]

Initialize additional probe modes by phase shifting the first mode.

Parameters
  • probe ((:, :, :, M, :, :) array) – A probe with M > 0 incoherent modes.

  • nmodes (int) – The number of desired modes.

References

M. Odstrcil, P. Baksh, S. A. Boden, R. Card, J. E. Chad, J. G. Frey, W. S. Brocklesby, “Ptychographic coherent diffractive imaging with orthogonal probe relaxation.” Opt. Express 24, 8360 (2016). doi: 10.1364/OE.24.008360

tike.ptycho.probe.gaussian(size, rin=0.8, rout=1.0)[source]

Return a complex gaussian probe distribution.

Illumination probe represented on a 2D regular grid.

A finite-extent circular shaped probe is represented as a complex wave. The intensity of the probe is maximum at the center and damps to zero at the borders of the frame.

Parameters
  • size (int) – The side length of the distribution

  • rin (float [0, 1) < rout) – The inner radius of the distribution where the dampening of the intensity will start.

  • rout (float (0, 1] > rin) – The outer radius of the distribution where the intensity will reach zero.

tike.ptycho.probe.get_varying_probe(shared_probe, eigen_probe=None, weights=None, m=None)[source]

Construct the varying m-th probes.

Parameters
  • shared_probe ((…, 1, 1, SHARED, WIDE, HIGH) complex64) – The shared probes amongst all positions.

  • m (int or list(int)) – The index of the requested probe.

  • eigen_probe ((…, 1, EIGEN, SHARED, WIDE, HIGH) complex64) – The eigen probes for all positions.

  • weights ((…, POSI, EIGEN, SHARED) float32) – The relative intensity of the eigen probes at each position.

Returns

unique_probes ((…, POSI, 1, 1, WIDE, HIGH))

tike.ptycho.probe.init_varying_probe(scan, shared_probe, N)[source]

Initialize arrays for N eigen modes.

tike.ptycho.probe.orthogonalize_eig(x)[source]

Orthogonalize modes of x using eigenvectors of the pairwise dot product.

Parameters

x ((…, nmodes, :, :) array_like complex64) – An array of the probe modes vectorized

References

M. Odstrcil, P. Baksh, S. A. Boden, R. Card, J. E. Chad, J. G. Frey, W. S. Brocklesby, “Ptychographic coherent diffractive imaging with orthogonal probe relaxation.” Opt. Express 24, 8360 (2016). doi: 10.1364/OE.24.008360

tike.ptycho.probe.simulate_varying_weights(scan, eigen_probe)[source]

Generate weights for eigen probe that follow random sinusoid.

The amplitude of the of weights is 1, the phase shift is (0, 2π], and the period is at most one full scan.

tike.ptycho.probe.update_eigen_probe(comm, R, eigen_probe, weights, patches, diff, β=0.1)[source]

Update eigen probes using residual probe updates.

This update is copied from the source code of ptychoshelves. It is similar to, but not the same as, equation (31) described by Odstrcil et al (2018). It is is also different from updates described in Odstrcil et al (2016). However, they all aim to correct for probe variation.

Parameters
  • comm (tike.communicators.Comm) – An object which manages communications between both GPUs and nodes.

  • R ((…, POSI, 1, 1, WIDE, HIGH) complex64) – Residual probe updates; what’s left after subtracting the shared probe update from the varying probe updates for each position

  • patches ((…, POSI, 1, 1, WIDE, HIGH) complex64)

  • diff ((…, POSI, 1, 1, WIDE, HIGH) complex64)

  • eigen_probe ((…, 1, 1, 1, WIDE, HIGH) complex64) – The eigen probe being updated.

  • β (float) – A relaxation constant that controls how quickly the eigen probe modes are updated. Recommended to be < 1 for mini-batch updates.

  • weights ((…, POSI) float32) – A vector whose elements are sums of the previous optimal updates for each posiiton.

References

M. Odstrcil, P. Baksh, S. A. Boden, R. Card, J. E. Chad, J. G. Frey, W. S. Brocklesby, “Ptychographic coherent diffractive imaging with orthogonal probe relaxation.” Opt. Express 24, 8360 (2016). doi: 10.1364/OE.24.008360

Michal Odstrcil, Andreas Menzel, and Manuel Guizar-Sicaros. Iterative least-squares solver for generalized maximum-likelihood ptychography. Optics Express. 2018.