本文整理汇总了Python中diffpy.srfit.fitbase.FitResults.printResults方法的典型用法代码示例。如果您正苦于以下问题:Python FitResults.printResults方法的具体用法?Python FitResults.printResults怎么用?Python FitResults.printResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类diffpy.srfit.fitbase.FitResults
的用法示例。
在下文中一共展示了FitResults.printResults方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from diffpy.srfit.fitbase import FitResults [as 别名]
# 或者: from diffpy.srfit.fitbase.FitResults import printResults [as 别名]
def main():
# Make the data and the recipe
strufile = "data/C60.stru"
q = numpy.arange(1, 20, 0.05)
makeData(strufile, q, "C60.iq", 1.0, 100.68, 0.005, 0.13, 2)
# Make the recipe
recipe = makeRecipe(strufile, "C60.iq")
# Optimize
scipyOptimize(recipe)
# Generate and print the FitResults
res = FitResults(recipe)
# We want to see how much speed-up we get from bringing the scale and
# background outside of the intensity generator. Get the number of calls
# to the residual function from the FitRecipe, and the number of calls to
# 'iofq' from the IntensityGenerator.
rescount = recipe.fithooks[0].count
calcount = recipe.bucky.I.count
footer = "iofq called %i%% of the time"%int(100.0*calcount/rescount)
res.printResults(footer = footer)
# Plot!
plotResults(recipe)
return
示例2: main
# 需要导入模块: from diffpy.srfit.fitbase import FitResults [as 别名]
# 或者: from diffpy.srfit.fitbase.FitResults import printResults [as 别名]
def main():
"""Refine the C60 molecule.
From previous examples we know that the radius of the model structure is
slightly too small. The annealing algorithm has to determine the proper
radius, and must also account for thermal vibrations in the PDF.
"""
molecule = makeC60()
recipe = makeRecipe(molecule, "data/C60.gr")
recipe.fithooks[0].verbose = 0
# Optimize
# Group related atomic positions for the optimizer
parlist = [getXYZNames(i) for i in xrange(60)]
groupAnneal(recipe, parlist)
# Print results
recipe.fix("all")
res = FitResults(recipe, showfixed = False)
res.printResults()
# Save the structure
molecule.write("C60_refined.stru", "pdffit")
# Plot results
plotResults(recipe)
return
示例3: main
# 需要导入模块: from diffpy.srfit.fitbase import FitResults [as 别名]
# 或者: from diffpy.srfit.fitbase.FitResults import printResults [as 别名]
def main():
"""Set up and refine the recipe."""
# Make the data and the recipe
cdsciffile = "data/CdS.cif"
znsciffile = "data/ZnS.cif"
data = "data/CdS_ZnS_nano.gr"
# Make the recipe
stru1 = loadCrystal(cdsciffile)
stru2 = loadCrystal(znsciffile)
recipe = makeRecipe(stru1, stru2, data)
from diffpy.srfit.fitbase.fithook import PlotFitHook
recipe.pushFitHook(PlotFitHook())
recipe.fithooks[0].verbose = 3
# Optimize - we do this in steps to help convergence
recipe.fix("all")
# Start with the lattice parameters. In makeRecipe, these were tagged with
# "lat". Here is how we use that.
recipe.free("lat")
leastsq(recipe.residual, recipe.values, maxfev = 50)
# Now the scale and phase fraction.
recipe.free("scale", "scale_CdS")
leastsq(recipe.residual, recipe.values, maxfev = 50)
# The ADPs.
recipe.free("adp")
leastsq(recipe.residual, recipe.values, maxfev = 100)
# The delta2 parameters.
recipe.free("delta2_cds", "delta2_zns")
leastsq(recipe.residual, recipe.values, maxfev = 50)
# The shape parameters.
recipe.free("radius", "thickness")
leastsq(recipe.residual, recipe.values, maxfev = 50)
# The positional parameters.
recipe.free("xyz")
leastsq(recipe.residual, recipe.values)
# Generate and print the FitResults
res = FitResults(recipe)
res.printResults()
# Plot!
plotResults(recipe)
return
示例4: gaussianfit
# 需要导入模块: from diffpy.srfit.fitbase import FitResults [as 别名]
# 或者: from diffpy.srfit.fitbase.FitResults import printResults [as 别名]
def gaussianfit(x, y, dy=None, A=1.0, sig=1.0, x0=0.0):
#def gaussianfit(arg):
'''main function to fit and plot gaussian curve
x, y, dy: gaussian date to be fitted
A, sig, x0: initial value
'''
#print type(arg)
dy = np.ones_like(x) if dy==None else dy
recipe = makeRecipe(x, y, dy, A, sig, x0)
scipyOptimize(recipe)
res = FitResults(recipe)
res.printResults()
plotResults(recipe)
return
示例5: main
# 需要导入模块: from diffpy.srfit.fitbase import FitResults [as 别名]
# 或者: from diffpy.srfit.fitbase.FitResults import printResults [as 别名]
def main():
# Create the recipe
recipe = makeRecipeII()
# Refine using the optimizer of your choice
scipyOptimize(recipe)
# Get the results in a FitResults object.
res = FitResults(recipe)
# Print the results
res.printResults()
# Plot the results
plotResults(recipe)
return
示例6: main
# 需要导入模块: from diffpy.srfit.fitbase import FitResults [as 别名]
# 或者: from diffpy.srfit.fitbase.FitResults import printResults [as 别名]
def main():
p = Profile()
p.loadtxt("data/gaussian.dat")
# FitContribution operations
# "|=" - Union of necessary components.
# "<<" - Inject a parameter value
c = FitContribution("g1")
c |= p
c |= "A * exp(-0.5*(x-x0)**2/sigma**2)"
c.A << 0.5
c.x0 << 5
c.sigma << 1
# FitRecipe operations
# "|=" - Union of necessary components.
# "+=" - Add Parameter or create a new one. Each tuple is a set of
# arguments for either setVar or addVar.
# "*=" - Constrain a parameter. Think of "*" as a push-pin holding one
# parameter's value to that of another.
# "%=" - Restrain a parameter or equation. Think of "%" as a rope
# loosely tying parameters to a value.
r = FitRecipe()
r |= c
r += (c.A, 0.5), (c.x0, 5), "sig"
r *= c.sigma, "sig"
r %= c.A, 0.5, 0.5
from gaussianrecipe import scipyOptimize
scipyOptimize(r)
res = FitResults(r)
# Print the results.
res.printResults()
# Plot the results.
from gaussianrecipe import plotResults
plotResults(r)
return
示例7: main
# 需要导入模块: from diffpy.srfit.fitbase import FitResults [as 别名]
# 或者: from diffpy.srfit.fitbase.FitResults import printResults [as 别名]
def main():
"""The workflow of creating, running and inspecting a fit."""
# Create the recipe
recipe = makeRecipe()
# Refine using the optimizer of your choice
scipyOptimize(recipe)
# Get the results.
res = FitResults(recipe)
# Print the results
res.printResults()
# Plot the results
plotResults(recipe)
return
示例8: main
# 需要导入模块: from diffpy.srfit.fitbase import FitResults [as 别名]
# 或者: from diffpy.srfit.fitbase.FitResults import printResults [as 别名]
def main():
molecule = makeC60()
# Make the data and the recipe
recipe = makeRecipe(molecule, "data/C60.gr")
# Tell the fithook that we want very verbose output.
recipe.fithooks[0].verbose = 3
# Optimize
from scipy.optimize import leastsq
leastsq(recipe.residual, recipe.getValues())
# Print results
res = FitResults(recipe)
res.printResults()
# Plot results
plotResults(recipe)
return
示例9: main
# 需要导入模块: from diffpy.srfit.fitbase import FitResults [as 别名]
# 或者: from diffpy.srfit.fitbase.FitResults import printResults [as 别名]
def main():
# Make two different data sets, each from the same structure, but with
# different scale, noise, broadening and background.
strufile = "data/C60.stru"
q = numpy.arange(1, 20, 0.05)
makeData(strufile, q, "C60_1.iq", 8.1, 101.68, 0.008, 0.12, 2, 0.01)
makeData(strufile, q, "C60_2.iq", 3.2, 101.68, 0.02, 0.003, 0, 1)
# Make the recipe
recipe = makeRecipe(strufile, "C60_1.iq", "C60_2.iq")
# Optimize
# Since the backgrounds have a large effect on the profile, we will refine
# them first, but do so separately.
# To refine the background from the first contribution, we will fix
# all other parameters and give the second contribution no weight in the
# fit.
recipe.fix("all")
recipe.free("bcoeffs1")
recipe.setWeight(recipe.bucky2, 0)
scipyOptimize(recipe)
# Now do the same for the second background
recipe.fix("all")
recipe.free("bcoeffs1")
recipe.setWeight(recipe.bucky2, 1)
recipe.setWeight(recipe.bucky1, 0)
scipyOptimize(recipe)
# Now refine everything with the structure parameters included
recipe.free("all")
recipe.setWeight(recipe.bucky1, 1)
scipyOptimize(recipe)
# Generate and print the FitResults
res = FitResults(recipe)
res.printResults()
# Plot!
plotResults(recipe)
return
示例10: makeRecipe
# 需要导入模块: from diffpy.srfit.fitbase import FitResults [as 别名]
# 或者: from diffpy.srfit.fitbase.FitResults import printResults [as 别名]
pylab.plot(r,diffzero,'k-')
pylab.xlabel("$r (\AA)$")
pylab.ylabel("$G (\AA^{-2})$")
pylab.legend(loc=1)
pylab.show()
return
if __name__ == "__main__":
# Make the data and the recipe
niciffile = "data/ni.cif"
siciffile = "data/si.cif"
data = "data/si90ni10-q27r60-xray.gr"
# Make the recipe
recipe = makeRecipe(niciffile, siciffile, data)
# Optimize
scipyOptimize(recipe)
# Generate and print the FitResults
res = FitResults(recipe)
res.printResults()
# Plot!
plotResults(recipe)
# End of file