pythonintegrator

Python Integrator: time column, data column


I have the following result:

Time Production
0 360
10 362
15 365
30 380
32 381
.. ..

The first column is the (simulation) time (not equi-distant); the second column is the production in kW.

Now i want to calculate the total production in kWh --> therefore i want to integrate the Production. Is there a straightforward way to do this in Python (numpy?)?

Thank you very much for your time.


Solution

  • You can use numpy trapizium rule to approximate,

    import numpy as np
    
    t = [0, 10, 15, 30, 32]
    p = [360, 362, 365, 380, 381]
    
    a = np.trapz(p,t)
    
    print(a)