smmcalibration¶
Standard usage of tweezepy involves instantiating one of the main user-facing classes, AV and PSD.
-
class
tweezepy.smmcalibration.AV(trace, fsample, taus='octave', mode='oavar', edf='real')¶ A class for computing and fitting the Allan variance using maximum likelihood estimation.
- Parameters
trace (array) – Bead trajectory in nm.
fsample (float) – Sampling frequency in Hz.
taus (str, optional) – Tau interval sampling. Options are ‘octave’, ‘decade’, and ‘all’, by default ‘octave’
mode (str, optional) – Allan variance type, either ‘avar’, ‘oavar’, and ‘totvar’, by default ‘oavar’. See allanvar module for more information.
edf (str, optional) – Equivalent degrees of freedom for AV. Options are ‘real’ and ‘approx’, by default ‘real’
- Raises
AssertionError – If taus, mode, or edf is not recognized.
Examples
>>> from tweezepy import load_trajectory, AV >>> trace = load_trajectory() # Load trajectory in nm >>> av = AV(trace, fsample = 400) # Compute overlapping AV >>> av.mlefit() # Perform MLE fit >>> print(av.results)
-
class
tweezepy.smmcalibration.PSD(trace, fsample, bins=3)¶ A class for computing and fitting the power spectral density using maximum likelihood estimation.
- Parameters
trace (array) – Bead positions in nm.
fsample (float) – Sampling frequency in Hz
bins (int, optional) – Number of bins, by default 3
Example
>>> from tweezepy import load_trajectory, PSD >>> trace = load_trajectory() # Load trajectory in nm >>> psd = PSD(trace, fsample = 400) # Compute PSD using Welch's method >>> psd.mlefit() # Perform MLE fit >>> print(psd.results)
The AV and PSD classes use the base class calibration.
-
class
tweezepy.smmcalibration.calibration(trace, fsample)¶ Base class for PSD and AV calibration.
- Parameters
trace (array) – 1-D array of bead positions in nm
fsample (float) – Sampling frequency in Hz
-
trace¶ 1-D array of bead positions in nm
- Type
array
-
fsample¶ Sampling frequency in Hz
- Type
float
-
property
data¶ Returns dictionary of data.
- Returns
Dictionary of data.
- Return type
dict
-
mlefit(fitfunc=None, cutoffs=[- inf, inf], tracking_error=False, guess=None, gamma=None, kappa=None, epsilon=None, kT=4.1, viscosity=8.94e-10, radius=530.0, pedantic=True, scale_covar=False, minimizer_kwargs={})¶ Estimate parameters and uncertainties via maximum likelihood estimation.
- Parameters
fitfunc (str or function, optional) – String or user defined function, by default ‘lansdorpPSD’ for PSD and ‘SMMAV’ for AV
tracking_error (bool, optional) – Incorporate tracking errors, by default False
guess (list, optional) – Initial parameter guesses, by default None
gamma (float, optional) – Fixed value for gamma parameter, by default None
kappa (float, optional) – Fixed value for kappa parameter, by default None
epsilon (float, optional) – Fixed value for epsilon parameter, by default None
pedantic (bool, optional) – Ignore unhelpful warning messages, by default True
kT (float, optional) – Thermal energy in pN nm, by default 4.1
viscosity (float, optional) – Dynamic viscosity for initial parameter guesses in pN s/nm^2, by default 8.94e-10
radius (float, optional) – Bead radius for inital parameter guesses in nm, by default 530.
minimizer_kwargs (dict, optional) – Keyword arguments to send to scipy.optimize.minimize.
-
plot(fig=None, fig_kwgs={}, ax_fit_kwgs={}, ax_res_kwgs={}, data_label=None, fit_label=None, data_color=None, fit_color='k')¶ Utility function for plotting.
- Parameters
fig (Figure, optional) – Matplotlibe Figure object, by default None
fig_kwgs (dict, optional) – Figure keyword arguments, by default {}
ax_fit_kwgs (dict, optional) – Axis keyword arguments, by default {}
ax_res_kwgs (dict, optional) – Axis keyword arguments, by default {}
data_label (str, optional) – Legend label for data.
fit_label (str, optional) – Legend label for fit line.
- Returns
fig, ax – Figure and axes objects.
- Return type
Figure, Axes