当前位置: 首页>>代码示例>>Python>>正文


Python Data.annotate_fit方法代码示例

本文整理汇总了Python中Stoner.Data.annotate_fit方法的典型用法代码示例。如果您正苦于以下问题:Python Data.annotate_fit方法的具体用法?Python Data.annotate_fit怎么用?Python Data.annotate_fit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stoner.Data的用法示例。


在下文中一共展示了Data.annotate_fit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1:

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import annotate_fit [as 别名]
d.plot(fmt="m-", label="Polyfit")
d.text(
    -9,
    450,
    "Polynominal co-efficients\n{}".format(d["2nd-order polyfit coefficients"]),
    fontdict={"size": "x-small", "color": "magenta"},
)

d.setas = "xy"
d.curve_fit(SF.quadratic, result=True, header="Curve-fit")
d.setas = "x...y"
d.plot(fmt="b-", label="curve-fit")
d.annotate_fit(
    SF.quadratic,
    prefix="quadratic",
    x=0.2,
    y=0.65,
    fontdict={"size": "x-small", "color": "blue"},
)

d.setas = "xy"
fit = SF.Quadratic()
p0 = fit.guess(y, x=x)
d.lmfit(SF.Quadratic, p0=p0, result=True, header="lmfit")

d.setas = "x...y"
d.plot(fmt="g-", label="lmfit")
d.annotate_fit(
    SF.Quadratic,
    prefix="Quadratic",
    x=0.65,
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:33,代码来源:Quadratic.py

示例2: linspace

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import annotate_fit [as 别名]
"""Example of nDimArrhenius Fit."""
from Stoner import Data
import Stoner.Fit as SF
from numpy import linspace
from numpy.random import normal

# Make some data
T = linspace(50, 500, 101)
R = SF.nDimArrhenius(T + normal(size=len(T), scale=5.0, loc=1.0), 1e6, 0.5, 2)
d = Data(T, R, setas="xy", column_headers=["T", "Rate"])

# Curve_fit on its own
d.curve_fit(SF.nDimArrhenius, p0=[1e6, 0.5, 2], result=True, header="curve_fit")
d.setas = "xyy"
d.plot(fmt=["r.", "b-"])
d.annotate_fit(SF.nDimArrhenius, x=0.25, y=0.3)

# lmfit using lmfit guesses
fit = SF.NDimArrhenius()
p0 = fit.guess(R, x=T)
d.lmfit(fit, p0=p0, result=True, header="lmfit")
d.setas = "x..y"
d.plot(fmt="g-")
d.annotate_fit(SF.NDimArrhenius, x=0.25, y=0.05, prefix="NDimArrhenius")

d.title = "n-D Arrhenius Test Fit"
d.ylabel = "Rate"
d.xlabel = "Temperature (K)"
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:30,代码来源:nDimArrhenius.py

示例3: zip

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import annotate_fit [as 别名]
d.curve_fit(func, p0=copy(params)[0:2], result=True, header="curve_fit")

d.setas = "xye"
fit = SF.Langevin()
p0 = fit.guess(G, x=B)
for p, v in zip(p0, params):
    p0[p].set(v)
    p0[p].max = v * 5
    p0[p].min = 0
    p0[p].vary = p != "T"

d.lmfit(fit, p0=p0, result=True, header="lmfit")


d.setas = "xyeyy"
d.plot(fmt=["r.", "b-", "g-"])

d.annotate_fit(
    func, x=0.1, y=0.5, fontdict={"size": "x-small", "color": "blue"}, mode="eng"
)
d.annotate_fit(
    SF.Langevin,
    x=0.1,
    y=0.25,
    fontdict={"size": "x-small", "color": "green"},
    prefix="Langevin",
    mode="eng",
)
d.title = "langevin Fit"
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:31,代码来源:langevin.py

示例4:

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import annotate_fit [as 别名]
    ODRModel,
    result=True,
    header="ODR-Fit",
    residuals=True,
    output="report",
    prefix="ODRModel",
)
# Reset labels
d.labels = []

# Make nice two panel plot layout
ax = d.subplot2grid((3, 1), (2, 0))
d.setas = "x..y"
d.plot(fmt="g+", label="Fit residuals")
d.setas = "x....y"
d.plot(fmt="b+", label="ODRModel Residuals")
d.title = ""

ax = d.subplot2grid((3, 1), (0, 0), rowspan=2)
d.setas = "xyy.y"
d.plot(fmt=["ro", "g-", "b-"])
d.xticklabels = [[]]
d.ax_xlabel = ""

# Annotate plot with fitting parameters
d.annotate_fit(PowerLaw, x=0.1, y=0.25, fontdict={"size": "x-small"})
d.annotate_fit(
    ODRModel, x=0.65, y=0.15, fontdict={"size": "x-small"}, prefix="ODRModel"
)
d.title = u"curve_fit with models"
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:32,代码来源:curvefit_models.py

示例5: linspace

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import annotate_fit [as 别名]
from numpy.random import normal

# Make some data
V = linspace(-4, 4, 1001)
I = SF.simmons(V, 2500, 5.2, 15.0) + normal(size=len(V), scale=100e-9)
dI = ones_like(V) * 100e-9

d = Data(V, I, dI, setas="xye", column_headers=["Bias", "Current", "Noise"])

d.curve_fit(SF.simmons, p0=[2500, 5.2, 15.0], result=True, header="curve_fit")
d.setas = "xyey"
d.plot(fmt=["r.", "b-"])
d.annotate_fit(
    SF.simmons,
    x=0.25,
    y=0.25,
    prefix="simmons",
    fontdict={"size": "x-small", "color": "blue"},
)

d.setas = "xye"
fit = SF.Simmons()
p0 = [2500, 5.2, 15.0]
d.lmfit(SF.Simmons, p0=p0, result=True, header="lmfit")
d.setas = "x...y"
d.plot(fmt="g-")
d.annotate_fit(
    fit,
    x=0.65,
    y=0.25,
    prefix="Simmons",
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:33,代码来源:Simmons.py

示例6: linspace

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import annotate_fit [as 别名]
from numpy.random import normal

# Make some data
V = linspace(-4, 4, 1000)
I = SF.fowlerNordheim(V, 2500, 3.2, 15.0) + normal(size=len(V), scale=1e-6)
dI = ones_like(V) * 10e-6

d = Data(V, I, dI, setas="xye", column_headers=["Bias", "Current", "Noise"])

d.curve_fit(SF.fowlerNordheim, p0=[2500, 3.2, 15.0], result=True, header="curve_fit")
d.setas = "xyey"
d.plot(fmt=["r.", "b-"])
d.annotate_fit(
    SF.fowlerNordheim,
    x=0.2,
    y=0.6,
    prefix="fowlerNordheim",
    fontdict={"size": "x-small", "color": "blue"},
)

d.setas = "xye"
fit = SF.FowlerNordheim()
p0 = [2500, 5.2, 15.0]
p0 = fit.guess(I, x=V)
for p, v, mi, mx in zip(
    ["A", "phi", "d"], [2500, 3.2, 15.0], [100, 1, 5], [1e4, 20.0, 30.0]
):
    p0[p].value = v
    p0[p].bounds = [mi, mx]
d.lmfit(SF.FowlerNordheim, p0=p0, result=True, header="lmfit")
d.setas = "x...y"
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:33,代码来源:FowlerNordheim.py

示例7: normal

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import annotate_fit [as 别名]
G = SF.fluchsSondheimer(B, *params) + normal(size=len(B), scale=5e-5)
dG = ones_like(B) * 5e-5
d = Data(
    B,
    G,
    dG,
    setas="xye",
    column_headers=["Thickness (nm)", "Conductance", "dConductance"],
)

d.curve_fit(SF.fluchsSondheimer, p0=params, result=True, header="curve_fit")

d.setas = "xye"
d.lmfit(SF.FluchsSondheimer, p0=params, result=True, header="lmfit")

d.setas = "xyeyy"
d.plot(fmt=["r.", "b-", "g-"])

d.annotate_fit(
    SF.fluchsSondheimer, x=0.2, y=0.6, fontdict={"size": "x-small", "color": "blue"}
)
d.annotate_fit(
    SF.FluchsSondheimer,
    x=0.2,
    y=0.4,
    fontdict={"size": "x-small", "color": "green"},
    prefix="FluchsSondheimer",
)
d.title = "Fluchs-Sondheimer Fit"
d.tight_layout()
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:32,代码来源:f_s.py

示例8: exp

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import annotate_fit [as 别名]
d.plot(fmt="ro")  # plot our data

func = lambda x, A, B, C: A + B * exp(-x / C)


# Do the fitting and plot the result
fit = d.differential_evolution(
    func, result=True, header="Fit", A=1, B=1, C=1, prefix="Model", residuals=True
)

# Reset labels
d.labels = []

# Make nice two panel plot layout
ax = d.subplot2grid((3, 1), (2, 0))
d.setas = "x..y"
d.plot(fmt="g+")
d.title = ""

ax = d.subplot2grid((3, 1), (0, 0), rowspan=2)
d.setas = "xyy"
d.plot(fmt=["r.", "b-"])
d.xticklabels = [[]]
d.xlabel = ""

# Annotate plot with fitting parameters
d.annotate_fit(func, prefix="Model", x=0.7, y=0.3, fontdict={"size": "x-small"})
text = r"$y=A+Be^{-x/C}$" + "\n\n"
d.text(7.2, 3.9, text, fontdict={"size": "x-small"})
d.title = u"Differential Evolution  Fit"
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:32,代码来源:differential_evolution_simple.py

示例9: guess_vals

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import annotate_fit [as 别名]
@simple_model.guesser
def guess_vals(y, x=None):
    """Should guess parameter values really!"""
    m = (y.max() - y.min()) / (x[y.argmax()] - x[y.argmin()])
    c = x.mean() * m - y.mean()  # return one value per parameter
    return [m, c]


# Add a function to sry vonstraints on parameters (optional)
@simple_model.hinter
def hint_parameters():
    """Five some hints about the parameter."""
    return {"m": {"max": 10.0, "min": 0.0}, "c": {"max": 5.0, "min": -5.0}}


# Create some x,y data
x = linspace(0, 10, 101)
y = 4.5 * x - 2.3 + normal(scale=0.4, size=len(x))

# Make The Data object
d = Data(x, y, setas="xy", column_headers=["X", "Y"])

# Do the fit
d.lmfit(simple_model, result=True)

# Plot the result
d.setas = "xyy"
d.plot(fmt=["r+", "b-"])
d.title = "Simple Model Fit"
d.annotate_fit(simple_model, x=0.05, y=0.5)
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:32,代码来源:make_model.py

示例10: fit

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import annotate_fit [as 别名]
# Curve_fit on its own
d.curve_fit(vftEquation, p0=params, result=True, header="curve_fit")

# lmfit uses some guesses
p0 = params
d.lmfit(VFTEquation, p0=p0, result=True, header="lmfit")

# Plot these results too
d.setas = "x..yy"
d.plot(fmt=["b-", "g-"])
# Annotate the graph
d.annotate_fit(
    vftEquation,
    x=0.25,
    y=0.35,
    fontdict={"size": "x-small", "color": "blue"},
    mode="eng",
)
d.annotate_fit(
    VFTEquation,
    x=0.5,
    y=0.35,
    prefix="VFTEquation",
    fontdict={"size": "x-small", "color": "green"},
    mode="eng",
)

# reset the columns for the fit
d.setas = "xye.."
# Now do the odr fit (will overwrite lmfit's metadata)
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:32,代码来源:vftEquation.py

示例11:

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import annotate_fit [as 别名]
)

d.curve_fit(SF.kittelEquation, p0=copy(params), result=True, header="curve_fit")

fit = SF.KittelEquation()
p0 = fit.guess(G, x=B)

d.lmfit(fit, p0=p0, result=True, header="lmfit")

d.setas = "xyeyy"
d.plot(fmt=["r.", "b-", "g-"])

d.annotate_fit(
    SF.kittelEquation,
    x=0.5,
    y=0.25,
    fontdict={"size": "x-small", "color": "blue"},
    mode="eng",
)
d.annotate_fit(
    SF.KittelEquation,
    x=0.5,
    y=0.05,
    fontdict={"size": "x-small", "color": "green"},
    prefix="KittelEquation",
    mode="eng",
)
d.title = "Kittel Fit"
d.fig.gca().xaxis.set_major_formatter(TexEngFormatter())
d.fig.gca().yaxis.set_major_formatter(TexEngFormatter())
d.tight_layout()
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:33,代码来源:kittel.py

示例12: linspace

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import annotate_fit [as 别名]
from numpy.random import normal

# Make some data
T = linspace(200, 350, 101)
R = SF.arrhenius(T + normal(size=len(T), scale=3.0, loc=0.0), 1e6, 0.5)
E = 10 ** ceil(log10(abs(R - SF.arrhenius(T, 1e6, 0.5))))
d = Data(T, R, E, setas="xye", column_headers=["T", "Rate"])

# Curve_fit on its own
d.curve_fit(SF.arrhenius, p0=(1e6, 0.5), result=True, header="curve_fit")
d.setas = "xyey"
d.plot(fmt=["r.", "b-"])
d.annotate_fit(
    SF.arrhenius,
    x=0.5,
    y=0.5,
    mode="eng",
    fontdict={"size": "x-small", "color": "blue"},
)

# lmfit using lmfit guesses
fit = SF.Arrhenius()
d.setas = "xye"
d.lmfit(fit, result=True, header="lmfit")
d.setas = "x...y"
d.plot(fmt="g-")
d.annotate_fit(
    SF.Arrhenius,
    x=0.5,
    y=0.35,
    prefix="Arrhenius",
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:33,代码来源:Arrhenius.py

示例13: gmean

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import annotate_fit [as 别名]
        result.data[:, c] = (resfldr[1][:, c] + resfldr[0][:, c]) / 2.0
    for c in [1, 3, 5, 7]:
        result.data[:, c] = gmean((resfldr[0][:, c], resfldr[1][:, c]), axis=0)

    # Doing the Kittel fit with an orthogonal distance regression as we have x errors not y errors
    p0 = [2, 200e3, 10e3]  # Some sensible guesses
    result.lmfit(
        Inverse_Kittel, p0=p0, result=True, header="Kittel Fit", output="report"
    )
    result.setas[-1] = "y"

    result.template.yformatter = TexEngFormatter
    result.template.xformatter = TexEngFormatter
    result.labels = None
    result.figure(figsize=(6, 8))
    result.subplot(211)
    result.plot(fmt=["r.", "b-"])
    result.annotate_fit(Inverse_Kittel, x=7e9, y=1e5, fontdict={"size": 8})
    result.ylabel = "$H_{res} \\mathrm{(Am^{-1})}$"
    result.title = "Inverse Kittel Fit"

    # Get alpha
    result.subplot(212)
    result.setas(y="Delta_H", e="Delta_H.stderr", x="Freq")
    result.y /= mu_0
    result.e /= mu_0
    result.lmfit(Linear, result=True, header="Width", output="report")
    result.setas[-1] = "y"
    result.plot(fmt=["r.", "b-"])
    result.annotate_fit(Linear, x=5.5e9, y=2.8e3, fontdict={"size": 8})
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:32,代码来源:plot-folder-test.py

示例14: Data

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import annotate_fit [as 别名]
"""Example of using lmfit to do a bounded fit."""
from Stoner import Data
from Stoner.Fit import StretchedExp

# Load dat and plot
d = Data("lmfit_data.txt", setas="xy")

# Do the fit
d.lmfit(StretchedExp, result=True, header="Fit", prefix="")
# plot
d.setas = "xyy"

d.plot(fmt=["+", "-"])
# Make apretty label using Stoner.Util methods
text = r"$y=A e^{-\left(\frac{x}{x_0}\right)^\beta}$" + "\n"
text += d.annotate_fit(StretchedExp, text_only=True, prefix="")
d.text(6, 4e4, text)
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:19,代码来源:lmfit_example.py

示例15:

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import annotate_fit [as 别名]
        data.del_rows(isnan(data.y))

        #Normalise data on y axis between +/- 1
        data.normalise(base=(-1.,1.), replace=True)

        #Swap x and y axes around so that R is x and T is y
        data=~data

        #Curve fit a straight line, using only the central 90% of the resistance transition
        data.curve_fit(linear,bounds=lambda x,r:-threshold<x<threshold,result=True,p0=[7.0,0.0]) #result=True to record fit into metadata

        #Plot the results
        data.setas[-1]="y"
        data.subplot(1,len(r_cols),i+1)
        data.plot(fmt=["k.","r-"])
        data.annotate_fit(linear,x=-1.,y=7.3c,fontsize="small")
        data.title="Ramp {}".format(data[iterator][0])
        row.extend([data["linear:intercept"],data["linear:intercept err"]])
    data.tight_layout()
    result+=np.array(row)

result.column_headers=["Ramp","Sample 4 R","dR","Sample 7 R","dR"]
result.setas="xyeye"
result.plot(fmt=["k.","r."])






开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:26,代码来源:Tc_Fit.py


注:本文中的Stoner.Data.annotate_fit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。