def double_poissonian_testing():
""" Testing of double poissonian with self created data.
First version of double poissonian fit."""
start=100
stop=300
num_points=int((stop-start)+1)*100
x = np.linspace(start, stop, num_points)
# double poissonian
mod,params = qudi_fitting.make_multiplepoissonian_model(no_of_functions=2)
print('Parameters of the model',mod.param_names)
parameter=Parameters()
parameter.add('p0_mu',value=200)
parameter.add('p1_mu',value=240)
parameter.add('p0_amplitude',value=1)
parameter.add('p1_amplitude',value=1)
data_noisy = ( np.array(mod.eval(x=x,params=parameter)) *
np.array((1+0.2*np.random.normal(size=x.shape) )*
parameter['p1_amplitude'].value) )
#make the filter an extra function shared and usable for other functions
gaus=gaussian(10,10)
data_smooth = filters.convolve1d(data_noisy, gaus/gaus.sum(),mode='mirror')
result = qudi_fitting.make_doublepoissonian_fit(x, data_noisy)
print(result.fit_report())
plt.figure()
plt.plot(x, data_noisy, '-b', label='noisy data')
plt.plot(x, data_smooth, '-g', label='smoothed data')
plt.plot(x,result.init_fit,'-y', label='initial values')
plt.plot(x,result.best_fit,'-r',linewidth=2.0, label='fit')
plt.xlabel('counts')
plt.ylabel('occurences')
plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3,
ncol=2, mode="expand", borderaxespad=0.)
plt.show()
评论列表
文章目录