mooonpy.fitting.dihedral module

Dihedral angle distribution analysis and fitting tools Cite PBZ paper by Tristan Muzzy

class mooonpy.fitting.dihedral.DihedralDist(phi_angles, bin_scale=10, name=None, function=<function multi_symmetric_gaussian>, ic=None, limits=None, density=False)[source]

Bases: CurveFit

Fit and analyze the dihedral angle distributions with histograms and probability density functions. using fit_model curve fits histogram bins using fit_mle uses MLE (recommended/default)

Parameters:
  • x – 1D array

  • y – 1D array

  • name – str

  • model – lmfit.models.Model (or None)

default_fit_kws = {'max_nfev': 5000, 'method': 'powell'}
default_limits = {'mu': (0, 180), 'sigma': (5, 90)}
fit_mle()[source]

Fit using Maximum Likelihood Estimation on raw angle data Returns fitted parameters in the same format as fit_model() Note: lmfit.minimize doesn’t support expr constraints, so we normalize in post-processing

guess_ic(guess=None)[source]

Basic guessing function. could make smart with peak detection or BIC but this is good enough for now Guess may be int 1-3 for number of peaks to use a default, or a dict of custom ICs

guess_limit()[source]

Add parameter limits. May be overridden outside

make_params()[source]

Override base class make_params function with extra amplitude constraint Initial area under the curve and sum of amplitudes=1 is preserved Note: this is only relevant for fitting histograms, MLE constrains using scaling.

plot_mode_decomposition(ax=None, figsize=(10, 6))[source]

Make pretty plots

run_default()[source]

Override to use MLE by default for DihedralDist

mooonpy.fitting.dihedral.multi_symmetric_gaussian(x, **params)[source]

Sum of multiple symmetric Gaussian’s with periodicity

mooonpy.fitting.dihedral.multi_symmetric_von_mises(x, **params)[source]

Sum of multiple symmetric von Mises

mooonpy.fitting.dihedral.symmetric_gaussian_periodic(x, center, sigma, amplitude, rad=False)[source]

Symmetric Gaussian with proper periodicity handling. Creates Gaussian’s at ±center and their first periodic images for bleed-through. https://en.wikipedia.org/wiki/Wrapped_normal_distribution

mooonpy.fitting.dihedral.symmetric_von_mises(x, center, sigma, amplitude=1.0, rad=False)[source]

Periodic von Mises fit, from -pi to pi or -180 to 180 Symmetry of dihedral angle PDF is enforced

Note under ~2.3 deg sigma uses gaussain to prevent float overflow