Пример #1
0
linedata = Profile()
linedata.setObservedProfile(xobs, yobs, dyobs)

# The second step is to create a FitContribution object, which associates
# observed profile with a mathematical model for the dependent variable.

from diffpy.srfit.fitbase import FitContribution
linefit = FitContribution('linefit')
linefit.setProfile(linedata)
linefit.setEquation("A * x + B")

# 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.

linefit.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.

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

# <demo> --- stop ---
Пример #2
0
                                      name='gaussnorm')
large_gaussian.setEquation(
    "lgA * gaussnorm * exp(-0.5 * (x - lgx0)**2/lgsig**2)")

small_gaussian = FitContribution("g2")
small_gaussian.setProfile(profile, xname="x")
small_gaussian.registerStringFunction('1/sqrt(2 * pi * sgsig**2)',
                                      name='gaussnorm')
small_gaussian.setEquation(
    "sgA * gaussnorm * exp(-0.5 * (x - sgx0)**2/sgsig**2)")

# 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()
small_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.lgA = 25000
large_gaussian.lgx0 = 40
large_gaussian.lgsig = 20
small_gaussian.sgA = 500
small_gaussian.sgx0 = 71
small_gaussian.sgsig = 3
Пример #3
0
linedata = Profile()
linedata.setObservedProfile(xobs, yobs, dyobs)

# The second step is to create a FitContribution object, which associates
# observed profile with a mathematical model for the dependent variable.

from diffpy.srfit.fitbase import FitContribution
linefit = FitContribution('linefit')
linefit.setProfile(linedata)
linefit.setEquation("A * x + B")

# 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.

linefit.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.

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

# <demo> --- stop ---
Пример #4
0
# The second step is to create a FitContribution object, which associates
# observed profile with a mathematical model for the dependent variable.

from diffpy.srfit.fitbase import FitContribution
large_gaussian = FitContribution("g1")
large_gaussian.setProfile(profile, xname="x")
large_gaussian.registerStringFunction('1/sqrt(2 * pi * sig**2)',
                                      name='gaussnorm')
large_gaussian.setEquation("A * gaussnorm * exp(-0.5 * (x - x0)**2/sig**2)")

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