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_min
andk_max
(optional, defaults are None)float
parameters. It returns the average value of the data (calculated using all points over thetau
axis) in the range[k_min, k_max]
.“power_spec”: takes
k_min
andk_max
(optional, defaults are None)float
parameters. It returns the average value of thedata.power_spec
field in the range[k_min, k_max]
.“var”: takes
k_min
andk_max
(optional, defaults are None)float
parameters. It returns the average value of thedata.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 firstnum_points
points.
In the case of
ImageStructureFunction
input:if
k_min
is None, the maximum betweendata.kx
anddata.ky
is taken.if
k_max
is None, the maximum betweendata.kx
anddata.ky
is taken.
In the case of
AzimuthalAverage
input:if
k_min
is None, the maximumdata.k
is taken.if
k_max
is None, the maximumdata.k
is taken.
If
k_min > k_max
, the two values are swapped and aWarning
is raised.In the case of
ImageStructureFunction
input, a booleanmask
can be optionally provided for the modes["min", "high_q", "power_spec", "var"]
. Thismask
is used to exclude grid points from the noise evaluation (where False is set). Themask
array must have the same(y, x)
shape ofdata
. Ifmask
is not of boolean type, it is cast tobool
and aWarning
is raised.- Parameters:
obj (Union[ImageStructureFunction, AzimuthalAverage]) –
ImageStructureFunction
orAzimuthalAverage
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:
TypeError – Input type not supported.
RuntimeError – Mode not supported