Changeset 169

Show
Ignore:
Timestamp:
01/24/08 00:33:58 (1 year ago)
Author:
vud1
Message:

"heart rate beta graph "

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pytrainer/trunk/pytrainer/gui/drawArea.py

    r148 r169  
    2323from matplotlib.backends.backend_gtk import FigureCanvasGTK, NavigationToolbar 
    2424from matplotlib.numerix import * 
     25from pylab import * 
    2526 
    2627class DrawArea: 
     
    3233                self.drawDefault() 
    3334 
    34         def stadistics(self,type,xvalues,yvalues,xlabel,ylabel,title,color): 
     35        def stadistics(self,type,xvalues,yvalues,xlabel,ylabel,title,color,zones=None): 
    3536                if len(xvalues[0]) < 1: 
    3637                        self.drawDefault() 
     
    3940                        self.drawBars(xvalues,yvalues,xlabel,ylabel,title,color) 
    4041                elif type == "plot": 
    41                         self.drawPlot(xvalues,yvalues,xlabel,ylabel,title,color
     42                        self.drawPlot(xvalues,yvalues,xlabel,ylabel,title,color,zones
    4243 
    4344        def drawBars(self,xvalues,yvalues,xlabel,ylabel,title,color): 
     
    5859                 
    5960                        p1 = self.axis.bar(xvalues[i], yvalues[i], width, color=color[i]) 
    60                  
     61                p = axvspan(1.25, 100.55, facecolor='g', alpha=0.5) 
    6162                self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea 
    6263                self.canvas.show() 
    6364                self.vbox.pack_start(self.canvas, True, True) 
    6465 
    65         def drawPlot(self,xvalues,yvalues,xlabel,ylabel,title,color): 
     66        def drawPlot(self,xvalues,yvalues,xlabel,ylabel,title,color,zones=None): 
    6667                self.canvas.destroy() 
    6768                self.figure = Figure(figsize=(6,4), dpi=72) 
    6869                self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea 
    6970                self.axis.clear() 
    70                 for i in range(0,len(xvalues)): 
     71                i = 0 
     72                for value in xvalues: 
    7173                        if len(xvalues) == 1: 
    7274                                self.axis = self.figure.add_subplot(111) 
     
    7880                        self.axis.grid(True) 
    7981                        self.axis.plot(xvalues[i],yvalues[i], color=color[i]) 
    80                          
     82                        i+=1 
     83                if zones!=None:  
     84                        for zone in zones:       
     85                                p = self.axis.axhspan(zone[0], zone[1], facecolor=zone[2], alpha=0.5, label=zone[3]) 
     86                l = self.axis.legend(loc='lower right') 
    8187                self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea 
    8288                self.canvas.show() 
  • pytrainer/trunk/pytrainer/heartrategraph.py

    r153 r169  
    1818 
    1919from gui.drawArea import DrawArea 
     20from lib.system import checkConf 
     21from lib.xmlUtils import XMLParser 
    2022 
    2123class HeartRateGraph: 
    2224        def __init__(self, vbox = None): 
    2325                self.drawarea = DrawArea(vbox) 
     26                self.conf = checkConf() 
     27                self.filename = self.conf.getValue("conffile") 
     28                self.configuration = XMLParser(self.filename) 
    2429 
    2530        def drawgraph(self,values): 
     31                maxhr = int(self.configuration.getValue("pytraining","prf_maxhr")) 
     32                resthr = int(self.configuration.getValue("pytraining","prf_minhr")) 
     33                if self.configuration.getValue("pytraining","prf_hrzones_karvonen")=="True": 
     34                        #if karvonen method 
     35                        targethr1 = ((maxhr - resthr) * 0.50) + resthr 
     36                        targethr2 = ((maxhr - resthr) * 0.60) + resthr 
     37                        targethr3 = ((maxhr - resthr) * 0.70) + resthr 
     38                        targethr4 = ((maxhr - resthr) * 0.80) + resthr 
     39                        targethr5 = ((maxhr - resthr) * 0.90) + resthr 
     40                        targethr6 = maxhr 
     41                else: 
     42                        #if not karvonen method 
     43                        targethr1 = maxhr * 0.50 
     44                        targethr2 = maxhr * 0.60 
     45                        targethr3 = maxhr * 0.70 
     46                        targethr4 = maxhr * 0.80 
     47                        targethr5 = maxhr * 0.90 
     48                        targethr6 = maxhr 
     49                 
     50                zone1 = (targethr1,targethr2,"#ffff99","Moderate activity") 
     51                zone2 = (targethr2,targethr3,"#ffcc00","Weight Control") 
     52                zone3 = (targethr3,targethr4,"#ff9900","Aerobic") 
     53                zone4 = (targethr4,targethr5,"#ff6600","Anaerobic") 
     54                zone5 = (targethr5,targethr6,"#ff0000","VO2 MAX") 
     55                 
     56                zones = [zone5,zone4,zone3,zone2,zone1] 
     57         
    2658                value_selected = -1 
    2759                if value_selected < 0: 
     
    3062                        xvalues, yvalues = self.get_values(values,value_selected) 
    3163                        xlabel,ylabel,title,color = self.get_value_params(value_selected) 
    32                         self.drawarea.stadistics("plot",[xvalues],[yvalues],[xlabel],[ylabel],[title],[color]
     64                        self.drawarea.stadistics("plot",[xvalues],[yvalues],[xlabel],[ylabel],[title],[color],zones
    3365 
    3466        def get_value_params(self,value): 
  • pytrainer/trunk/pytrainer/profile.py

    r160 r169  
    3030                self.conf = checkConf() 
    3131                self.filename = self.conf.getValue("conffile") 
     32                self.configuration = XMLParser(self.filename) 
    3233 
    3334        def isProfileConfigured(self):