STSim#

class pyrost.simulation.STSim(params, backend='numpy', bars=None, det_ix=None, det_iy=None, det_wfx=None, det_wfy=None, lens_wfx=None, lens_wfy=None, roi=None, smp_pos=None, smp_profile=None, smp_wfx=None, smp_wfy=None)#

One-dimensional Speckle Tracking scan simulation class. Generates barcode’s transmission profile and lens’ abberated wavefront, whereupon propagates the wavefront to the detector’s plane.

Parameters
  • params (STParams) – Set of simulation parameters.

  • backend (str) – Choose between numpy (‘numpy’) or FFTW (‘fftw’) library for the FFT implementation.

  • kwargs – Any of the optional attributes specified in STSim notes.

Notes

Necessary attributes:

  • backend : the backend library for the FFT implementation.

  • params : Experimental parameters.

Optional attributes:

  • bars : Barcode’s bar positions [um].

  • det_wfx : Wavefront at the detector plane along the x axis.

  • det_wfy : Wavefront at the detector plane along the y axis.

  • det_iy : Intensity profile at the detector plane along the x axis.

  • det_iy : Intensity profile at the detector plane along the y axis.

  • lens_wfx : Wavefront at the lens plane along the x axis.

  • lens_wfy : Wavefront at the lens plane along the y axis.

  • num_threads : Number of threads used in the calculations.

  • n_x : Wavefront size along the x axis.

  • n_y : Wavefront size along the y axis.

  • roi : Region of interest in detector plane.

  • smp_pos : Sample translations along the x axis.

  • smp_profile : Barcode’s transmission profile.

  • smp_wfx : Wavefront at the sample plane along the x axis.

  • smp_wfy : Wavefront at the sample plane along the y axis.

Raises

ValueError – If the ‘backend’ keyword is invalid.

find_beam_roi()#

Calculate the beam’s field of view at the detector grid as a list of four pixel coordinates.

Return type

Tuple[int, int, int, int]

Returns

A set of four coordinates (‘y0’, ‘y1’, ‘x0’, ‘x1’), where ‘y0’ and ‘y1’ are the lower and upper bounds of the beam along the vertical detector axis and ‘x0’ and ‘x1’ are the lower and upper bounds of the beam along the horizontal axis.

frames(wfieldx=None, wfieldy=None, apply_noise=True)#

Return intensity frames at the detector plane. Applies Poisson noise if apply_noise is True.

Parameters
  • wfieldx (Optional[ndarray]) – Whitefield profile along the x axis.

  • wfieldy (Optional[ndarray]) – Whitefield profile along the y aixs.

  • apply_noise (bool) – Apply Poisson noise if it’s True.

Return type

ndarray

Returns

Intensity frames.

ptychograph(wfieldx=None, wfieldy=None, apply_noise=True)#

Return a ptychograph of intensity frames. Applies Poisson noise if apply_noise is True.

Parameters
  • wfieldx (Optional[ndarray]) – Whitefield profile along the x axis.

  • wfieldy (Optional[ndarray]) – Whitefield profile along the y aixs.

  • apply_noise (bool) – Apply Poisson noise if it’s True.

Return type

ndarray

Returns

Ptychograph.

update_bars(bars)#

Return a new STSim object with the updated bars.

Parameters

bars (ndarray) – Array of barcode’s bar positions.

Return type

STSim

Returns

A new STSim object with the updated bars.

update_roi(roi)#

Return a new STSim object with the updated region of interest.

Parameters
  • roi (ndarray) – Region of interest in detector plane. The values are

  • following (given in pixels as) – [x0, x1, y0, y1].

Return type

STSim

Returns

A new STSim object with the updated roi.