当前位置: 首页>>代码示例>>Python>>正文


Python Fitting.set_param方法代码示例

本文整理汇总了Python中gumpy.nexus.fitting.Fitting.set_param方法的典型用法代码示例。如果您正苦于以下问题:Python Fitting.set_param方法的具体用法?Python Fitting.set_param怎么用?Python Fitting.set_param使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gumpy.nexus.fitting.Fitting的用法示例。


在下文中一共展示了Fitting.set_param方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fit_curve

# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import set_param [as 别名]
def fit_curve():
    global Plot1
    ds = Plot1.ds
    if len(ds) == 0:
        log('Error: no curve to fit in Plot1.\n')
        return
    for d in ds:
        if d.title == 'fitting':
            Plot1.remove_dataset(d)
    d0 = ds[0]
    fitting = Fitting(GAUSSIAN_FITTING)
    try:
        fitting.set_histogram(d0, fit_min.value, fit_max.value)
        val = peak_pos.value
        if val == val:
            fitting.set_param('mean', val)
        val = FWHM.value
        if val == val:
            fitting.set_param('sigma', math.fabs(val / 2.35482))
        res = fitting.fit()
        res.var[:] = 0
        res.title = 'fitting'
        Plot1.add_dataset(res)
        mean = fitting.params['mean']
        mean_err = fitting.errors['mean']
        FWHM.value = 2.35482 * math.fabs(fitting.params['sigma'])
        FWHM_err = 5.54518 * math.fabs(fitting.errors['sigma'])
        log('POS_OF_PEAK=' + str(mean) + ' +/- ' + str(mean_err))
        log('FWHM=' + str(FWHM.value) + ' +/- ' + str(FWHM_err))
        log('Chi2 = ' + str(fitting.fitter.getQuality()))
        peak_pos.value = fitting.mean
#        print fitting.params
    except:
#        traceback.print_exc(file = sys.stdout)
        log('can not fit\n')
开发者ID:Gumtree,项目名称:gumtree,代码行数:37,代码来源:Taipan_Data_Viewer.py

示例2: fit_curve

# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import set_param [as 别名]
def fit_curve(min = None, max = None):
    global Plot1
    ds = Plot1.ds
    if ds is None or len(ds) == 0:
        print 'Error: no curve to fit in Plot1.'
        return
    for d in ds:
        if d.title == 'fitting':
            Plot1.remove_dataset(d)
    d0 = ds[0]
    fitting = Fitting(GAUSSIAN_FITTING)
    fitting.set_histogram(d0, min, max)
    val = peak_pos.value
    if val == val:
        fitting.set_param('mean', val)
    try:
        res = fitting.fit()
        res.var[:] = 0
        res.title = 'fitting'
        Plot1.add_dataset(res)
        mean = fitting.params['mean']
        slog('POS_OF_PEAK=' + str(mean))
        slog('FWHM=' + str(2.35482 * math.fabs(fitting.params['sigma'])))
        peak_pos.value = fitting.mean
    except:
        print 'failed to fit with Gaussian curve.'
        return
开发者ID:Gumtree,项目名称:Taipan_scripts,代码行数:29,代码来源:5_calibrate_s2.py

示例3: linear_fit

# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import set_param [as 别名]
def linear_fit():
    global Plot2
    valid = []
    vaxes = []
    for i in xrange(peak_res.size):
        if not Double.isNaN(peak_res[i]):
            valid.append(peak_res[i] * -1)
            vaxes.append(h2k2l2[i])
    if len(valid) == 0:
        slog('Error: there is no available peak.')
        return
    ds2 = Dataset(valid, axes=[vaxes])
    Plot2.set_dataset(ds2)
    ds = Plot2.ds
    if ds is None or len(ds) == 0:
        print 'Error: no curve to fit in Plot2'
        return
    for d in ds:
        if d.title == 'linear_fitting':
            Plot2.remove_dataset(d)
    d0 = ds[0]
    fitting = Fitting(LINEAR_FITTING)
    fitting.set_histogram(d0)
    if linear_slope.value == 0:
        fitting.set_param('a', 1)
    else:
        fitting.set_param('a', linear_slope.value)
    res = fitting.fit()
    res.var[:] = 0
    res.title = 'linear_fitting'
    Plot2.add_dataset(res)
    linear_slope.value = fitting.a
    print fitting.params
开发者ID:Gumtree,项目名称:Taipan_scripts,代码行数:35,代码来源:6_fit_nonlinear.py

示例4: plot2_fit_curve

# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import set_param [as 别名]
def plot2_fit_curve():
    global Plot2
    ds = Plot2.ds
    if len(ds) == 0:
        log("Error: no curve to fit in Plot2.\n")
        return
    for d in ds:
        if d.title == "fitting":
            Plot2.remove_dataset(d)
    if len(ds) == 1:
        sds = ds[0]
    else:
        sds = Plot2.get_selected_dataset()
        if sds is None:
            open_error(
                "Please select a curve to fit. Right click on the plot to focus on a curve. Or use CTRL + Mouse Click on a curve to select one."
            )
            return
    fitting = Fitting(GAUSSIAN_FITTING)
    try:
        fitting.set_histogram(sds, plot2_fit_min.value, plot2_fit_max.value)
        val = plot2_peak_pos.value
        if val == val:
            fitting.set_param("mean", val)
        val = plot2_FWHM.value
        if val == val:
            fitting.set_param("sigma", math.fabs(val / 2.35482))
        res = fitting.fit()
        res.var[:] = 0
        res.title = "fitting"
        Plot2.add_dataset(res)
        mean = fitting.params["mean"]
        log("POS_OF_PEAK=" + str(mean))
        log("FWHM=" + str(2.35482 * math.fabs(fitting.params["sigma"])))
        log("Chi2 = " + str(fitting.fitter.getQuality()))
        plot2_peak_pos.value = fitting.mean
        plot2_FWHM.value = 2.35482 * math.fabs(fitting.params["sigma"])
    #        print fitting.params
    except:
        #        traceback.print_exc(file = sys.stdout)
        log("can not fit\n")
开发者ID:Gumtree,项目名称:Kowari_scripts,代码行数:43,代码来源:dataBrowser.py

示例5: plot2_fit_curve

# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import set_param [as 别名]
def plot2_fit_curve():
    global Plot2
    ds = Plot2.ds
    if len(ds) == 0:
        log('Error: no curve to fit in Plot2.\n')
        return
    for d in ds:
        if d.title == 'fitting':
            Plot2.remove_dataset(d)
    if len(ds) == 1:
        sds = ds[0]
    else:
        sds = Plot2.get_selected_dataset()
        if sds is None :
            open_error('Please select a curve to fit. Right click on the plot to focus on a curve. Or use CTRL + Mouse Click on a curve to select one.')
            return
    fitting = Fitting(GAUSSIAN_FITTING)
    try:
        fitting.set_histogram(sds, plot2_fit_min.value, plot2_fit_max.value)
        val = plot2_peak_pos.value
        if val == val:
            fitting.set_param('mean', val)
        val = plot2_FWHM.value
        if val == val:
            fitting.set_param('sigma', math.fabs(val / 2.35482))
        res = fitting.fit()
        res.var[:] = 0
        res.title = 'fitting'
        Plot2.add_dataset(res)
        Plot2.pv.getPlot().setCurveMarkerVisible(Plot2.__get_NXseries__(res), False)
        mean = fitting.params['mean']
        log('POS_OF_PEAK=' + str(mean))
        log('FWHM=' + str(2.35482 * math.fabs(fitting.params['sigma'])))
        log('Chi2 = ' + str(fitting.fitter.getQuality()))
        plot2_peak_pos.value = fitting.mean
        plot2_FWHM.value = 2.35482 * math.fabs(fitting.params['sigma'])
#        print fitting.params
    except:
#        traceback.print_exc(file = sys.stdout)
        log('can not fit\n')
开发者ID:Gumtree,项目名称:Quokka_scripts,代码行数:42,代码来源:alignment.py

示例6: linear_fit

# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import set_param [as 别名]
def linear_fit():
    global Plot2
    ds2 = Dataset(peaks * -1, axes=[hkl])
    Plot2.set_dataset(ds2)
    ds = Plot2.ds
    if ds is None or len(ds) == 0:
        slog('Error: no curve to fit in Plot2')
        return
    for d in ds:
        if d.title == 'linear_fitting':
            Plot2.remove_dataset(d)
    d0 = ds[0]
    fitting = Fitting(LINEAR_FITTING)
    fitting.set_histogram(d0)
    if linear_slope.value == 0:
        fitting.set_param('a', 1)
    else:
        fitting.set_param('a', linear_slope.value)
    res = fitting.fit()
    res.var[:] = 0
    res.title = 'linear_fitting'
    Plot2.add_dataset(res)
    linear_slope.value = fitting.a
    slog(str(fitting.params))
开发者ID:Gumtree,项目名称:Taipan_scripts,代码行数:26,代码来源:auto_6_fit_nonlinear.py


注:本文中的gumpy.nexus.fitting.Fitting.set_param方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。