graph finished and captor choice possible

This commit is contained in:
theo.canaud 2022-06-27 17:31:07 +02:00
parent 5f23c7b15e
commit b51a98ba92

View file

@ -1,5 +1,6 @@
from pickletools import long1
from secrets import choice from secrets import choice
from xmlrpc.client import boolean from turtle import goto
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import csv import csv
@ -7,40 +8,66 @@ import csv
#"C:\Users\quent\OneDrive\Bureau\ENSC\TransD\Framboisier\02400001.TXT" #"C:\Users\quent\OneDrive\Bureau\ENSC\TransD\Framboisier\02400001.TXT"
#! /usr/bin/env python3 #! /usr/bin/env python3
# -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
def function():
#tab = np.zeros([1,9])
while True:
choice = input("Choisis un fichier csv de 1 à 1862: \n")
print("\n")
if float(choice) in range(1, 1863):
rawdata = '../RawDataFiles/RawData' + choice + '.csv' #Définit le fichier à ouvrir
with open(rawdata, newline='') as csvfile:
reader = csv.reader(csvfile, quoting=csv.QUOTE_NONNUMERIC)
x = [row for row in reader]
int_x = np.array(x, int)
column_index = [2,3,4,5,6,7,8,9]
for col in column_index:
column_values = np.empty(0)
for array in range(len(int_x)):
column_values = np.append(column_values, np.array(int_x[array][col-1]))
plt.plot(column_values)
plt.show()
break
elif choice > '1862' or choice < '1':
print("{} n'est pas un nombre valide.\n".format(choice))
# x = tab[:,0] # x = tab[:,0]
# y = tab[:,1] # y = tab[:,1]
# print(tab) # print(tab)
# return x , y # return x , y
bool #fonction choix du capteur à afficher :
#bool true si capteur veux être utiliser sinon false (tableau)
def function():
while True:
print("\n")
choice = input("(1) Choisis un fichier csv de 1 à 1862: ")
print("\n")
if float(choice) in range(1, 1863):
rawdata = '../RawDataFiles/RawData' + choice + '.csv' #Définit le fichier à ouvrir
choice2 = input("(2) Choisir un capteur à afficher en particulier dans le tableau? oui/non \n")
print("\n")
if choice2 == "oui":
while True:
ccapteur = int(input("(3) Choisis parmis les capteurs (1, 2, 3, 4, 5, 6, 7, 8): "))
print("\n")
if ccapteur in (1,2,3,4,5,6,7,8): #Affiche le capteur sélectionner
with open(rawdata, newline='') as csvfile:
reader = csv.reader(csvfile, quoting=csv.QUOTE_NONNUMERIC)
x = [row for row in reader]
int_x = np.array(x, int)
column_index = [ccapteur + 1]
for col in column_index:
column_values = np.empty(0)
for array in range(len(int_x)):
column_values = np.append(column_values, np.array(int_x[array][col-1]))
plt.plot(column_values)
plt.show()
exit()
elif ccapteur != (1,2,3,4,5,6,7,8):
print("{} n'est pas un nombre valide.\n".format(int(ccapteur)))
elif choice2 == "non": #Ouvre le csv file et affiche tout les capteurs
with open(rawdata, newline='') as csvfile:
reader = csv.reader(csvfile, quoting=csv.QUOTE_NONNUMERIC)
x = [row for row in reader]
int_x = np.array(x, int)
column_index = [2,3,4,5,6,7,8,9]
for col in column_index:
column_values = np.empty(0)
for array in range(len(int_x)):
column_values = np.append(column_values, np.array(int_x[array][col-1]))
plt.plot(column_values)
plt.show()
break
elif choice > '1862' or choice < '1':
print("{} n'est pas un nombre valide.\n".format(choice))
#Fonction d'affichage du graphique #Fonction d'affichage du graphique
def printFig(axe_x , axe_y , title = "new plot" , xlabel = "Temps" , ylabel = "Tension"): def printFig(axe_x , axe_y , title = "new plot" , xlabel = "Temps" , ylabel = "Tension"):
@ -53,8 +80,9 @@ def printFig(axe_x , axe_y , title = "new plot" , xlabel = "Temps" , ylabel = "T
#print(x) #print(x)
#print("y = " + str(y)) #print("y = " + str(y))
def final(): def final():
function() function()
#printFig() #printFig()
final() final()