Traitement-signal-plantes/Py-Script/courbe.py

52 lines
1.3 KiB
Python

from secrets import choice
import numpy as np
import matplotlib.pyplot as plt
import csv
import pandas as pd
#"C:\Users\quent\OneDrive\Bureau\ENSC\TransD\Framboisier\02400001.TXT"
#! /usr/bin/env python3
# -*- 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)
for row in reader:
t = np.zeros([1,9])
t[0] = row
tab = np.append(tab ,t , axis = 0)
break
elif choice > '1862' or choice < '1':
print("{} n'est pas un nombre valide.\n".format(choice))
x = tab[:,0]
y = tab[:,1]
print(tab)
return x , y
#Fonction d'affichage du graphique
def printFig(axe_x , axe_y , title = "new plot" , xlabel = "Temps" , ylabel = "Tension"):
plt.plot(axe_x , axe_y)
plt.xlabel(xlabel)
plt.ylabel(ylabel)
plt.title(title)
plt.show()
return 0
#print(x)
#print("y = " + str(y))
def final():
x, y = function()
printFig(x,y)
final()