From 1214a6532e1de7e52fdb4776c9edc1ff923f94a2 Mon Sep 17 00:00:00 2001 From: tim Date: Sat, 27 Jan 2018 21:37:27 +0200 Subject: [PATCH] Add the full date range to the overall glucose summary title; remove A1c from daily graphs, since it's more useful as a longer-term measurement; introduce commented-out code to allow decimal comment variables. --- glucometer_graphs.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/glucometer_graphs.py b/glucometer_graphs.py index 72b1072..907582f 100755 --- a/glucometer_graphs.py +++ b/glucometer_graphs.py @@ -82,8 +82,11 @@ def main(): for row in rows: row = parse_entry(row, args.icons) + ''' Ensure that the rows are sorted by date ''' + rows = sorted(rows, key=lambda row: row.get('date'), reverse=False) + ''' Fill in gaps that might exist in the data, in order to smooth the curves and fills ''' - ''' We're using 8 minute gaps in order to have more accurate fills ''' + ''' We're using 10 minute gaps in order to have more accurate fills ''' rows = fill_gaps(rows, interval=dt.timedelta(minutes=10)) ''' If we're on the default values for units, highs and lows, check that the average @@ -126,7 +129,10 @@ def main(): with FigurePDF(args.output_file) as pdf: ''' Overall averages for all data by hour of the day ''' - title = 'Overall Average Glucose Summary' + start = rows[0].get('date') + end = rows[-1].get('date') + period = start.strftime('%A, %-d %B %Y') + ' to ' + end.strftime('%A, %-d %B %Y') + title = 'Overall Average Glucose Summary for ' + period data = {} for row in rows: @@ -291,7 +297,7 @@ def main(): ''' Draw graph with a spline tranform and labels ''' generate_plot(data, ax=ax, - transforms={'spline':True, 'label':True, 'avgglucose':g_median, 'avga1c':a_median}, + transforms={'spline':True, 'label':True, 'avgglucose':g_median}, args=args, color=BLUE, ) @@ -534,6 +540,10 @@ def parse_entry(data, icons, fmt='%Y-%m-%d %H:%M:%S'): ''' Convert floating point-style strings (2.0) to integer-style strings (2) ''' try: cvalue = int(float(cvalue)) +# if int(float(cvalue)) == float(cvalue) +# cvalue = int(float(cvalue)) +# else +# cvalue = float(cvalue) except: pass cvalue = str(cvalue)