try to fix getArray
This commit is contained in:
parent
1eb7ec26b3
commit
b464ff1541
|
@ -17,10 +17,11 @@ void averageCalculation(long **p, double averageArray[])
|
||||||
averageArray[i] = 0;
|
averageArray[i] = 0;
|
||||||
while (j < nRowRawData)
|
while (j < nRowRawData)
|
||||||
{
|
{
|
||||||
averageArray[i - 1] += p[i][j];
|
printf("pij = %ld\n" , p[i][j]);
|
||||||
|
averageArray[i - 1] += (double)p[i][j];
|
||||||
|
printf("%f , %ld\n", averageArray[i] , p[i][j]);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
// printf("%f , %f\n", averageArray[i] , averageArray[i] / nRowRawData);
|
|
||||||
averageArray[i] /= nRowRawData;
|
averageArray[i] /= nRowRawData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,19 +31,20 @@ void fillArrayWithRawData(char *rawDataFileName, long **p, int N, int M)
|
||||||
char *buffer;
|
char *buffer;
|
||||||
size_t bufsize = 200;
|
size_t bufsize = 200;
|
||||||
buffer = (char *)malloc(bufsize * sizeof(char));
|
buffer = (char *)malloc(bufsize * sizeof(char));
|
||||||
int token;
|
char * token;
|
||||||
|
|
||||||
FILE *f = fopen(rawDataFileName, "r");
|
FILE *f = fopen(rawDataFileName, "r");
|
||||||
|
|
||||||
for (i = 0; i < N; i++)
|
for (i = 0; i < N; i++)
|
||||||
{
|
{
|
||||||
if (!getline(&buffer, &bufsize, f))
|
char *t , *c1, *c2 , *c3;
|
||||||
break; // condition d'arret de la boucle si fichier fini
|
while (fscanf(f , "%s,%s,%s,%s\n",t,c1,c2,c3))
|
||||||
j = 0;
|
|
||||||
while ((token = strsep(&buffer, ",")) != 0)
|
|
||||||
{ // séparation valeur par virgule initiale : csv
|
{ // séparation valeur par virgule initiale : csv
|
||||||
p[i][j] = token;
|
printf("%s,%s,%s,%s",t,c1,c2,c3);
|
||||||
j++;
|
p[i][0] = atol(t);
|
||||||
|
p[i][1] = atol(c1);
|
||||||
|
p[i][2] = atol(c2);
|
||||||
|
p[i][3] = atol(c3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
|
@ -5,100 +5,26 @@ import struct
|
||||||
import csv
|
import csv
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
#"C:\Users\quent\OneDrive\Bureau\ENSC\TransD\Framboisier\02400001.TXT"
|
def function():
|
||||||
#! /usr/bin/env python3
|
|
||||||
# -*- coding: UTF-8 -*-
|
|
||||||
|
|
||||||
csv_reader1 = csv.reader(open('./RawDataFiles/RawData1.csv')) #Ouvre le fichier .csv
|
for i in range(1, 10):
|
||||||
bigx = float(-sys.maxsize-1)
|
rawdata = 'Code-C/RawDataFiles/RawData' + str(i) + '.csv' #Définit le fichier à ouvrir
|
||||||
bigy = float(-sys.maxsize-1)
|
|
||||||
smallx = float(sys.maxsize)
|
|
||||||
smally = float(sys.maxsize)
|
|
||||||
capteurs = []
|
|
||||||
|
|
||||||
for ligne in csv_reader1:
|
with open(rawdata, newline='') as csvfile:
|
||||||
capteurs.append(ligne)
|
reader = csv.reader(csvfile, quoting=csv.QUOTE_NONNUMERIC)
|
||||||
if float(ligne[0]) > bigx:
|
x = [row for row in reader]
|
||||||
bigx = float(ligne[0])
|
int_x = np.array(x, int)
|
||||||
if float(ligne[1]) > bigy:
|
|
||||||
bigy = float(ligne[1])
|
|
||||||
if float(ligne[0]) < smallx:
|
|
||||||
smallx = float(ligne[0])
|
|
||||||
if float(ligne[1]) < smally:
|
|
||||||
smally = float(ligne[1])
|
|
||||||
|
|
||||||
capteurs.sort()
|
for j in range(1,len(int_x[0])):
|
||||||
x_arr = []
|
aver = average(int_x[:,j])
|
||||||
y_arr = []
|
print("I = " , i ," J = " ,j ," aver = " , aver , '\0')
|
||||||
|
|
||||||
for capteur in capteurs:
|
|
||||||
x_arr.append(capteur[0])
|
|
||||||
y_arr.append(capteur[1])
|
|
||||||
|
|
||||||
fig1 = plt.figure(1, figsize = (5.91, 2.758))
|
def average(x):
|
||||||
fig2 = plt.figure(1, figsize = (5.91, 2.758))
|
res = 0
|
||||||
fig3 = plt.figure(1, figsize = (5.91, 2.758))
|
for i in range(len(x)):
|
||||||
fig4 = plt.figure(1, figsize = (5.91, 2.758))
|
res += x[i]
|
||||||
fig5 = plt.figure(1, figsize = (5.91, 2.758))
|
return res / len(x)
|
||||||
fig6 = plt.figure(1, figsize = (5.91, 2.758))
|
|
||||||
fig7 = plt.figure(1, figsize = (5.91, 2.758))
|
|
||||||
fig8 = plt.figure(1, figsize = (5.91, 2.758))
|
|
||||||
fig9 = plt.figure(1, figsize = (5.91, 2.758))
|
|
||||||
fig10 = plt.figure(1, figsize = (5.91, 2.758))
|
|
||||||
|
|
||||||
fig1.xlabel('Temps')
|
|
||||||
fig1.ylabel('Tension')
|
|
||||||
fig1.title("Données tableau 1")
|
|
||||||
fig1.plot(x_arr, y_arr, 'r')
|
|
||||||
|
|
||||||
#fig, (ax1) = plt.subplots(2, 1)
|
function()
|
||||||
|
|
||||||
# Fe = 250000 #Fréquence d'échantillonage
|
|
||||||
# tstep = 1 / Fe
|
|
||||||
# y = capteur[:][0]
|
|
||||||
# y2 = capteur[:][0]
|
|
||||||
# N = len(y)
|
|
||||||
# t = np.linspace(0, (N-1) * tstep, N)
|
|
||||||
|
|
||||||
#Légende des plot 1, 2, 3, 4, 5, 6, 7 et 8
|
|
||||||
# ax1.set_xlabel('Temps')
|
|
||||||
# ax1.set_ylabel('Tension')
|
|
||||||
# ax1.set_title("Données du premier capteur")
|
|
||||||
# ax1.plot(t, y)
|
|
||||||
|
|
||||||
# ax2.set_xlabel('Temps')
|
|
||||||
# ax2.set_ylabel('Tension')
|
|
||||||
# ax2.set_title("Données du deuxième capteur")
|
|
||||||
# ax2.plot(t, y2)
|
|
||||||
|
|
||||||
# ax3.set_xlabel('Temps')
|
|
||||||
# ax3.set_ylabel('Tension')
|
|
||||||
# ax3.set_title("Données du troisième capteur")
|
|
||||||
# ax3.plot(t, y3)
|
|
||||||
|
|
||||||
# ax4.set_xlabel('Temps')
|
|
||||||
# ax4.set_ylabel('Tension')
|
|
||||||
# ax4.set_title("Données du quatrième capteur")
|
|
||||||
# ax4.plot(t, y4)
|
|
||||||
|
|
||||||
# ax5.set_xlabel('Temps')
|
|
||||||
# ax5.set_ylabel('Tension')
|
|
||||||
# ax5.set_title("Données du cinquième capteur")
|
|
||||||
# ax5.plot(t, y5)
|
|
||||||
|
|
||||||
# ax6.set_xlabel('Temps')
|
|
||||||
# ax6.set_ylabel('Tension')
|
|
||||||
# ax6.set_title("Données du sixième capteur")
|
|
||||||
# ax6.plot(t, y6)
|
|
||||||
|
|
||||||
# ax7.set_xlabel('Temps')
|
|
||||||
# ax7.set_ylabel('Tension')
|
|
||||||
# ax7.set_title("Données du septième capteur")
|
|
||||||
# ax7.plot(t, y7)
|
|
||||||
|
|
||||||
# ax8.set_xlabel('Temps')
|
|
||||||
# ax8.set_ylabel('Tension')
|
|
||||||
# ax8.set_title("Données du huitième capteur")
|
|
||||||
# ax8.plot(t, y8)
|
|
||||||
|
|
||||||
plt.show() #Affiche le tableau à l'écran
|
|
||||||
|
|
Loading…
Reference in a new issue