Example #1
0
# SrFit objects can be examined by calling their show() function.  SrFit
# parses the model equation and finds two parameters A, B at independent
# variable x.  The values of parameters A, B are at this stage undefined.

large_gaussian.show()

# <demo> --- stop ---

# We can set A and B to some specific values and calculate model
# observations.  The x and y attributes of the FitContribution are
# the observed values, which may be re-sampled or truncated to a shorter
# fitting range.

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')