noise_est#

This module contains the helper function to estimate the noise factor.

The methods implemented here are some of the most widely used in the literature and are implemented for both ÌmageStructureFunction` and AzimuthalAverage objects. For ImageStructureFunction objects, a mask as the one used to compute the AzimuthalAverage can be given in order to mask-out points from the noise estimate.

Mode

ImageStructureFunction

AzimuthalAverage

“zero”

\(0\)

\(0\)

“min”

\(\min\left\{ D(\vec{q}, \Delta t_{\mathrm{min}}) \right\}\)

\(\min\left\{ D(q, \Delta t_{\mathrm{min}}) \right\}\)

“high_q”

\(\langle D(\vec{q}, \Delta t) \rangle_{\Delta t, \lvert \vec{q} \rvert \in [q_{\mathrm{min}}, q_{\mathrm{max}}]}\)

\(\langle D(q, \Delta t) \rangle_{\Delta t, q \in [q_{\mathrm{min}}, q_{\mathrm{max}}]}\)

“power_spec”

\(\langle \mathrm{PS}(\vec{q}) \rangle_{\lvert \vec{q} \rvert \in [q_{\mathrm{min}}, q_{\mathrm{max}}]}\)

\(\langle \mathrm{PS}(q) \rangle_{q \in [q_{\mathrm{min}}, q_{\mathrm{max}}]}\)

“var”

\(\langle \mathrm{VAR}(\vec{q}) \rangle_{\lvert \vec{q} \rvert \in [q_{\mathrm{min}}, q_{\mathrm{max}}]}\)

\(\langle \mathrm{VAR}(q) \rangle_{q \in [q_{\mathrm{min}}, q_{\mathrm{max}}]}\)

“polyfit”

0th degree coefficient of quadratic fit over \(\Delta t\) of first num_points of \(D(\vec{q}, \Delta t)\)

0th degree coefficient of quadratic fit over \(\Delta t\) of first num_points of \(D(q, \Delta t)\)

where:

  • \(D(\vec{q}, \Delta t)\) is the image structure function

  • \(\mathrm{PS}(\vec{q})\) is the average power spectrum of the images

  • \(\mathrm{VAR}({\vec{q}})\) is the average power spectrum of the background-corrected images, which is just the variance in time of the Fourier transformed images.

The symbols with scalar \(q\) indicate the azimuthal average of the same quantities.

fastddm.noise_est.estimate_camera_noise(obj: ImageStructureFunction | AzimuthalAverage, mode: str = 'zero', **kwargs) Tuple[ndarray, ndarray]#

Estimate of noise factor in ImageStructureFunction or AzimuthalAverage.

Possible modes are:

  • “zero”: zero at all wavevectors.

  • “min”: minimum value at minimum lag time.

  • “high_q”: takes k_min and k_max (optional, defaults are None) float parameters. It returns the average value of the data (calculated using all points over the tau axis) in the range [k_min, k_max].

  • “power_spec”: takes k_min and k_max (optional, defaults are None) float parameters. It returns the average value of the data.power_spec field in the range [k_min, k_max].

  • “var”: takes k_min and k_max (optional, defaults are None) float parameters. It returns the average value of the data.var field in the range [k_min, k_max].

  • “polyfit”: takes num_points (optional, default is 5) int parameter. For each wavevector, it returns the constant term of a quadratic polynomial fit of the first num_points points.

In the case of ImageStructureFunction input:

  • if k_min is None, the maximum between data.kx and data.ky is taken.

  • if k_max is None, the maximum between data.kx and data.ky is taken.

In the case of AzimuthalAverage input:

  • if k_min is None, the maximum data.k is taken.

  • if k_max is None, the maximum data.k is taken.

If k_min > k_max, the two values are swapped and a Warning is raised.

In the case of ImageStructureFunction input, a boolean mask can be optionally provided for the modes ["min", "high_q", "power_spec", "var"]. This mask is used to exclude grid points from the noise evaluation (where False is set). The mask array must have the same (y, x) shape of data. If mask is not of boolean type, it is cast to bool and a Warning is raised.

Parameters:
  • obj (Union[ImageStructureFunction, AzimuthalAverage]) – ImageStructureFunction or AzimuthalAverage object.

  • mode (str, optional) – Estimate mode. Possible values are: “zero”, “min”, “high_q”, “power_spec”, “var”, and “polyfit”. Default is “zero”.

Returns:

Estimated noise factor and uncertainty.

Return type:

Tuple[numpy.ndarray, numpy.ndarray]

Raises: