-
Notifications
You must be signed in to change notification settings - Fork 1
/
script4.py
61 lines (43 loc) · 1.07 KB
/
script4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from math import *
import numpy as np
import matplotlib.pyplot as plt
# Open a file
f = open("pressure.txt", "r")
# define an empty list
data=[]
# read full file and split into its parts
data=f.read().split()
# Close opend file
f.close()
n = len(data)
#print(n)
x=np.linspace(0,n,n)
x /= 3600. # conversion en heures
#print(len(x))
y=np.asarray(data, dtype=float) # convert a list into np array see http://docs.scipy.org/doc/numpy/reference/generated/numpy.asarray.html
y /= 1000. # conversion en kPa
#print(len(y))
mean = np.mean(y)
std = np.std(y)
ymean = np.ones(n)*mean
yp = np.ones(n)*(mean+std)
ym = np.ones(n)*(mean-std)
plt.plot(x,y)
plt.plot(x,ymean)
plt.plot(x,yp)
plt.plot(x,ym)
plt.ylabel('pression [kPa]')
plt.xlabel('temps [heures]')
plt.show()
# Histogramme
ps = 24000.
rho = 0.91875
for i in range(0,len(data)) :
data[i] = sqrt( (float(data[i]) - ps)/rho )
data[i] *= 3600./1000.
plt.hist(data, 50, normed=1, facecolor='r')
plt.xlabel('vitesse (Km/h)')
plt.ylabel('Probabilite')
plt.title('Histogramme')
#plt.axis([40, 160, 0, 0.03])
plt.show()