我真的不知道你在做什么或试图做什么,但我会这样做(假设西格玛和伽马对所有峰值都是相同的)。如果这在法布里·珀罗身上说得通的话,我想得不多)import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import leastsq
def cauchy(x, x0, g):
return 1. / ( np.pi * g * ( 1 + ( ( x - x0 )/ g )**2 ) )
def gauss( x, x0, s):
return 1./ np.sqrt(2 * np.pi * s**2 ) * np.exp( - (x-x0)**2 / ( 2 * s**2 ) )
def pseudo_voigt( x, x0, s, g, a ):
fg = 2 * s * np.sqrt( 2 * np.log(2) )
fl = 2 * g
f = ( fg**5 + 2.69269 * fg**4 * fl + 2.42843 * fg**3 * fl**2 + 4.47163 * fg**2 * fl**3 + 0.07842 * fg * fl**4+ fl**5)**(1./5.)
eta = 1.36603 * ( fl / f ) - 0.47719 * ( fl / f )**2 + 0.11116 * ( f / fl )**3
return a * ( eta * cauchy( x, x0, f) + ( 1 - eta ) * gauss( x, x0, f ) )
def all_peaks(x, mus, amps, s, g ):
out = 0
for m, a in zip( mus, a