Single Side Band

class ptychography40.reconstruction.ssb.SSB_UDF(lamb, dpix, semiconv, semiconv_pix, dtype=<class 'numpy.float32'>, cy=None, cx=None, transformation=None, cutoff=1, method='subpix', mask_container=None)[source]

UDF to perform ptychography using the single side band (SSB) method [PLY+15].

__init__(lamb, dpix, semiconv, semiconv_pix, dtype=<class 'numpy.float32'>, cy=None, cx=None, transformation=None, cutoff=1, method='subpix', mask_container=None)[source]
Parameters:
  • lamb (float) – The illumination wavelength in m. The function ptychography40.common.wavelength() allows to calculate the electron wavelength as a function of acceleration voltage.

  • dpix (float or Iterable(y, x)) – STEM pixel size in m

  • semiconv (float) – STEM semiconvergence angle in radians

  • dtype (np.dtype) – dtype to perform the calculation in

  • semiconv_pix (float) – Diameter of the primary beam in the diffraction pattern in pixels

  • cy (float, optional) – Position of the optical axis on the detector in px, center of illumination. Default: Center of the detector

  • cx (float, optional) – Position of the optical axis on the detector in px, center of illumination. Default: Center of the detector

  • transformation (numpy.ndarray() of shape (2, 2) or None) – Transformation matrix to apply to shift vectors. This allows to adjust for scan rotation and mismatch of detector coordinate system handedness, such as flipped y axis for MIB.

  • cutoff (int) – Minimum number of pixels in a trotter

  • method ('subpix' or 'shift') – Method to use for generating the mask stack

  • mask_container (MaskContainer) – Allows to pass in a precomputed mask stack when using with single thread live data or with an inline executor as a work-around. The number of masks is sanity-checked to match the other parameters. The proper fix is https://github.com/LiberTEM/LiberTEM/issues/335

get_results()[source]

Since we derive the wave front with a linear function from intensities, but the wave front is inherently an amplitude, we take the square root of the calculated amplitude and combine it with the calculated phase.

ptychography40.reconstruction.ssb.generate_masks(reconstruct_shape, mask_shape, dtype, lamb, dpix, semiconv, semiconv_pix, transformation=None, cy=None, cx=None, cutoff=1, cutoff_freq=inf, method='subpix')[source]

Generate the trotter mask stack.

The y dimension is trimmed to size(y)//2 + 1 to exploit the inherent symmetry of the mask stack.

Parameters:
  • reconstruct_shape (tuple(int)) – Shape of the reconstructed area

  • mask_shape (tuple(int)) – Shape of the detector

  • dtype (numpy dtype) – dtype to use for the mask stack

  • lamb (float) – Wavelength of the illuminating radiation in m

  • dpix (float or (float, float)) – Scan step in m. Tuple (y, x) in case scan step is different in x and y direction.

  • semiconv (float) – Semiconvergence angle of the illumination in radians

  • semiconv_pix (float) – Semiconvergence angle in measured in detector pixel, i.e. radius of the zero order disk.

  • transformation (numpy.ndarray, optional) – Matrix for affine transformation from the scan coordinate directions to the detector coordinate directions. This does not include the scale, which is handled by dpix, lamb, semiconv and semiconv_pix. It should only be used to rotate and flip the coordinate system as necessary. See also https://github.com/LiberTEM/LiberTEM/blob/master/src/libertem/corrections/coordinates.py

  • cy (float, optional) – Position of the optical axis on the detector in px, center of illumination. Default: Center of the detector

  • cx (float, optional) – Position of the optical axis on the detector in px, center of illumination. Default: Center of the detector

  • cutoff (int, optional) – Minimum number of pixels in the positive and negative trotter. This can be used to purge very small trotters to reduce noise. Default is 1, i.e. no cutoff unless one trotter is empty.

  • cutoff_freq (float) – Trotters belonging to a spatial frequency higher than this value in reciprocal pixel coordinates will be cut off.

  • method (str, optional) – Can be 'subpix'`(default) or :code:’shift’` to switch between mask_pair_subpix() and mask_pair_shift() to generate a trotter pair.

Returns:

masks – Masks in sparse.pydata.org COO format. y and x frequency index are FFT shifted, i.e. the zero frequency is at (0,0) and negative frequencies are in the far quadrant and reversed. The y frequency index is cut in half with size(y)//2 + 1 to exploit the inherent symmetry of a real-valued Fourier transform. The y and x index are then flattened to make it suitable for using it with MaskContainer.

Return type:

sparse.COO