def _generate_graphical_summary_report(self, metrics, page, avg_png_file,
                                           labels):
        """
        Generate the graph of average time taken for each instance type.
        """
        avg_png_fpath = path.join(self.reports_dir, avg_png_file)
        avg_graph_data = {}
        for instance_type_id, graph_data in metrics.iteritems():
            instance_type_name = instance_type_id_name_map[instance_type_id]
            key = "%s" % instance_type_name
            avg_graph_data[key] = graph_data['avg']

        cairoplot.dot_line_plot(
                    avg_png_fpath,
                    avg_graph_data,
                    self.IMG_WIDTH,
                    self.IMG_HEIGHT,
                    axis=True,
                    series_legend=True,
                    y_title="Time in ms",
                    x_title="Average API Response Time Summary - Per "\
                            "instance type",
                    x_labels=labels)
        page.img(src=avg_png_file, alt="Instance Type Summary report")
        page.br()
Exemple #2
0
	def MakeGraph(self, Data, FileName):
		"""
		Funzione che produce un grafico temporale.

		:param Data: Serie di dati da dover graficare.
		:param FileName: Nome file da assegnare al grafico prodotto.
		:returns: *nulla*

		"""
		global Interval,TimeStep

		Markers=[]
		FileName = 'extra/MonitorGraph/'+FileName

		for x in range((TimeStep-1)*Interval,-1,-Interval): Markers.append(str(x))

		#ogni volta cerca di acquisire il lock per creare una nuova immagine, se non riesce, rompe il lock
		TempLock = FileLock(FileName)
		try:
			TempLock.acquire(timeout=Interval)
		except LockTimeout:
			TempLock.break_lock()
		else:
			cairoplot.dot_line_plot(FileName, dict(zip(self.ProbeList,Data[:])), 
600, 200, axis=True, grid=True, series_legend=False, x_labels=Markers, series_colors=self.Colors)
			TempLock.release()
    def _generate_graphical_summary_report(self, metrics, page, avg_png_file,
        labels):
        """
        Generate the graph of average time taken for each instance type.
        """
        avg_png_fpath = path.join(self.reports_dir, avg_png_file)
        avg_graph_data = {}
        for instance_type_id, graph_data in metrics.iteritems():
            instance_type_name = instance_type_id_name_map[instance_type_id]
            key = "%s" % instance_type_name
            avg_graph_data[key] = graph_data['avg']

        cairoplot.dot_line_plot(
                    avg_png_fpath,
                    avg_graph_data,
                    self.IMG_WIDTH,
                    self.IMG_HEIGHT,
                    axis=True,
                    series_legend=True,
                    y_title="Time in ms",
                    x_title="Average API Response Time Summary - Per "\
                            "instance type",
                    x_labels=labels)
        page.img(src=avg_png_file, alt="Instance Type Summary report")
        page.br()
Exemple #4
0
        def createGraph(self, filename):
            if self.getNumSamples() < 5:
                self.logging.debug("Not enough samples to create %s graph" % filename)
                return
            else:
                self.logging.debug("Updating %s graph" % filename)

            if self.calibrated:
                y_bounds = (-4, 4)
                y_title = "Acceleration (g)"
            else:
                y_bounds = None
                y_title = "ADC Counts"

            data = {}
            for axis in ["x", "y", "z"]:
                index = min(len(getattr(self, axis)), SensorList.max_graph_data)
                data[axis] = getattr(self, axis)[-index:]

            cairoplot.dot_line_plot(
                name=filename,
                data=data,
                width=900,
                height=900,
                border=3,
                axis=True,
                grid=True,
                series_legend=True,
                x_labels=self.time,
                x_title="Time (minutes:seconds)",
                y_bounds=y_bounds,
                y_title=y_title,
            )
Exemple #5
0
def websiteVisit(confId): 
    '''
    confId : A conference Id
    A graph of last week website visit
    '''
    listOfVisits = [1,2,3,4,2,3,2,14,2,2,422,4,2,2,14,1,41,41,24,42,41,41]
    # Get list of visits from an API
    cairoplot.dot_line_plot('weekVisit.png', listOfVisits[-7:], 1000, 700, axis=True, dots=True, border = 50, x_title="Number of days", y_title="Number of Visits",series_colors =[(1.0,0.0,0.0)])
    def _generate_graph_from_metrics(self, csv_fname, page):
        """
        Generate a line graph (png file) from the available metrics.
        """
        fname_name_ext = list(path.splitext(path.basename(csv_fname)))
        avg_png_file = fname_name_ext[0] + '_average.png'

        labels, metrics = self._fetch_metrics(csv_fname)
        if 'request_count' in metrics:
            #generate ungrouped report.
            png_file = fname_name_ext[0] + '.png'
            png_fpath = path.join(self.reports_dir, png_file)
            instance_count = metrics.pop('request_count')
            alt_text = "Service Level Summary Report"
            cairoplot.dot_line_plot(
                png_fpath,
                metrics,
                self.IMG_WIDTH,
                self.IMG_HEIGHT,
                axis=True,
                series_legend=True,
                y_title="Time in ms",
                x_title="Response Time Trend - Across services",
                x_labels=labels)
            page.img(src=png_file, alt=alt_text)
            page.br()
        else:
            png_file = fname_name_ext[0] + '_%s.png'
            png_fpath = path.join(self.reports_dir, png_file)
            #generate reports grouped by instance_type.
            #generate graph for average time taken for each instance type.
            self._generate_graphical_summary_report(metrics, page,
                                                    avg_png_file, labels)

            #generate summary csvs.
            self._generate_tabular_summary_report(metrics, page, labels)

            #generate the min-avg-max graph for each instance type.
            for instance_type, graph_data in metrics.iteritems():
                instance_count = graph_data.pop('request_count')
                instance_type_name = instance_type_id_name_map[instance_type]
                alt_text = "Instance type '%s' summary report" % \
                           instance_type_name
                cairoplot.dot_line_plot(
                            png_fpath % instance_type,
                            graph_data,
                            self.IMG_WIDTH,
                            self.IMG_HEIGHT,
                            axis=True,
                            series_legend=True,
                            y_title="Time in ms",
                            x_title="Response Time Trend (For Instance Type: "\
                                    "%(instance_type_name)s, Instance Count: "\
                                    "%(instance_count)s)" % locals(),
                            x_labels=labels)
                page.img(src=png_file % instance_type, alt=alt_text)
                page.br()
    def _generate_graph_from_metrics(self, csv_fname, page):
        """
        Generate a line graph (png file) from the available metrics.
        """
        fname_name_ext = list(path.splitext(path.basename(csv_fname)))
        avg_png_file = fname_name_ext[0] + '_average.png'

        labels, metrics = self._fetch_metrics(csv_fname)
        if 'request_count' in metrics:
            #generate ungrouped report.
            png_file = fname_name_ext[0] + '.png'
            png_fpath = path.join(self.reports_dir, png_file)
            instance_count = metrics.pop('request_count')
            alt_text = "Service Level Summary Report"
            cairoplot.dot_line_plot(
                        png_fpath,
                        metrics,
                        self.IMG_WIDTH,
                        self.IMG_HEIGHT,
                        axis=True,
                        series_legend=True,
                        y_title="Time in ms",
                        x_title="Response Time Trend - Across services",
                        x_labels=labels)
            page.img(src=png_file, alt=alt_text)
            page.br()
        else:
            png_file = fname_name_ext[0] + '_%s.png'
            png_fpath = path.join(self.reports_dir, png_file)
            #generate reports grouped by instance_type.
            #generate graph for average time taken for each instance type.
            self._generate_graphical_summary_report(metrics, page,
                    avg_png_file, labels)

            #generate summary csvs.
            self._generate_tabular_summary_report(metrics, page, labels)

            #generate the min-avg-max graph for each instance type.
            for instance_type, graph_data in metrics.iteritems():
                instance_count = graph_data.pop('request_count')
                instance_type_name = instance_type_id_name_map[instance_type]
                alt_text = "Instance type '%s' summary report" % \
                           instance_type_name
                cairoplot.dot_line_plot(
                            png_fpath % instance_type,
                            graph_data,
                            self.IMG_WIDTH,
                            self.IMG_HEIGHT,
                            axis=True,
                            series_legend=True,
                            y_title="Time in ms",
                            x_title="Response Time Trend (For Instance Type: "\
                                    "%(instance_type_name)s, Instance Count: "\
                                    "%(instance_count)s)" % locals(),
                            x_labels=labels)
                page.img(src=png_file % instance_type, alt=alt_text)
                page.br()
Exemple #8
0
        def createGraph(self, filename):
            if self.getNumDataPoints() < 5:
                return
            else:
                pass

            data = {}
            for axis in ["x", "y", "z"]:
                index = min(len(self.avg[axis]), Activity.Properties.max_graph_data)
                data[axis] = self.avg[axis][-index:]
            file = filename + "_avg"
            cairoplot.dot_line_plot(name=file,
                                    data=data,
                                    width=900,
                                    height=900,
                                    border=3,
                                    axis=True,
                                    grid=True,
                                    y_bounds=(-2,2),
                                    series_legend=True,
                                    x_title = "Time (minutes:seconds)",
                                    y_title = "Average") 

            data = {}
            for axis in ["x", "y", "z"]:
                index = min(len(self.std_deviation[axis]), Activity.Properties.max_graph_data)
                data[axis] = self.std_deviation[axis][-index:]

            file = filename + "_std_dev"
            cairoplot.dot_line_plot(name=file,
                                    data=data,
                                    width=900,
                                    height=900,
                                    border=3,
                                    axis=True,
                                    grid=True,
                                    y_bounds=(0,1),
                                    series_legend=True,
                                    x_title = "Time (minutes:seconds)",
                                    y_title = "Standard Deviation") 
Exemple #9
0
	def MakeLegend(self, FileName):
		"""
		Funzione che produce un'immagine con la legenda.

		:param FileName: Nome file da assegnare al risultato.
		:returns: *nulla*

		"""
		global Interval
		FileName = 'extra/MonitorGraph/'+FileName
		FakeValues = range(len(self.ProbeList))

		#ogni volta cerca di acquisire il lock per creare una nuova immagine, se non riesce, rompe il lock
		TempLock = FileLock(FileName)
		try:
			TempLock.acquire(timeout=Interval)
		except LockTimeout:
			TempLock.break_lock()
		else:
			cairoplot.dot_line_plot(FileName, dict(zip(self.ProbeList,FakeValues)), 200, 10*len(self.ProbeList)+50, 
axis=False, grid=False, series_legend=True,series_colors=self.Colors)
			TempLock.release()
Exemple #10
0
import cairoplot


data = [3141, 1729, 3248626 - 3007797 - 240008 - 563, 2507, 992, 861, 221, 1597, 6 + 581]
datax = [
    "11 Dev 2011",
    "18 Dev 2011",
    " 1 Jan 2012",
    " 8 Jan 2012",
    "15 Jan 2012",
    "22 Jan 2012",
    "29 Jan 2012",
    "19 Feb 2012",
    "25 Mar 2012",
]
cairoplot.dot_line_plot(
    "images/git_work_time.png",
    data,
    1000,
    300,
    x_labels=datax,
    border=0,
    axis=True,
    grid=True,
    x_title="Date",
    y_title="Line of Code changed",
)
Exemple #11
0
			data[-1][6] += [min(5,(tc.target-tc.progress-tc.d)*10.) ]
			data[-1][1] += [tc.progress]
			data[-1][2] += [tc.currentvel]
			#print tc.currentvel
			data[-1][3] += [tc.current_accel]
			data[-1][4] += [tc.d]
			data[-1][5] += [0]#,tc.maxvel]
			data[-1][0] += [tc.current_jerk]#[(tc.d-tc.target)*10 if tc.d-tc.target>0 else 0]
			#if pr : print tc.target-tc.progress-tc.d
			pr = i%1000==0 
	
			#if pr : print "\n",i,"\n%4.5f %4.5f v%4.5f a%4.5f j%4.5f %4.5f %4.5f "% (tc.target, tc.progress, tc.currentvel, tc.current_accel, tc.current_jerk, tc.maxvel, tc.maxaccel)
			if pr : print "\n", i		
	print tc.d," - p", 
	print tc.target - tc.progress,  tc.target <=tc.progress
	print tc.currentvel, tc.current_accel
		
	n+=1
	cairoplot.dot_line_plot ("test%d.png"%n,
						 data[-1],
						 800,
						 600,
 			background = (.95,.95,.95),
					border = 0,
					axis = False,
					grid = True,
					dots = False,
					series_colors = [(.8,0,0),(0,0.8,0),(0,0,0.8),(.4,0.4,1),(.4,0,0.4),(0,0.4,0.4),(.4,.4,0.4),]
)

Exemple #12
0
    f = [math.exp(x) for x in t]
    g = [10*math.cos(x) for x in t]
    h = [10*math.sin(x) for x in t]
    erx = [0.1*random() for x in t]
    ery = [5*random() for x in t]
    data = Series({"exp" : [t,f], "cos" : [t,g], "sin" : [t,h]})
    series_colors = [ (1,0,0), (0,0,0), (0,0,1) ]
    cairoplot.scatter_plot ( 'cross_r_exponential_series.png', data = data, errorx = [erx,erx], errory = [ery,ery], width = 800, height = 600, border = 20, 
                             axis = True, discrete = False, dots = 5, grid = True, 
                             x_title = "t", y_title = "f(t) g(t)", series_legend=True, series_colors = series_colors )


if test_dot_line_plot:
    #Default plot
    data = [ 0, 1, 3.5, 8.5, 9, 0, 10, 10, 2, 1 ]
    cairoplot.dot_line_plot( "dot_line_1_default_series.png", data, 400, 300, border = 50, axis = True, grid = True,
                             x_title = "x axis", y_title = "y axis" )

    #Labels
    data = { "john" : [-5, -2, 0, 1, 3], "mary" : [0, 0, 3, 5, 2], "philip" : [-2, -3, -4, 2, 1] }
    x_labels = [ "jan/2008", "feb/2008", "mar/2008", "apr/2008", "may/2008" ]
    y_labels = [ "very low", "low", "medium", "high", "very high" ]
    cairoplot.dot_line_plot( "dot_line_2_dictionary_labels_series.png", data, 400, 300, x_labels = x_labels, 
                             y_labels = y_labels, axis = True, grid = True,
                             x_title = "x axis", y_title = "y axis", series_legend=True )
    
    #Series legend
    data = { "john" : [10, 10, 10, 10, 30], "mary" : [0, 0, 3, 5, 15], "philip" : [13, 32, 11, 25, 2] }
    x_labels = [ "jan/2008", "feb/2008", "mar/2008", "apr/2008", "may/2008" ]
    cairoplot.dot_line_plot( 'dot_line_3_series_legend_series.png', data, 400, 300, x_labels = x_labels, 
                             axis = True, grid = True, series_legend = True )
data = [
    3141,
    1729,
    3248626-3007797-240008-563,
    2507,
    992,
    861,
    221,
    1597,
    6+581
  ]
datax = [
    "11 Dev 2011",
    "18 Dev 2011",
    " 1 Jan 2012",
    " 8 Jan 2012",
    "15 Jan 2012",
    "22 Jan 2012",
    "29 Jan 2012",
    "19 Feb 2012",
    "25 Mar 2012"
  ]
cairoplot.dot_line_plot(
  "images/git_work_time.png",
  data,
  1000, 300,
  x_labels = datax,
  border = 0, axis = True, grid = True,
  x_title = "Date", y_title = "Line of Code changed"
)
Exemple #14
0
	latency += 1

## Sleep efficiency determination and annotation of the classified dataset
efficiency = N.sum(count)/N.size(count)
labels = 'Sleep', 'Wake'
fracs = [efficiency, 1-efficiency]

## Report string for sleep efficiency (SE) and sleep onset latency (SOL)
report = 'SE: ' + str(100*efficiency) + '; SOL: ' + str(latency) + ' minutes'

## Use cairoplot to generate some quick plots of the sleep data
background=cairo.LinearGradient(300,0,300,400)
background.add_color_stop_rgb(0.0, .54, .54, .54)
background.add_color_stop_rgb(1.0, .24, .24, .24)
data = {"SLEEP": float(efficiency) , "WAKE": float(1-efficiency)}
print("Efficiency: " + str(efficiency) + " and ~Eff: " + str(1-efficiency))
cairoplot.pie_plot("SleepEfficiency.png", data, 400, 400, gradient=True, shadow=True, background=background)
users={ "none": user, "none2":[0],"sleep": [0]}
cairoplot.dot_line_plot("SleepWake.png", users, 400, 400, axis=True, grid=True, y_title='Sleep=1; Wake=0', x_title=report,  y_bounds=(0,1.11), background=background)

#py.figure(1, figsize=(6,6))
#ax = py.axes([0.1, 0.1, 0.8, 0.8])
#py.pie(fracs, labels=labels, autopct='%1.1f%%', shadow=True)
#py.title('Sleep Efficiency with ' + report)

#py.axis([0,N.size(user), 0, 1.2])
#py.grid(True)
#py.show()

#classifier(e)
Exemple #15
0
    start = time.time()
    count = 0
    while time.time() < start + 60:
        if geiger.read(1) != "":
            print("Count")
            count = count + 1
    return count

# our read attempts will time out after 1 second
geiger = serial.Serial(port = geigerPort, baudrate = 9600, timeout = 1)

# plot the past plotLength minutes, initially all zero
times  = [""] * 30
counts = [0] * 30

# once a minute, add a new count, drop the oldest, and replot
while 1 == 1:
    # drop the oldest data point
    counts = counts[1:len(counts)]
    times  =  times[1:len(times)]
    # append the newest data point
    counts.append(countsPerMinute(geiger))
    times.append(time.strftime("%I:%M %p"))
    # plot the resulting graph
    cairoplot.dot_line_plot(chartPath, counts, 400, 300,
                            background = "white white",
                            border = 1,
                            axis = True,
                            x_labels = times,
                            x_title  = "CPM as of %s" % time.asctime())