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


Python Function.interpolate方法代码示例

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


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

示例1: exit

# 需要导入模块: from function import Function [as 别名]
# 或者: from function.Function import interpolate [as 别名]
exit(0)

# now read in 1A.csv to get voltage_actual against wh
# in = time, voltage_drain, current

last_time = 0
total_wh = 0

fin = open("1A.csv")
fout = open("1A_treated.csv", 'w')
fout.write("total_wh, voltage_actual\n")
while (True):
    l = fin.readline()
    if len(l) == 0:
        break
    spl = l.split(',')
    try:
        time = float(spl[0])
        voltage_drain = float(spl[1])
        current = float(spl[2])
        total_wh += (time - last_time) * voltage_drain * current / 3600
        last_time = time

        fout.write("%f,%f\n" % (total_wh, f.interpolate(voltage_drain)))
    except Exception, e:
        print "An exception occurred: " + str(e)
        print "It's probably ok"

fin.close()
fout.close()
开发者ID:dcposch,项目名称:dcpos.ch,代码行数:32,代码来源:current_to_wh.py

示例2: Function

# 需要导入模块: from function import Function [as 别名]
# 或者: from function.Function import interpolate [as 别名]
        print "It's probably ok"

f = Function(data=data)

for i in xrange(len(data)):
    v = data[i][0]
    wh = data[i][1]
    data[i] = (v, (wh - min_wh) / (max_wh - min_wh))

SPACING = (max_v - min_v) / 100

fout.write('[\n')

v = min_v
while v <= max_v:
    interpolated_wh = f.interpolate(v)
    fout.write("{%d,%d},\n" % (int(v*1000000), int(interpolated_wh*1000000)))
    v += SPACING

fout.write(']\n')
fout.write('[\n')

SPACING = (max_v - min_v) / 10000

last_v = min_v
last_wh = f.interpolate(min_v)
max_delta_v = 0
max_delta_wh = 0
min_delta_v = float("inf")
min_delta_wh = float("inf")
v = min_v
开发者ID:dcposch,项目名称:dcpos.ch,代码行数:33,代码来源:create_datastructure.py


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