本文整理匯總了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