Example #1
0
# fitting range.

linefit.A
linefit.A = 3
linefit.B = 5
print(linefit.A, linefit.A.value)
print(linefit.B, linefit.B.value)

# <demo> --- stop ---

# linefit.evaluate() returns the modeled values and linefit.residual
# the difference between observed and modeled data scaled by estimated
# standard deviations.

print("linefit.evaluate() =", linefit.evaluate())
print("linefit.residual() =", linefit.residual())
plt.plot(xobs, yobs, 'x', linedata.x, linefit.evaluate(), '-')
plt.title('Line simulated at A=3, B=5')

# <demo> --- stop ---

# We want to find optimum model parameters that fit the simulated curve
# to the observations.  This is done by associating FitContribution with
# a FitRecipe object.  FitRecipe can manage multiple fit contributions and
# optimize all models to fit their respective profiles.

from diffpy.srfit.fitbase import FitRecipe
rec = FitRecipe()
# clearFitHooks suppresses printout of iteration number
rec.clearFitHooks()
Example #2
0
print(large_gaussian.lgA, large_gaussian.lgA.value)
print(large_gaussian.lgx0, large_gaussian.lgx0.value)
print(large_gaussian.lgsig, large_gaussian.lgsig.value)
print(small_gaussian.sgA, small_gaussian.sgA.value)
print(small_gaussian.sgx0, small_gaussian.sgx0.value)
print(small_gaussian.sgsig, small_gaussian.sgsig.value)

# <demo> --- stop ---

# linefit.evaluate() returns the modeled values and linefit.residual
# the difference between observed and modeled data scaled by estimated
# standard deviations.

print("large_gaussian.evaluate() =", large_gaussian.evaluate())
print("large_gaussian.residual() =", large_gaussian.residual())
print("small_gaussian.evaluate() =", small_gaussian.evaluate())
print("small_gaussian.residual() =", small_gaussian.residual())
plt.plot(xobs, yobs, 'x', profile.x, large_gaussian.evaluate(), '-', profile.x,
         small_gaussian.evaluate())
plt.title(
    'Two Gaussians simulated at A=25000, x0=40, sig=20 and A=500, x0=68, sig=3'
)

# <demo> --- stop ---

# We want to find optimum model parameters that fit the simulated curve
# to the observations.  This is done by associating FitContribution with
# a FitRecipe object.  FitRecipe can manage multiple fit contributions and
# optimize all models to fit their respective profiles.
Example #3
0
# fitting range.

linefit.A
linefit.A = 3
linefit.B = 5
print(linefit.A, linefit.A.value)
print(linefit.B, linefit.B.value)

# <demo> --- stop ---

# linefit.evaluate() returns the modeled values and linefit.residual
# the difference between observed and modeled data scaled by estimated
# standard deviations.

print("linefit.evaluate() =", linefit.evaluate())
print("linefit.residual() =", linefit.residual())
plt.plot(xobs, yobs, 'x', linedata.x, linefit.evaluate(), '-')
plt.title('Line simulated at A=3, B=5')

# <demo> --- stop ---

# We want to find optimum model parameters that fit the simulated curve
# to the observations.  This is done by associating FitContribution with
# a FitRecipe object.  FitRecipe can manage multiple fit contributions and
# optimize all models to fit their respective profiles.

from diffpy.srfit.fitbase import FitRecipe
rec = FitRecipe()
# clearFitHooks suppresses printout of iteration number
rec.clearFitHooks()
Example #4
0
large_gaussian.A = 25000
large_gaussian.x0 = 40
large_gaussian.sig = 20
print(large_gaussian.A, large_gaussian.A.value)
print(large_gaussian.x0, large_gaussian.x0.value)
print(large_gaussian.sig, large_gaussian.sig.value)

# <demo> --- stop ---

# linefit.evaluate() returns the modeled values and linefit.residual
# the difference between observed and modeled data scaled by estimated
# standard deviations.

print("large_gaussian.evaluate() =", large_gaussian.evaluate())
print("large_gaussian.residual() =", large_gaussian.residual())
plt.plot(xobs, yobs, 'x', profile.x, large_gaussian.evaluate(), '-')
plt.title('Gaussian simulated at A=30000, x0=50, sig=30')

# <demo> --- stop ---

# We want to find optimum model parameters that fit the simulated curve
# to the observations.  This is done by associating FitContribution with
# a FitRecipe object.  FitRecipe can manage multiple fit contributions and
# optimize all models to fit their respective profiles.

from diffpy.srfit.fitbase import FitRecipe
recipe = FitRecipe()

# clearFitHooks suppresses printout of iteration number
recipe.clearFitHooks()