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

quelques ajouts

parent 289444d0
......@@ -4,7 +4,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Visualisation et analyse de données"
"# Visualisation et analyse de données\n",
"\n",
"Notebook disponible à cette adresse\n",
"\n",
"https://gitlab.physmed.chudequebec.ca/pdespres/gph2006\n"
]
},
{
......@@ -13,7 +17,7 @@
"metadata": {},
"outputs": [],
"source": [
"import this"
"import this\n"
]
},
{
......@@ -36,13 +40,6 @@
"<iframe src=\"https://matplotlib.org/gallery.html\" width=\"800\" height=\"1200\"></iframe>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -203,7 +200,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Ici, on aurait un résultat de mesure avec incertitude de type A"
"Ici, on aurait un résultat de mesure avec incertitude de type A \n",
"$$\\sigma_\\bar{x} \\approx \\frac{\\sigma}{\\sqrt{n}}$$\n",
"\n",
"\n",
"(voir cours de Luc Beaulieu)"
]
},
{
......@@ -256,7 +257,7 @@
]
},
{
"cell_type": "markdown",
"cell_type": "raw",
"metadata": {},
"source": [
"LabVIEW Measurement \n",
......@@ -306,38 +307,73 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# programme qui prend un fichier LVM \n",
"# en argument et qui en fait un histogramme \n",
"# (une seule colonne de mesures) \n",
"\n",
"import matplotlib.pyplot as plt #matplotlib \n",
"import numpy as np #numpy \n",
"import sys #système et fichiers \n",
"from scipy.stats import norm #pour distribution normale \n",
"\n",
"import matplotlib.pyplot as plt #matplotlib\n",
"import numpy as np #numpy\n",
"from scipy.stats import norm #pour distribution normale\n",
" \n",
"file_in=\"Labo1_output.lvm\"\n",
"x=[] #liste vide\n",
"\n",
"#ouverture du fichier (structure LVM) \n",
"#ouverture du fichier passé en argument (structure LVM)\n",
"with open(file_in,'r') as f:\n",
" for line in f:\n",
" val=line.strip().split() #enlève les espaces avant/après et tokenize \n",
" if not val: #saute lignes vide \n",
" for line in f: \n",
" val=line.strip().split() #enlève les espaces avant/après et tokenize\n",
" if not val: #saute lignes vide\n",
" continue\n",
" if(val[0]==\"Y_Unit_Label\"):\n",
" xtitle=val[1] #récupère les unités \n",
" if(val[0]==\"X_Value\"): #on commence à lire les valeurs \n",
" nb_mesures=0\n",
" x=[]\n",
" xtitle=val[1] #récupère les unités\n",
" if(val[0]==\"X_Value\"): #on commence à lire les valeurs\n",
" \n",
" for line_tmp in f:\n",
" x.append(float(line_tmp.replace(\",\",\".\").strip())) #liste de valeur \n",
" nb_mesures+=1\n",
" x.append(float(line_tmp.replace(\",\",\".\").strip())) #liste de valeur\n",
" \n",
"f.close() #fermeture fichier "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#création array numpy\n",
"volts=np.array(x)\n",
"print(str(len(x))+\" mesures lues\")\n",
"\n",
"# deux graphiques côte à côte\n",
"f = plt.figure(figsize=(10,4))\n",
"fig1 = f.add_subplot(121)\n",
"fig2 = f.add_subplot(122)#time series\n",
"xtime=np.linspace(1,len(x),len(x))\n",
"fig1.plot(xtime,volts)\n",
"fig1.set_ylabel(xtitle)\n",
"fig1.set_xlabel(\"no. mesure\")\n",
"\n",
"#fit distribution normale\n",
"mu,std=norm.fit(volts)\n",
"# axes des x pour fit\n",
"xlin = np.linspace(volts.min(),volts.max(), 100)\n",
"#courbe distribution normale\n",
"p = norm.pdf(xlin, mu, std)\n",
" \n",
"#histogram\n",
"n, bins, patches = fig2.hist(volts, 20, range=[volts.min(),volts.max()], density=1, facecolor='green', alpha=0.75)\n",
"#graph distribution normale\n",
"fig2.plot(xlin, p, 'k', linewidth=2, label=r\"$\\mu$: \"+str(\"{:.2f}\".format(mu))+r\" $\\sigma$: \"+str(\"{:.2f}\".format(std)))\n",
"fig2.set_xlabel(xtitle)\n",
"fig2.set_ylabel('Fréquence')\n",
"fig2.set_title(str(len(x))+\" mesures\")\n",
"fig2.legend()\n",
"fig2.grid(True)\n",
"\n",
"#plt.tight_layout()\n",
"plt.show() "
]
},
{
"cell_type": "code",
"execution_count": null,
......
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