本文整理汇总了Python中gumpy.nexus.fitting.Fitting.fit方法的典型用法代码示例。如果您正苦于以下问题:Python Fitting.fit方法的具体用法?Python Fitting.fit怎么用?Python Fitting.fit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gumpy.nexus.fitting.Fitting
的用法示例。
在下文中一共展示了Fitting.fit方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: linear_fit
# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import fit [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
示例2: fit_curve
# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import fit [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')
示例3: fit_curve
# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import fit [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
示例4: fit_curve
# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import fit [as 别名]
def fit_curve():
global Plot1
ds = Plot1.ds
if 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)
try:
fitting.set_histogram(d0)
res = fitting.fit()
res.var[:] = 0
res.title = 'fitting'
Plot1.add_dataset(res)
mean = fitting.params['mean']
mean_err = fitting.error['mean']
print 'POS_OF_PEAK=' + str(mean) + '+/-' + str(mean_err)
print 'FWHM=' + str(2.35482 * math.fabs(fitting.params['sigma'])) \
+ '+/-' + str(5.54518 * fitting.error['sigma'])
print 'Chi2=' + str(fitting.fitter.getQuality())
peak_pos.value = fitting.mean
except:
print 'can not fit'
示例5: __std_fit_curve__
# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import fit [as 别名]
def __std_fit_curve__():
global Plot1
ds = Plot1.ds
if ds is None or len(ds) == 0:
slog('Error: no curve to fit in Plot1.')
return
for d in ds:
if d.title == 'fitting':
Plot1.remove_dataset(d)
d0 = ds[0]
try:
fitting = Fitting(GAUSSIAN_FITTING)
fitting.set_histogram(d0)
res = fitting.fit()
res.var[:] = 0
res.title = 'fitting'
Plot1.add_dataset(res)
slog(str(fitting.params))
mean = fitting.mean
slog('POS_OF_PEAK=' + str(mean))
slog('FWHM=' + str(2.35482 * math.fabs(fitting.params['sigma'])))
peak_pos.value = mean
except:
slog('failed to fit with Gaussian curve.')
traceback.print_exc(file = sys.stdout)
return
示例6: linear_fit
# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import fit [as 别名]
def linear_fit():
global Plot2
ds = Plot2.ds
if len(ds) == 0:
print 'Error: no curve to fit in Plot2'
return
for d in ds:
if d.title == 'fitting':
Plot2.remove_dataset(d)
d0 = ds[0]
fitting = Fitting(LINEAR_FITTING)
fitting.set_histogram(d0)
res = fitting.fit()
res.var[:] = 0
res.title = 'fitting'
Plot2.add_dataset(res)
print fitting.params
示例7: fit_curve
# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import fit [as 别名]
def fit_curve():
global Plot1
ds = Plot1.ds
if ds is None or len(ds) == 0:
slog('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)
res = fitting.fit()
res.var[:] = 0
res.title = 'fitting'
Plot1.add_dataset(res)
slog(fitting.params)
peak_pos.value = fitting.mean
示例8: fit_curve
# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import fit [as 别名]
def fit_curve():
global Plot1
ds = Plot1.ds
if 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, fit_min.value, fit_max.value)
res = fitting.fit()
res.var[:] = 0
res.title = 'fitting'
Plot1.add_dataset(res)
print fitting.params
peak_pos.value = fitting.mean
示例9: plot2_fit_curve
# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import fit [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")
示例10: plot2_fit_curve
# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import fit [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')
示例11: fit_curve
# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import fit [as 别名]
def fit_curve():
global Plot1
ds = Plot1.ds
if len(ds) == 0:
log('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)
try:
fitting.set_histogram(d0, fit_min.value, fit_max.value)
res = fitting.fit()
res.var[:] = 0
res.title = 'fitting'
Plot1.add_dataset(res)
mean = fitting.params['mean']
log('POS_OF_PEAK=' + str(mean))
log('FWHM=' + str(2.35482 * math.fabs(fitting.params['sigma'])))
peak_pos.value = fitting.mean
except:
log('can not fit')
示例12: linear_fit
# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import fit [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))
示例13: fit_2nd_peak
# 需要导入模块: from gumpy.nexus.fitting import Fitting [as 别名]
# 或者: from gumpy.nexus.fitting.Fitting import fit [as 别名]
def fit_2nd_peak(min, max):
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_2':
Plot1.remove_dataset(d)
d0 = ds[0]
try:
fitting = Fitting(GAUSSIAN_FITTING)
fitting.set_histogram(d0, min, max)
res = fitting.fit()
res.var[:] = 0
res.title = 'fitting_2'
Plot1.add_dataset(res)
mean = fitting.params['mean']
slog('POS_OF_2ND_PEAK=' + str(mean))
slog('FWHM_OF_2ND_PEAK=' + str(2.35482 * math.fabs(fitting.params['sigma'])))
except:
traceback.print_exc(file = sys.stdout)
print 'failed to fit the 2nd peak.'
return