M2_SETI/A4/TP_A4/exo4_opti/graph.py

75 lines
1.8 KiB
Python
Raw Permalink Normal View History

2023-02-12 23:49:07 +01:00
import numpy as np
import re
from matplotlib import pyplot as plt
### Variation de W et E
# with open ('time.txt', 'r') as timing:
# text = timing.read()
# # extract the values using regular expression
# values = re.findall(r'\d+\.\d+|\d+', text)
# # convert values to int or float
# values = [float(value) if '.' in value else int(value) for value in values]
# result = np.reshape(values,(36,10))
# # print(result)
# # SEQ = result[0:6,3]
# result = np.delete(result, (0,1,4,5,6,7), 1)
# W1 = result[0:6,:]
# W2 = result[6:12,:]
# W5 = result[12:18,:]
# W10 = result[18:24,:]
# W15 = result[24:30,:]
# W20 = result[30:36,:]
# plt.figure()
# plt.plot(W1[:,1],W1[:,2]+W1[:,3],'+-')
# plt.plot(W2[:,1],W2[:,2]+W2[:,3],'+-')
# plt.plot(W5[:,1],W5[:,2]+W5[:,3],'+-')
# plt.plot(W10[:,1],W10[:,2]+W10[:,3],'+-')
# plt.plot(W15[:,1],W15[:,2]+W15[:,3],'+-')
# plt.plot(W20[:,1],W20[:,2]+W20[:,3],'+-')
# plt.legend(["WS = 1","WS = 2","WS = 5","WS = 10","WS = 15","WS = 20"])
# plt.xlabel("Coins")
# plt.ylabel("t (s)")
# plt.title("Convolution + Eigen pas opti")
# plt.show()
### CPP
with open ('CPP.txt', 'r') as timing:
text = timing.read()
# extract the values using regular expression
values = re.findall(r'\d+\.\d+|\d+', text)
# convert values to int or float
values = [float(value) if '.' in value else int(value) for value in values]
result = np.reshape(values,(12,10))
# print(result)
RES = result[:6,4:6]
X = [str(sub) for sub in RES]
result = np.delete(result, (0,1,4,5,6,7), 1)
OPT = result[0:6,2]+result[0:6,3]*1.1e9/(RES[:,0]*RES[:,1])
NOPT = result[6:12,2]+result[6:12,3]*1.1e9/(RES[:,0]*RES[:,1])
plt.figure()
plt.plot(X,OPT,'+-')
plt.plot(X,NOPT,'+-')
plt.legend(["Optimisé","Non optimisé"])
plt.xlabel("Résolution")
plt.ylabel("CPP")
plt.title("CPP en fonction des images")
plt.show()