Commit 27554098 authored by Yassine's avatar Yassine
Browse files

update

parent 9bac6913
Time(s),y,y',"y"""
0.10999999999999999,0.0063779769373282814,0.10445153541852893,0.899207073735685
0.22000000000000006,0.023516297303618792,0.19676966985034672,0.7895775045904424
0.3300000000000001,0.05009165303736232,0.2771625342936138,0.6823408464767272
0.4400000000000002,0.08481069831164972,0.3459536316443378,0.5784800064247029
0.5500000000000003,0.12642178869988618,0.4035660409915061,0.47883619264497257
0.6600000000000004,0.1737250120826072,0.45050712986974606,0.3841140700468123
0.7700000000000005,0.22558057471700624,0.4873538971336623,0.2948879465865334
0.8800000000000006,0.28091561817061694,0.5147390490268334,0.2116088114068868
0.9900000000000007,0.3387295529445365,0.5333378918503417,0.13461205467032844
1.1000000000000008,0.398098002688836,0.5438561065145141,0.06412570895130815
1.2100000000000009,0.45817545906468055,0.5470184532821076,0.0002790628141746687
1.320000000000001,0.5181967516649536,0.543558439256806,-0.05688849144362784
1.430000000000001,0.5774774401055361,0.5342089666909943,-0.1074185021511318
1.5400000000000011,0.635413236585212,0.5196939670145013,-0.151424509019766
1.6500000000000012,0.6914785670283137,0.5007210136359738,-0.18908320255346234
1.7600000000000013,0.7452243775161723,0.4779748960386916,-0.2206257824186636
1.8700000000000014,0.7962752902254933,0.4521121284658566,-0.2463295933400922
1.9800000000000015,0.8443262096656008,0.42375635853645444,-0.2665101056734249
2.0899999999999994,0.8891384757796724,0.3934946344099406,-0.2815132968136501
2.199999999999997,0.9305356555800269,0.3618744835747229,-0.29170847911010367
2.3099999999999947,0.9683990595504894,0.3294017519119981,-0.2974816100438057
2.4199999999999924,1.0026630631890683,0.29653914831661476,-0.2992291111338554
2.52999999999999,1.033310307893306,0.2637054377687821,-0.297352213418586
2.6399999999999877,1.06036684901222,0.231275224269292,-0.2922518394331506
2.7499999999999853,1.083897312397841,0.19957926439862192,-0.2843240243964411
2.859999999999983,1.1040001142723588,0.16890525235758086,-0.273955872834711
2.9699999999999807,1.120802792761564,0.1394990181144868,-0.26152204110596555
3.0799999999999783,1.134457493100487,0.11156608164225998,-0.24738173123871132
3.189999999999976,1.1451366423533225,0.08527350810080404,-0.231876177144564
3.2999999999999736,1.1530288435587686,0.06075201113034081,-0.2153266005836424
3.4099999999999713,1.158335013557709,0.03809825409751558,-0.19803261122651472
3.519999999999969,1.161264783418745,0.01737730210903458,-0.1802710227340295
3.6299999999999666,1.1620331753771498,-0.0013748191879273575,-0.16229505493040586
3.7399999999999642,1.1608575655661615,-0.018148498624385972,-0.14433389083638315
3.849999999999962,1.1579549375613964,-0.032957885464395195,-0.12659255651681334
3.9599999999999596,1.1535394278889979,-0.04583823986273086,-0.10925209133827707
4.069999999999958,1.1478201611697518,-0.056843317827127385,-0.0924699762837331
4.179999999999955,1.1409993694838656,-0.06604281714990613,-0.07638078838935192
4.289999999999953,1.1332707878389936,-0.073519907302756,-0.06109705011036892
4.399999999999951,1.1248183152981521,-0.07936886291617963,-0.04671024344559016
4.509999999999948,1.1158149293617667,-0.08369281722014679,-0.033291959912950864
4.619999999999946,1.1064218395837737,-0.08660164872879648,-0.020895158931581115
4.729999999999944,1.0967878651175764,-0.08821001152935527,-0.00955550879142919
4.839999999999941,1.087049019913951,-0.08863551679949991,0.000707213856115052
4.949999999999939,1.077328288608424,-0.08799707064011549,0.009887688207364187
5.0599999999999365,1.0677355757177904,-0.08641337098017149,0.017993597527858007
5.169999999999934,1.0583678105912513,-0.08400156419239022,0.02504417975678286
5.279999999999932,1.0493091906075391,-0.08087606015466699,0.031068796914728303
5.3899999999999295,1.040631545351907,-0.07714750280228219,0.03610553780035586
5.499999999999927,1.0323948049225349,-0.07292189173688145,0.04019986656260377
5.609999999999925,1.024647556081884,-0.06829984918493416,0.04340332789010204
5.7199999999999225,1.0174276706625736,-0.06337602552401858,0.045772317784045224
5.82999999999992,1.0107629914380556,-0.05823863571136056,0.04736692718807212
5.939999999999918,1.0046720615553626,-0.05296911824580876,0.048249864149482846
6.0499999999999154,0.9991648845812781,-0.047641907761038965,0.04848545868904086
6.159999999999913,0.9942437032164095,-0.04232431197260219,0.048138753168148085
6.269999999999911,0.9899037857671791,-0.03707648347222145,0.04727467966699006
6.379999999999908,0.9861342105183831,-0.03195147676685853,0.04595732472808778
6.489999999999906,0.9829186392047989,-0.026995380984665016,0.04424928077779744
6.599999999999904,0.9802360718268831,-0.022247518802107954,0.04221108261333717
6.709999999999901,0.9780615760818107,-0.017740702373540296,0.039900726533327546
6.819999999999899,0.9763669856773061,-0.013501537353736166,0.03737326899282101
6.929999999999897,0.9751215627535785,-0.009550766483264821,0.034680501075609604
7.039999999999894,0.9742926205512082,-0.005903644644333688,0.03187069459260816
7.149999999999892,0.9738461033242625,-0.0025703377797435447,0.02898841522998341
7.25999999999989,0.9737471213037194,0.000443661410657223,0.026074397878515065
7.369999999999887,0.9739604392629764,0.003137107533001357,0.02316547907005284
7.479999999999885,0.9744509179224241,0.005512572292503049,0.02029458132120998
7.589999999999883,0.9751839080523419,0.007576015411435915,0.01749074413165308
7.69999999999988,0.9761255976921169,0.00933636148922708,0.014779196397523564
7.809999999999878,0.9772433133992734,0.010805087049383827,0.012181465072562236
7.919999999999876,0.9785057768748954,0.011995821456548575,0.009715515033456024
8.029999999999873,0.9798833186843188,0.012923964841954424,0.007395915274895359
8.139999999999871,0.9813480511055287,0.013606325651478878,0.00523402676717899
8.249999999999869,0.9828740023950583,0.014060779931202961,0.0032382075485360984
8.359999999999866,0.9844372149652776,0.014305953994024885,0.0014140308895330689
8.469999999999864,0.9860158101210094,0.014360931669950063,-0.0002354873477372621
8.579999999999862,0.9875900221108821,0.014244986934068202,-0.0017096557329390194
8.68999999999986,0.989142204313359,0.013977342331251036,-0.003009871940704567
8.799999999999857,0.9906568104027325,0.013576953276053636,-0.0041393880262884375
8.909999999999854,0.9921203533303343,0.013062318000491275,-0.005103078940222883
9.019999999999852,0.9935213449146314,0.012451312651174537,-0.005907216605347654
9.12999999999985,0.9948502187644983,0.01176105080021226,-0.006559251572432867
9.239999999999847,0.996099239166526,0.011007766430492125,-0.007067603972437553
9.349999999999845,0.9972623984533016,0.010206719284282254,-0.007441465196708075
9.459999999999843,0.998335305238651,0.009372121323177215,-0.0076906114632286915
9.56999999999984,0.999315065761158,0.008517082935638975,-0.007825230169131836
9.679999999999838,1.0002001604219524,0.007653577443994616,-0.007855759688391029
9.789999999999836,1.0009903174397121,0.006792422403850677,-0.007792743050024642
9.899999999999833,1.0016863853777211,0.005943276153480184,-0.0076466957269357705
10.009999999999831,1.0022902061271255,0.0051146480567799205,-0.007427987579128992
10.119999999999829,1.0028044897594943,0.0043139208887985605,-0.007146738827681687
10.229999999999826,1.0032326924923918,0.003547383835511621,-0.006812729787422422
10.339999999999824,1.0035788988456844,0.002820274617399931,-0.006435323956475059
10.449999999999822,1.003847708905334,0.002136829297445441,-0.006023403949298012
10.55999999999982,1.0040441314567092,0.0015003383964266323,-0.005585319665829869
10.669999999999817,1.0041734836022094,0.0009132080099857927,-0.0051288480122174684
10.779999999999815,1.0042412973390578,0.0003770247010527833,-0.00466116342737366
10.889999999999812,1.0042532334432712,-0.00010737697385294675,-0.0041888184233906944
10.99999999999981,1.0042150028855712,-0.0005398453567435696,-0.0037177333155506975
11.109999999999808,1.00413229589474,-0.0009208419590635635,-0.003253194298249662
11.219999999999805,1.0040107186838887,-0.0012513719783580558,-0.002799859015468753
11.329999999999803,1.0038557377653468,-0.00153291583413,-0.0023617687773314078
11.4399999999998,1.0036726317003863,-0.0017673624036379089,-0.0019423665866513673
11.549999999999798,1.0034664500605681,-0.0019569445475857727,-0.0015445201600587932
11.659999999999796,1.0032419793179306,-0.002104177427574627,-0.0011705491561935233
11.769999999999794,1.0030037153311377,-0.0022118000325503564,-0.0008222558574877414
11.879999999999791,1.0027558420536853,-0.00228272025090604,-0.0005009585912003622
11.989999999999789,1.0025022160578372,-0.002319963748883038,-0.00020752721862926649
12.099999999999786,1.0022463564435988,-0.0023266268448579033,5.757993213184598e-05
12.209999999999784,1.0019914396851801,-0.002305833503302387,0.0002942782657466836
12.319999999999782,1.0017402989574553,-0.0022606965118664502,0.0005028187770632631
12.42999999999978,1.0014954274812784,-0.0021942828502829665,0.0006837500409107022
12.539999999999777,1.0012589854285652,-0.0021095832106704225,0.0008378807575741831
12.649999999999775,1.0010328099351447,-0.002009485585295405,0.000966243226563579
12.759999999999772,1.00081842778096,-0.0018967527998602156,0.001070058071617641
12.86999999999977,1.000617070312616,-0.0017740038377651065,0.0011507004916884167
12.979999999999768,1.0004296902019474,-0.0016436987733690408,0.0012096682663513825
13.089999999999765,1.0002569796557113,-0.0015081271098107492,0.0012485517000013768
13.199999999999763,1.00009938971509,-0.0013693992991924164,0.001269005647586141
13.30999999999976,0.9999571503089718,-0.0012294412095824512,0.0012727237257725843
13.419999999999758,0.9998302907514858,-0.001089991294054613,0.00126141477740227
13.529999999999756,0.9997186604015447,-0.0009526002115229469,0.0012367816241040108
13.639999999999754,0.9996219492298289,-0.0008186326471244196,0.0012005021119436687
13.749999999999751,0.9995397080663558,-0.000689271081003878,0.0011542124281191946
13.859999999999749,0.99947136832919,-0.0005655212582326382,0.0010994926428892215
13.969999999999747,0.9994162610616979,-0.0004482191189062264,0.0010378544101203868
14.079999999999744,0.999373635131762,-0.00033803895589179246,0.0009707307419907218
14.189999999999742,0.9993426744713516,-0.00023550257791308437,0.0008994677583659128
14.29999999999974,0.9993225142586143,-0.0001409892673658903,0.0008253182990687336
14.409999999999737,0.9993122559670489,-5.4746335158960055e-05,0.0007494372775338487
14.519999999999735,0.9993109812272516,2.309991129899651e-05,0.0006728786470326931
14.629999999999733,0.9993177644660848,9.253295635205431e-05,0.000596593845582527
14.73999999999973,0.9993316843058602,0.00015363477505090528,0.0005214315826660432
14.849999999999728,0.9993518337222106,0.0002065745821297942,0.00044813882977867703
14.959999999999726,0.9993773289737409,0.0002515977551716768,0.0003773628774133009
import csv
valeurs =[]
with open('test_valeurs.csv', newline='') as csvfile:
spamreader = csv.reader(csvfile, delimiter=',', quotechar='|')
for row in spamreader:
valeurs.append(row)
print(valeurs)
for i in valeurs:
if i[-1] is not int:
i[1] = i[1] + i[2]
i.remove(2)
print(valeurs)
import csv
import matplotlib.pyplot as plt
import os
#Constructeur
def create_time_series(filename):
time_series = {
"data" : [],
"labels" : None
}
with open(filename, newline='',encoding='utf8') as csvfile:
spamreader = csv.reader(csvfile)
for row in spamreader:
time_series["data"].append(row)
time_series["labels"] = time_series["data"].pop(0)
swap_column(time_series)
for i in time_series["data"]:
x = list(i[0])
for j in range(len(x)):
if x[j]==",":
x[j]="."
x = ''.join(x)
i[0] = x
plot(time_series,filename)
return time_series
#Accesseurs
def get_date(t_s):
return t_s["date"]
def get_labels(t_s):
return t_s["labels"]
#Mutateurs
def set_date(t_s,date):
t_s["date"] = date
return
def set_labels(t_s,labels):
t_s["labels"] = labels
return
def swap_column(ts):
for i in ts["data"]:
i.insert(0,i.pop(len(i)-1))
def plot(ts,filename):
nb_curves=len(ts['data'][0])-1
#initiation columns list
columns=[[] for x in range(nb_curves+1)]
#fill columns
for i in range(0,len(ts['data'])):
columns[0].append(float(ts['data'][i][0])) #timestamp
for j in range(nb_curves) :
columns[j+1].append(float(ts['data'][i][j+1])) #y values
fig, ax = plt.subplots()
for i in range(nb_curves):
ax.plot(columns[0], columns[1+i], label=ts['labels'][i+1])
plt.xlabel('temps(s)')
plt.ylabel('position(mm)')
ax.legend()
plt.show()
fig.savefig(filename+".png")
def get_files(mypath):
f = os.listdir(mypath)
return f
if __name__ == '__main__':
files = get_files("./resultats")
for i in files:
create_time_series("./resultats"+i)
0.1,80
0.2,84
0.3,78
0.4,116
0.5,196
0.6,260
0.7,304
0.8,286
0.9,254
0.10,224
0.11,210
0.12,208
0.13,236
0.14,250
0.15,252
0.16,248
0.17,250
0.18,240
0.19,246
0.20,244
0.21,250
0.22,244
0.23,234
0.24,244
0.25,254
0.26,250
0.27,250
0.28,246
0.29,244
0.30,234
0.31,246
0.32,248
0.33,246
0.34,246
0.35,248
0.36,244
0.37,240
0.38,250
0.39,250
80,0.1
84,0.2
78,0.3
116,0.4
196,0.5
260,0.6
304,0.7
286,0.8
254,0.9
224,0.10
210,0.11
208,0.12
236,0.13
250,0.14
252,0.15
248,0.16
250,0.17
240,0.18
246,0.19
244,0.20
250,0.21
244,0.22
234,0.23
244,0.24
254,0.25
250,0.26
250,0.27
246,0.28
244,0.29
234,0.30
246,0.31
248,0.32
246,0.33
246,0.34
248,0.35
244,0.36
240,0.37
250,0.38
250,0.39
#####################
# #
# TimeSeries.py #
# 05/2022 #
# ENIB/ZG2 #
# G. desmeulles #
# #
#####################
import csv
import matplotlib.pyplot as plt
#constructor
def create(filename=None,time_stamp_column_number=0):
ts={'data':[],'labels':[]}
if filename!=None:
with open(filename, newline='') as csvfile:
spamreader = csv.reader(csvfile, delimiter=',', quotechar='"')
for row in spamreader:
ts['data'].append(row)
ts['labels']=ts['data'].pop(0)
if time_stamp_column_number:
swap_column(ts,0,time_stamp_column_number)
ts['xlabel']=ts['labels'][0]
return ts
#accessor/mutators
def get_data(ts): return ts['data'][:]
def get_labels(ts): return ts['labels'][:]
def set_data(ts,data): ts['data']=data
def set_labels(ts,labels): ts['labels']=labels
#operations
def swap_column(ts,n1,n2):
for row in ts['data']:
row.insert(n1,row.pop(n2))
ts['labels'].insert(n1,ts['labels'].pop(n2))
def plot(ts,x_label=None,y_label="",title="",filename=None):
if x_label==None:
x_label=ts['labels'][0]
nb_columns=len(ts['data'][0])
columns=[[] for x in range(nb_columns)]
for i in range(0,len(ts['data'])):
for j in range(nb_columns) :
columns[j].append(float(ts['data'][i][j]))
fig, ax = plt.subplots()
for i in range(nb_columns-1):
ax.plot(columns[0], columns[i+1], label=ts['labels'][i+1])
ax.set(xlabel=x_label, ylabel=y_label, title=title)
ax.legend()
plt.show()
if filename:
fig.savefig(filename)
#Nouvelle fonction
def dump(ts,filename):
with open(filename, 'w', newline='') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=',',)
spamwriter.writerow(ts['labels'])
for line in ts['data']:
output = []
for val in line:
output.append(str(val))
spamwriter.writerow(output)
if __name__=='__main__':
print('test TimeSeries.py')
ts = create('test_valeurs.csv',1)
print(ts)
plot(ts,y_label='distance(mm)',title='Courbe ZG2!!',filename='test.png')
dump(ts,'test.csv')
80
84
78
116
196
260
304
286
254
224
210
208
236
250
252
248
250
240
246
244
250
244
234
244
254
250
250
246
244
234
246
248
246
246
248
244
240
250
250
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment