コード例 #1
0
ファイル: profiler.py プロジェクト: Bevinsky/HU_g9
	def process_data(self, data):
		# all data is not grouped?
		day = utils.groupby(data, xkey=lambda x: x.time.weekday())[self.weekday]
		day = utils.collect_total(day, True)
		for m in day:
			day[m] = day[m] # watt i medel
		
		self.data = day
コード例 #2
0
ファイル: profiler.py プロジェクト: Bevinsky/HU_g9
	def diff_actual(self, date, conf_int=False):
		"""
		Plots both the actual energy data for a specific date, as well as the
		profile for that date.
		
		This only works for past dates.
		"""
		if date >= datetime.date.today():
			raise ValueError('invalid date')
		prof_def = self.get_profile_def(date)
		prof_res = self.calculate(prof_def)
		date_res = self.dataman.collectByDate(self.device, date)
		date_res = utils.collect_total(map(str_to_tuple, date_res), True)
		date_res = [((0.0, 0.0) if i not in date_res else date_res[i]) for i in range(1440)]
		
		fig, ax = plt.subplots(1)
		fig.autofmt_xdate()
		# group by minute of day, do autocounting
		x = map(lambda i: datetime.datetime(2012, 10, 12, i/60, i%60), range(1440))
		if conf_int:
			c_low = map(lambda i: i[0] - i[1], prof_res)
			c_high = map(lambda i: i[0] + i[1], prof_res)
			ax.fill_between(x, c_low, c_high, alpha=0.5, lw=0, color='yellow')
		
		prof_res = map(lambda i: i[0], prof_res)
		date_res = map(lambda i: i[0], date_res)
		
		ax.fill_between(x, prof_res, date_res, color='blue', lw=0, alpha=0.6)
		ax.plot(x, prof_res, color='red', lw=0.8)
		ax.plot(x, date_res, color='green', lw=0.8)
		ax.plot(x, [numpy.mean(prof_res)]*1440, color='red', lw=1)
		ax.plot(x, [numpy.mean(date_res)]*1440, color='green', lw=1)
		ax.fmt_xdata = mdates.DateFormatter('%H:%M')
		ax.grid(True, which='major')
		plt.xlabel(u'Tid')
		plt.ylabel(u'Energianvändning')
		t1 = u' '.join(prof_def) + ' (red)'
		t2 = str(date) + u' (green)'
		plt.title(t1 + ' and ' + t2)
		plt.show()
コード例 #3
0
ファイル: profiler.py プロジェクト: Bevinsky/HU_g9
	def process_data(self, data):
		data = utils.collect_total(data, True)
		self.data = data