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


Python Data.polyfit方法代码示例

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


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

示例1: norm_group

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import polyfit [as 别名]
def norm_group(pos,_,**kargs):
    """Takes the drain current for each file in group and builds an analysis file and works out the mean drain"""
    if "signal" in kargs:
        signal=kargs["signal"]
    else:
        signal="fluo"
    lfit=kargs["lfit"]
    rfit=kargs["rfit"]

    posfile=Data()
    posfile.metadata=pos[0].metadata
    posfile=posfile&pos[0].column(0)
    posfile.column_headers=['Energy']
    for f in pos:
        print(str(f["run"])+str(f.find_col(signal)))
        posfile=posfile&f.column(signal)
    posfile.add_column(lambda r:np.mean(r[1:]),"mean drain")
    ec=posfile.find_col('Energy')
    md=posfile.find_col('mean drain')
    linearfit=scipy.poly1d(posfile.polyfit(ec,md,1,lambda x,y:lfit[0]<=x<=lfit[1]))
    posfile.add_column(lambda r:r[md]-linearfit(r[ec]),'minus linear')
    highend=posfile.mean('minus',lambda r:rfit[0]<=r[ec]<=rfit[1])
    ml=posfile.find_col('minus linear')
    posfile.add_column(lambda r:r[ml]/highend,"normalised")
    if "group_key" in kargs:
        posfile[kargs["group_key"]]=pos.key
    return posfile
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:29,代码来源:XMCD_Reduction.py

示例2: linspace

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import polyfit [as 别名]
from Stoner import Data
import Stoner.Fit as SF
from numpy import linspace
from numpy.random import normal
import matplotlib.pyplot as plt

# Make some data
x = linspace(-10, 10, 101)
y = SF.quadratic(x + normal(size=len(x), scale=0.1), 4, -2, 11) * normal(
    size=len(x), scale=0.05, loc=1.0
)
s = y * 0.05
d = Data(x, y, s, setas="xye", column_headers=["X", "Y"])
d.plot(fmt="r.")

d.polyfit(result=True, header="Polyfit")
d.setas = "x..y"
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,
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:33,代码来源:Quadratic.py

示例3: linspace

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import polyfit [as 别名]
"""Decompose Example"""
from Stoner import Data
from Stoner.tools import format_val
from numpy import linspace, reshape, array

x = linspace(-10, 10, 201)
y = 0.3 * x ** 3 - 6 * x ** 2 + 11 * x - 20
d = Data(x, y, setas="xy", column_headers=["X", "Y"])
d.decompose()
d.setas = "xyyy"
coeffs = d.polyfit(polynomial_order=3)
str_coeffs = [format_val(c, mode="eng") for c in coeffs.ravel()]
str_coeffs = reshape(array(str_coeffs), coeffs.shape)
d.plot()
d.text(-6, -800, "Coefficients\n{}".format(str_coeffs), fontdict={"size": "x-small"})
d.ylabel = "Data"
d.title = "Decompose Example"
d.tight_layout()
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:20,代码来源:decompose.py


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