Commit c307a599 authored by Philippe Després's avatar Philippe Després

new

parents
Pipeline #316 failed with stages
LabVIEW Measurement
Writer_Version 2
Reader_Version 2
Separator Tab
Decimal_Separator .
Multi_Headings No
X_Columns No
Time_Pref Absolute
Operator phdes19
Description Lab1
Date 2017/01/17
Time 10:29:25.3080300833532626614
***End_of_Header***
Channels 1
Samples 10
Date 2017/01/17
Time 10:29:25.3080300833532626614
Y_Unit_Label Volts
X_Dimension Time
X0 0.0000000000000000E+0
Delta_X 0.100000
***End_of_Header***
X_Value Voltage Comment
4.588001513452368
4.236253004617207
4.681448165655915
4.375001736901455
4.279830038559405
4.513075123238851
4.684843368734313
4.369175154688901
4.693827712829139
4.596214096652724
4.660023650346688
4.559013344494868
4.422503548920769
4.39227415855849
4.531575369380083
4.260787502983274
4.532466337562645
4.382674387387075
4.845387798005393
4.359768726023524
4.680857486491775
4.864829727335986
4.524446392414663
4.714391933954503
4.694503207301663
4.6784935484169745
4.476037597475838
4.5237927145295584
4.716325615888866
4.652534237213917
4.388321812735378
4.633481371664937
4.29626562758133
4.545818352689168
4.696164704075326
4.166751720192279
4.602794459510299
4.290278302817858
4.5784987233639205
4.793716922420535
4.320778270130845
4.426101187785696
4.640355250187776
4.339106294399874
4.610398638574211
4.4241071296662415
4.450433116717915
4.431271399098203
4.55360200850291
4.427998474858142
4.1370853723107865
4.2798915396050505
4.217525488462503
4.570648166479544
4.868464245325898
4.894111551780929
4.51784965773334
3.93661462444895
4.571588191476581
4.416322794173004
4.627061173263287
4.3798861919591445
4.558167927524022
4.872443257009836
4.398252443888782
4.413125133299139
4.321877530106297
4.50268758028171
4.53523002236481
4.542544724811586
4.397249378542398
4.569052531088091
4.712501798810399
4.118162519311418
4.155395690964026
4.5989838190095975
4.09143227224598
4.46138625447448
4.664471685284572
5.08141867812211
4.350680996528124
4.536486848593545
4.463045939026494
4.54556078398931
4.51404183259687
4.311002915808056
4.898110470747267
4.535753013446112
4.336206556280405
4.443652892736065
4.561892484520395
4.490027332807389
4.300110848751689
4.403017384494488
4.388119856677487
4.358546342218127
4.435311722395388
4.512109647378704
4.507834400486863
4.347525671589978
4.679492923104492
4.465503158446396
4.581514117843893
4.810543001361084
4.159297251283579
4.508375985628196
4.444792761026084
4.733097162476032
4.574451417040172
4.690980811869233
4.593748628000691
4.472435115748715
4.523755013451532
4.652757870659911
4.734847924668076
4.71307760135384
4.581349099110422
4.602341190711225
4.384398023264271
4.691844699008675
4.566912574037595
4.5624747687410485
4.20261144535426
4.38326497908622
4.134462435489458
4.589309566476205
4.220915458043681
4.297746660909357
4.144944278621677
4.318517623371778
4.964371525190561
4.706411256716195
4.772915941535235
4.283034322012294
4.4252328238214895
4.479485400182029
4.5545467025569355
4.356278565944821
4.4558459420081125
4.639992038187532
4.284666922631296
4.8868731839443065
4.476333746071471
4.1562247392622425
4.786497400829684
4.511142455836909
4.569017847869591
4.518205363076911
4.614112915535395
4.653200188852456
4.5530452511621125
4.351554259200262
4.221037739753927
4.5239110544643
4.476347515464328
4.220639491123048
4.292253131784945
4.407100164399649
4.136651365485504
4.3956078382243335
4.288384091691677
4.018279127448117
4.527640600036118
4.510278934487476
4.490742469554024
4.277017031234176
4.340833910885989
4.750253554349718
4.239000415343268
4.680505005969743
4.664918072919928
4.411143171700292
4.644491023078291
4.632102393128175
4.783638315948799
4.26889411014708
4.323285369210584
4.163966775187241
4.690918617426431
4.25605137078579
4.344876791773041
4.589057114705643
4.8092088515064395
4.468863316667217
4.509039476287767
4.696711588604805
4.547998518214662
4.433704392745976
4.6115422630427725
4.294534770207
4.858933720968877
4.296696297235947
4.29821811934272
4.3320902773973655
4.413640917813636
4.633521486660511
4.605966503193769
4.208240212016791
4.194771833438793
4.470282815577818
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exemple de production d'un graphique avec Matplotlib"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Génération de données"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"f = open('random_data.txt', 'w')\n",
"\n",
"for i in range(200):\n",
" f.write('\\t'+str(np.random.normal(4.5,0.2))+'\\n')\n",
"\n",
"f.close()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
# programme qui prend un fichier LVM
# en argument et qui en fait un histogramme
# (une seule colonne de mesures)
import matplotlib.pyplot as plt #matplotlib
import numpy as np #numpy
import sys #système et fichiers
from scipy.stats import norm #pour distribution normale
#vérification si l'usager a passé un argument au programme
if(len(sys.argv)!=2):
print("Usage: "+sys.argv[0]+" [fichier]")
sys.exit()
#ouverture du fichier passé en argument (structure LVM)
with open(sys.argv[1],'r') as f:
for line in f:
val=line.strip().split() #enlève les espaces avant/après et tokenize
if not val: #saute lignes vide
continue
if(val[0]=="Y_Unit_Label"):
xtitle=val[1] #récupère les unités
if(val[0]=="X_Value"): #on commence à lire les valeurs
nb_mesures=0
x=[]
for line_tmp in f:
x.append(float(line_tmp.replace(",",".").strip())) #liste de valeur
nb_mesures+=1
f.close() #fermeture fichier
#création array numpy
volts=np.array(x)
print(str(nb_mesures)+" mesures lues")
#fit distribution normale
mu,std=norm.fit(volts)
# axes des x pour fit
xlin = np.linspace(volts.min(),volts.max(), 100)
#courbe distribution normale
p = norm.pdf(xlin, mu, std)
#histogram
n, bins, patches = plt.hist(volts, 20, range=[volts.min(),volts.max()], normed=1, facecolor='green', alpha=0.75)
#graph distribution normale
plt.plot(xlin, p, 'k', linewidth=2, label=r"$\mu$: "+str("{:.2f}".format(mu))+r" $\sigma$: "+str("{:.2f}".format(std)))
plt.xlabel(xtitle)
plt.ylabel('Fréquence')
plt.title(str(nb_mesures)+" mesures")
plt.legend()
plt.grid(True)
plt.show()
#time series
plt.figure()
xtime=np.linspace(1,nb_mesures,nb_mesures)
plt.plot(xtime,volts)
plt.ylabel(xtitle)
plt.xlabel("no. mesure")
plt.show()
Markdown is supported
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