2012_09_12_graph_dpg109
Tracer le graphique à partir des fichiers .log
2012_09_12_graph_dpg109.py
—
Python Source,
2 ko (2428 bytes)
Contenu du fichier
#! /usr/bin/env python
# -*- coding:UTF-8 -*-
############################################
# Programme graph_dpg109.py
# Lambert Gregory
# 04.05.2011
# Ce programme cree le graphique des valeurs
# obtenues avec dpg109.py
############################################
# cd Documents/00_Observatoire/01_Silla/01_T4_Euler/20_Pompage/2012/Pompage_EulerCam/00graphPression/
titregraph = 'Pompage EulerCam septembre 2012'
fichierlog = 'DPG109_2012-09-11_07h46m19s.log'
fichierlog2 = 'DPG109_2012-09-12_07h57m31s.log'
fichierlog3 = 'DPG109_2012-07-15_07h33m53s.log'
label1jour = '11 sept'
label2jour = '12 sept'
label3jour = '13 sept'
# Importation de fonctions externes :
import matplotlib.pyplot as plt
from matplotlib import rc, rcParams # Ecriture LaTex
from pylab import *
# Def des fonctions
def graph(x1,y1,x2,y2,x3,y3):
rc('text',usetex=True) # Ecriture LaTex
rc('font',**{'family':'serif','serif':['Computer Modern']}) # Ecriture LaTex
# Parametre du Graphique
Xmin = 0
Xmax = max(len(x1),len(x2),len(x3))
Ymin = 0
Ymax = 0.0008
# Plot graph
plt.plot(x1,y1,label= label1jour)
plt.hold(True)
plt.plot(x2,y2,label= label2jour)
plt.hold(True)
plt.plot(x3,y3,label= label3jour)
plt.ylabel('Pression [mb]')
plt.xlabel("TUNIX")
plt.title(titregraph)
plt.axis([Xmin,Xmax,Ymin,Ymax])
plt.legend(loc='upper right')
plt.show()
return()
def traceGraph(source,source2,source3):
"Créer un graphique sans prendre en compte les lignes de remarques"
fs1 = open(source, 'r')
while 1:
txt = fs1.readline()
if txt == '':
break
if txt[0] != '#':
Y1.append(float(txt[13:45]))
fs2 = open(source2, 'r')
while 1:
txt = fs2.readline()
if txt == '':
break
if txt[0] != '#':
Y2.append(float(txt[13:45]))
fs3 = open(source3, 'r')
while 1:
txt = fs3.readline()
if txt == '':
break
if txt[0] != '#':
Y3.append(float(txt[13:45]))
axeX1 = linspace(1,len(Y1),len(Y1))
axeX2 = linspace(1,len(Y2),len(Y2))
axeX3 = linspace(1,len(Y3),len(Y3))
graph(axeX1,Y1,axeX2,Y2,axeX3,Y3)
fs1.close()
fs2.close()
fs3.close()
return
# Main
Y1 = []
Y2 = []
Y3 = []
traceGraph(fichierlog,fichierlog2,fichierlog3)
## Prochaine Mission :
# Tracer les trois jours sur le même graphique, avec des couleurs différentes
# idée -> au lieu du vecteur temps TUNIX, on pourrait créer un vecteur pour les trois graphs
# trouver qui est le plus long vecteur et créer x[] = length (max)
