I have three columns of data (time (t), Thrust (T), distance (s)) from which I would like to calculate the work performed. The text (logdata.txt) file containing the data is structured as follows:
time, thrust, distance
1 2405 501
2 2500 702
3 2500 903
4 2580 1100
5 2610 1300
The examples I have encountered only show how to use the scipy.integrate functions when setting up your own function for f(x), however in this case I have the raw data (hence no function). I would like to integrate the thrust over the distance covered using the Simpson rule. The code I use is as follows:
from scipy import integrate
import numpy as np
data = np.loadtxt("logdata.txt")
#selecting the whole second and third column of the text file
x = data[1]
y = data[2]
integrate.simps(y)
However, this does not give me a reasonable value. Does anyone know how to go about this?
You need to provide the
x, or in this case, the distance as well -I can verify this is roughly right by checking the average "thrust" and the distance moved