本文整理汇总了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()
示例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