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 |
|
|
|---|---|---|
“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 |
0th degree coefficient of quadratic fit over
\(\Delta t\) of first |
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_minandk_max(optional, defaults are None)floatparameters. It returns the average value of the data (calculated using all points over thetauaxis) in the range[k_min, k_max].“power_spec”: takes
k_minandk_max(optional, defaults are None)floatparameters. It returns the average value of thedata.power_specfield in the range[k_min, k_max].“var”: takes
k_minandk_max(optional, defaults are None)floatparameters. It returns the average value of thedata.varfield in the range[k_min, k_max].“polyfit”: takes
num_points(optional, default is 5)intparameter. For each wavevector, it returns the constant term of a quadratic polynomial fit of the firstnum_pointspoints.
In the case of
ImageStructureFunctioninput:if
k_minis None, the maximum betweendata.kxanddata.kyis taken.if
k_maxis None, the maximum betweendata.kxanddata.kyis taken.
In the case of
AzimuthalAverageinput:if
k_minis None, the maximumdata.kis taken.if
k_maxis None, the maximumdata.kis taken.
If
k_min > k_max, the two values are swapped and aWarningis raised.In the case of
ImageStructureFunctioninput, a booleanmaskcan be optionally provided for the modes["min", "high_q", "power_spec", "var"]. Thismaskis used to exclude grid points from the noise evaluation (where False is set). Themaskarray must have the same(y, x)shape ofdata. Ifmaskis not of boolean type, it is cast tobooland aWarningis raised.- Parameters:
obj (Union[ImageStructureFunction, AzimuthalAverage]) –
ImageStructureFunctionorAzimuthalAverageobject.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:
TypeError – Input type not supported.
RuntimeError – Mode not supported