STParams#

class pyrost.simulation.STParams(defocus, det_dist, n_frames, step_size, step_rnd, detx_size, dety_size, pix_size, p0, th_s, wl, alpha, ap_x, ap_y, focus, ab_cnt, bar_atn, bar_rnd, bar_sigma, bar_size, bulk_atn, offset, num_threads=0, seed=0)#

Container with the simulation parameters for the wavefront propagation.

Parameters
  • barcode

    A dictionary of barcode sample parameters. The following elements are accepted:

    • bar_size : Average bar’s size [um].

    • bar_sigma : Bar bluriness width [um].

    • bar_atn : Bar’s attenuation coefficient [0.0 - 1.0].

    • bulk_atn : Barcode’s bulk attenuation coefficient [0.0 - 1.0].

    • bar_rnd : Bar’s coordinates random deviation [0.0 - 1.0].

    • offsetBarcode’s offset at the beginning and at the end

      of the scan from the detector’s bounds [um].

  • detector

    A dictionary of detector parameters. The following elements are accepted:

    • detx_size : Detector’s size along the horizontal axis in pixels.

    • dety_size : Detector’s size along the vertical axis in pixels.

    • pix_size : Detector’s pixel size [um].

  • exp_geom

    A dictionary of experimental geometry parameters. The following elements are accepted:

    • defocus : Lens’ defocus distance [um].

    • det_dist : Distance between the barcode and the detector [um].

    • step_size : Scan step size [um].

    • n_frames : Number of frames.

  • lens

    A dictionary of lens parameters. The following elements are accepted:

    • ap_x : Lens’ aperture size along the x axis [um].

    • ap_y : Lens’ aperture size along the y axis [um].

    • focus : Focal distance [um].

    • alpha : Third order aberrations coefficient [rad / mrad^3].

    • ab_cnt : Lens’ aberrations center point [0.0 - 1.0].

  • source

    A dictionary of X-ray source parameters. The following elements are accepted:

    • p0 : Source beam flux [cnt / s].

    • wl : Source beam’s wavelength [um].

    • th_s : Source rocking curve width [rad].

  • system

    A dictionary of calculation parameters. The following elements are accepted:

    • seed : Seed used in all the pseudo-random number generations.

    • num_threads : Number of threads used in the calculations.

See also

Simulation parameters : Full list of experimental parameters.

bar_positions(dist, rnd_dev=True)#

Generate a coordinate array of barcode’s bar positions at distance dist from focal plane.

Parameters
  • dist (float) – Distance from the focal plane [um].

  • rnd_dev (bool) – Randomize positions if it’s True.

Return type

ndarray

Returns

Array of barcode’s bar coordinates.

See also

pyrost.bin.bar_positions() : Full details of randomized barcode steps generation algorithm.

barcode_profile(x_arr, dx, bars)#

Generate a barcode’s transmission profile at x_arr coordinates.

Parameters
  • x_arr (ndarray) – Array of the coordinates, where the transmission coefficients are calculated [um].

  • dx (float) – Sampling interval of the coordinate array [um].

  • bars (ndarray) – Array of barcode’s bar positions [um].

Return type

ndarray

Returns

Barcode’s transmission profile.

See also

pyrost.bin.barcode_profile() : Full details of barcode’s transmission profile generation algorithm.

beam_span(dist)#

Return beam span along the x axis at distance dist from the focal plane.

Parameters

dist (float) – Distance from the focal plane [um].

Return type

Tuple[float, float]

Returns

Tuple of two items (‘th_lb’, ‘th_ub’). The elements are the following:

  • th_lb : Beam’s lower bound [um].

  • th_ub : Beam’s upper bound [um].

contents()#

Return a list of the attributes stored in the container that are initialised.

Return type

List[str]

Returns

List of the attributes stored in the container.

get(attr, value=None)#

Retrieve a dataset, return value if the attribute is not found.

Parameters
  • attr (str) – Data attribute.

  • value (Optional[Any]) – Data which is returned if the attribute is not found.

Return type

Any

Returns

Attribute’s data stored in the container, value if attr is not found.

classmethod import_default()#

Return the default STParams. Extra arguments override the default values if provided.

Return type

STParams

Returns

An STParams object with the default parameters.

classmethod import_ini(ini_file)#

Initialize the container object with an INI file ini_file.

Parameters

ini_file (str) – Path to the ini file.

Return type

~I

Returns

A new container with all the attributes imported from the ini file.

items()#

Return (key, value) pairs of the datasets stored in the container.

Return type

ItemsView

Returns

(key, value) pairs of the datasets stored in the container.

keys()#

Return a list of the attributes available in the container.

Return type

List[str]

Returns

List of the attributes available in the container.

lens_x_wavefront(n_x=None, return_step=False)#

Return wavefields at the lens plane along x axis.

Parameters
Return type

Tuple[ndarray, float]

Returns

A tuple of two elements (‘u0_x’, ‘dx’). The elements are the following:

  • u0_x : Wavefront along the x axis.

  • dx : Step size along the x axis [um]. Only if return_step is True.

Notes

The exit-surface at the lens plane:

\[U_0(x) = \Pi(a_x x) \exp \left[ -\frac{j \pi x^2}{\lambda f} + j \alpha \left( \frac{x - x_{ab_cnt}}{f} \right)^3 \right]\]
lens_y_wavefront(n_y=None, return_step=False)#

Return wavefields at the lens plane along y axis.

Parameters
Return type

Tuple[ndarray, float]

Returns

A tuple of two elements (‘u0_y’, ‘dy’). The elements are the following:

  • u0_y : Wavefront along the y axis.

  • dy : Step size along the y axis [um]. Only if return_step is True.

Notes

The exit-surface at the lens plane:

\[U_0(y) = \Pi(a_y y)\]
replace(**kwargs)#

Return a new container object with a set of attributes replaced.

Parameters

kwargs (Any) – A set of attributes and the values to to replace.

Return type

~D

Returns

A new container object with updated attributes.

sample_positions()#

Generate an array of sample’s translations with random deviation.

Return type

ndarray

Returns

Array of sample translations [um].

source_curve(dist, step)#

Return source’s rocking curve profile at dist distance from the lens.

Parameters
  • dist (float) – Distance from the lens to the rocking curve profile [um].

  • step (float) – Sampling interval [um].

Return type

ndarray

Returns

Source’s rocking curve profile.

static str_to_list(strings)#

Convert strings to a list of strings.

Parameters

strings (Union[str, List[str]]) – String or a list of strings

Return type

List[str]

Returns

List of strings.

to_ini(ini_file)#

Save all the attributes stored in the container to an INI file ini_file.

Parameters

ini_file (str) – Path to the ini file.

update_seed(seed=None)#

Update seed used in pseudo-random number generation.

Parameters

seed (Optional[int]) – New seed value. Chosen randomly if None.

update_threads(num_threads=None)#

Update number of threads used in calculcations.

Parameters

num_threads (Optional[int]) – Number of threads used in the computations.

values()#

Return the attributes’ data stored in the container.

Return type

ValuesView

Returns

List of data stored in the container.

x_wavefront_size()#

Return wavefront array size along the x axis, that satisfies the sampling condition.

Return type

int

Returns

Array size.

Notes

The sampling condition when we propagate the wavefield from the lens plane to the sample plane is as follows:

\[N_x >= \frac{\mathrm{max} \left( \Delta x_{lens}, \Delta x_{sample} \right) (\Delta x_{lens} + \Delta x_{sample})}{\lambda d} = \frac{4 a_x^2 \mathrm{max} \left( f, df \right)}{f^2 \lambda}\]

Whereupon, the sampling condition when we propagate the wavefield to the detector plane is:

\[N_x >= \frac{\Delta x_{sample} \Delta x_{det}}{\lambda d} = \frac{2 a_x n_{x} \Delta_{pix} df}{f \lambda d_{det}}\]
y_wavefront_size()#

Return wavefront array size along the y axis, that satisfies the sampling condition.

Return type

int

Returns

Array size.

Notes

The sampling condition when we propagate the wavefield from the lens plane to the sample plane is as follows:

\[N_y >= \frac{\mathrm{max} \left( \Delta y_{lens}, \Delta y_{sample} \right) (\Delta y_{lens} + \Delta y_{sample})}{\lambda d} = \frac{8 a_y^2}{(f + df) \lambda}\]

Whereupon, the sampling condition when we propagate the wavefield to the detector plane is:

\[N_y >= \frac{\Delta y_{sample} \Delta y_{det}}{\lambda d} = \frac{2 a_y n_{y} \Delta_{pix}}{\lambda d_{det}}\]