Mercurial > ~darius > hgwebdir.cgi > agl
comparison agl.py @ 11:9fac3371e9ad
Print consumption and generation, tTwiddle text box, remove debugging.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Mon, 11 Sep 2017 18:07:16 +0930 |
parents | 70cc1e874157 |
children | b610ce4ec081 |
comparison
equal
deleted
inserted
replaced
10:70cc1e874157 | 11:9fac3371e9ad |
---|---|
141 } | 141 } |
142 | 142 |
143 tarrifs = { | 143 tarrifs = { |
144 'power_exported' : 0.163, | 144 'power_exported' : 0.163, |
145 'power_imported' : 0.380, | 145 'power_imported' : 0.380, |
146 'power_generated' : 0.163, | |
147 'power_consumed' : 0.380, | |
146 } | 148 } |
147 | 149 |
148 names = { | 150 names = { |
149 'battery_charge' : 'Battery Charge', | 151 'battery_charge' : 'Battery Charge', |
150 'battery_power' : 'Battery Power', | 152 'battery_power' : 'Battery Power', |
225 scale_min = None | 227 scale_min = None |
226 scale_max = None | 228 scale_max = None |
227 | 229 |
228 if col in tarrifs: | 230 if col in tarrifs: |
229 annotation = '%s: $%.2f' % (names[col], (ydata[1:] * xdeltas).sum() / 1000.0 * tarrifs[col]) | 231 annotation = '%s: $%.2f' % (names[col], (ydata[1:] * xdeltas).sum() / 1000.0 * tarrifs[col]) |
230 print(annotation) | |
231 else: | 232 else: |
232 annotation = None | 233 annotation = None |
233 | 234 |
234 if units[col] == yaxisunits1: | 235 if units[col] == yaxisunits1: |
235 ax = ax1lines | 236 ax = ax1lines |
267 ax2.set_ylim(bottom = line[4], top = line[5]) | 268 ax2.set_ylim(bottom = line[4], top = line[5]) |
268 if line[6] != None: | 269 if line[6] != None: |
269 annotations.append(line[6]) | 270 annotations.append(line[6]) |
270 | 271 |
271 ax2.legend(loc = 'upper right') | 272 ax2.legend(loc = 'upper right') |
272 ax1.text(0.02, 0.8, reduce(lambda a, b: a + '\n' + b, annotations), | 273 ax1.text(0.02, 0.9, reduce(lambda a, b: a + '\n' + b, annotations), |
273 transform = ax1.transAxes, bbox=dict(facecolor='red', alpha=0.5)) | 274 transform = ax1.transAxes, bbox = dict(facecolor = 'red', alpha = 0.5), |
275 ha = 'left', va = 'top') | |
274 ndays = int(max(1, round(((end - start).total_seconds()) / 86400))) | 276 ndays = int(max(1, round(((end - start).total_seconds()) / 86400))) |
275 for ax in fig.get_axes(): | 277 for ax in fig.get_axes(): |
276 ax.set_title('%s to %s' % (start.strftime('%Y-%m-%d'), end.strftime('%Y-%m-%d'))) | 278 ax.set_title('%s to %s' % (start.strftime('%Y-%m-%d'), end.strftime('%Y-%m-%d'))) |
277 ax.set_xlim([start, end]) | 279 ax.set_xlim([start, end]) |
278 ax.format_xdata = lambda d: matplotlib.dates.num2date(d).strftime('%d %b %H:%M') | 280 ax.format_xdata = lambda d: matplotlib.dates.num2date(d).strftime('%d %b %H:%M') |