How can sampled power readings estimate energy?

trapezoid approximates an integral with adjoining trapezoids. Each area is the average endpoint height times the interval width.

numpy.trapezoid in practice

At seconds zero, one and three, power readings zero, two and two watts contribute one and four joules. Check chronological order because the routine follows the coordinates supplied.

import numpy as np
np.trapezoid([0,2,2],x=[0,1,3])

Result 5.0

中文

离散功率读数如何估算能量?

trapezoid 用分段梯形近似积分,每段面积是平均高度乘以横坐标间隔。

numpy.trapezoid 算例

在 0、1、3 秒记录 0、2、2 瓦,两段分别贡献 1 和 4 焦耳。横坐标按给定次序参与计算,先确认时间顺序。

import numpy as np
np.trapezoid([0,2,2],x=[0,1,3])

结果 5.0

References / 参考来源

Keep reading / 继续阅读