fit_logic_standalone.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:qudi 作者: Ulm-IQO 项目源码 文件源码
def gaussian_twoD_testing():
    """ Implement and check the estimator for a 2D gaussian fit. """

    data = np.empty((121,1))
    amplitude=np.random.normal(3e5,1e5)
    center_x=91+np.random.normal(0,0.8)
    center_y=14+np.random.normal(0,0.8)
    sigma_x=np.random.normal(0.7,0.2)
    sigma_y=np.random.normal(0.7,0.2)
    offset=0
    x = np.linspace(90,92,11)
    y = np.linspace(13,15,12)
    xx, yy = np.meshgrid(x, y)

    axes=(xx.flatten(), yy.flatten())

    theta_here=10./360.*(2*np.pi)

#            data=qudi_fitting.twoD_gaussian_function((xx,yy),*(amplitude,center_x,center_y,sigma_x,sigma_y,theta_here,offset))
    gmod,params = qudi_fitting.make_twoDgaussian_model()

    data = gmod.eval(x=axes, amplitude=amplitude, center_x=center_x,
                     center_y=center_y, sigma_x=sigma_x, sigma_y=sigma_y,
                     theta=theta_here, offset=offset)
    data += 50000*np.random.random_sample(np.shape(data))

    gmod, params = qudi_fitting.make_twoDgaussian_model()

    para=Parameters()
#    para.add('theta',vary=False)
#    para.add('center_x',expr='0.5*center_y')
#    para.add('sigma_x',min=0.2*((92.-90.)/11.), max=   10*(x[-1]-y[0]) )
#    para.add('sigma_y',min=0.2*((15.-13.)/12.), max=   10*(y[-1]-y[0]))
#    para.add('center_x',value=40,min=50,max=100)

    result = qudi_fitting.make_twoDgaussian_fit(xy_axes=axes, data=data)#,add_parameters=para)

#
#            FIXME: What does "Tolerance seems to be too small." mean in message?
#            print(result.message)
    plt.close('all')

    fig, ax = plt.subplots(1, 1)
    ax.hold(True)
    ax.imshow(result.data.reshape(len(y),len(x)),
              cmap=plt.cm.jet, origin='bottom', extent=(x.min(), x.max(),
                                       y.min(), y.max()),interpolation="nearest")
    ax.contour(x, y, result.best_fit.reshape(len(y),len(x)), 8
                , colors='w')
    plt.show()
#    plt.close('all')

    print(result.fit_report())

#            print('Message:',result.message)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号