I have an excel file witch contains a data set of velocity. using these libraries :
from xlrd import open_workbook
import matplotlib.pyplot as plt
import statistics
import numpy as np
after reading files of excel we have the 3 list. for example:
t=[0.02,0.6,0.01,0.14,0.18,0.22,0.26,0.3,0.34,0.38,0.42,0.46,0.5,0.54]
Vx=[-22.67,-20.74,-15.42,-17.83,-9.17,-7.1,-14.74,-11.84,-10.54,-18.4,-10.31,-6.84,-15.45,-4.81]
Vy=[6.9,7.99,-3.8,9.62,8.49,-3.55,-6.45,0.48,6.54,-1.13,-5.74,-2.45,2.63,-4.71]
in next steps we need the mean
and these numbers as an array
:
u = np.array(Vx)
V = np.array(Vy)
ubar,vbar=round(statistics.mean(Vx),3),round(statistics.mean(Vy),3)
after that other form of vectors are required. u'
and v'
with these formula :
uprime = [i-ubar for i in Vx]
vprime = [i-vbar for i in Vy]
now after some other formula and calculations we have major and minor axes of an ellipse : for example :
x0=16.69
y0=21.22
the whole ellipse has a rotation showing by theta
.
for example :
theta = -0.25 #rad
now i want to plot this datasets (u'-v')
by scatter form and the ellipse on it.
i have plotted the scatter :
plt.scatter(uprime,vprime,marker=".")
plt.xlabel("u'")
plt.ylabel("v'")
plt.show()
but i can't plot the ellipse and its rotation. after that i must find the datas out of the llipsoid to find them as spikes. somthing like the picture below. how can i do that?(the main dataset is near to 1300 datas and here is just a summary)