comparison agl.py @ 8:22d31cee19b1

Misc tidyup, no functional change
author Daniel O'Connor <darius@dons.net.au>
date Mon, 11 Sep 2017 16:48:36 +0930
parents 27540ac7879d
children e2807c99e107
comparison
equal deleted inserted replaced
7:27540ac7879d 8:22d31cee19b1
131 'site_cons_grid' : 'Watt', 131 'site_cons_grid' : 'Watt',
132 'site_cons_pv' : 'Watt' 132 'site_cons_pv' : 'Watt'
133 } 133 }
134 134
135 convs = { 135 convs = {
136 'battery_power' : lambda a: a / 1000.0 136 'battery_power' : lambda a: a / 1000.0,
137 }
138
139 scale_limits = {
140 'battery_charge' : (0, 100),
137 } 141 }
138 142
139 names = { 143 names = {
140 'battery_charge' : 'Battery Charge', 144 'battery_charge' : 'Battery Charge',
141 'battery_power' : 'Battery Power', 145 'battery_power' : 'Battery Power',
198 (start, end)) 202 (start, end))
199 ary = numpy.array(cur.fetchall()) 203 ary = numpy.array(cur.fetchall())
200 if ary.shape[0] == 0: 204 if ary.shape[0] == 0:
201 print('No data') 205 print('No data')
202 return 206 return
203 # Convert naive UTC to proper UTC then adjust to local time 207 # Convert TZ naive UTC to TZ aware UTC then adjust to local time
204 xdata = map(lambda f: f.replace(tzinfo = utc).astimezone(lt), ary[:,0]) 208 xdata = map(lambda f: f.replace(tzinfo = utc).astimezone(lt), ary[:,0])
205 for idx in range(len(cols)): 209 for idx in range(len(cols)):
206 ydata = ary[:,idx + 1] 210 ydata = ary[:,idx + 1]
207 if cols[idx] in convs: 211 if cols[idx] in convs:
208 ydata = convs[cols[idx]](ydata) 212 ydata = convs[cols[idx]](ydata)