def pipe_create_ics(test=False): '''Compute smoothed data''' if test: rows = test_data2 else: rows = gen_rows g = pipe.pipe( lambda x: rows(), lambda p: pipe.mapiter(p, coerce_row), lambda p: gen_insulin_carb_vrows(rows=p), # does the actual smoothing lambda p: gen_all_rows_basals(rows=p), # calc basal_amt_12 )
def pipe4(test=False): '''Write smoothed data to .csv file''' print('Not yet ready for prime time') raise Exception if test: p1 = ic_test_data1 filename = 'active_insulin_on_test_data.csv' else: p1 = gen_rows filename = 'active_insulin_on_real_data.csv' g = pipe.pipe(lambda x: p1(), lambda x: pipe.mapiter(x, coerce_row), gen_insulin_carb_vrows, gen_all_rows_basals) csv_output(g(None), filename, IOB_KEYS)
def pipe1(test=False): if test: p1 = ic_test_data1() else: p1 = gen_rows() # should be the same from here on p2 = pipe.mapiter(p1, coerce_row) p25 = p2 # pipe.tee(p2, prefix='real:', printer=printrow) p3 = gen_insulin_carb_vrows(rows=p25) p35 = p3 # pipe.tee(p3, prefix='vrow:', stringify=format_row) # pipe.more(p35, page=10, printer=printrow) p4 = gen_all_rows_basals(rows=p35) # pipe.more(p4, page=10, printer=print_row) return p4
def pipe_count_carbs(): carb_count = [0] def count_carbs(seq): for s in seq: if s['carbs'] > 0: carb_count[0] += 1 yield s g = pipe.pipe( lambda x: gen_rows(), lambda p: pipe.mapiter(p, coerce_row), lambda p: gen_insulin_carb_vrows(rows=p), # does the actual smoothing lambda p: gen_all_rows_basals(rows=p), # calc basal_amt_12 count_carbs) # pipe.more(g(None)) pipe.exhaust(g(None), progress=1000) print 'carb_count', carb_count
def pipe2(test=False): '''Computes smoothed data''' if test: p1 = ic_test_data1() else: p1 = gen_rows(year=2014, month=5, day=19) # should be the same from here on p2 = pipe.mapiter(p1, coerce_row) p25 = pipe.tee(p2, prefix='real:', stringify=format_real_row) p3 = gen_insulin_carb_vrows(rows=p25) pipe.more(p3, page=10, printer=print_row) p35 = p3 # pipe.tee(p3, prefix='vrow:', printer=lambda row: print(format_row(row)) p4 = gen_all_rows_basals(rows=p35) if test: filename = 'insulin_carb_smoothed_on_test_data.csv' else: filename = 'insulin_carb_smoothed_on_real_data.csv' csv_output(p4, filename, ICS_KEYS)
def pipe3(test=False): '''Computes active_insulin data''' if test: p1 = ic_test_data1() else: p1 = gen_rows() # should be the same from here on p2 = pipe.mapiter(p1, coerce_row) p25 = p2 # pipe.tee(p2, prefix='real:', printer=printrow) p3 = gen_insulin_carb_vrows(rows = p25) p35 = p3 # pipe.tee(p3, prefix='vrow:', stringify=format_row) # pipe.more(p35, page=10, printer=printrow) p4 = gen_all_rows_basals(rows = p35) # pipe.more(p4, page=10, printer=print_row) p5 = compute_insulin_on_board(rows=p4, test_data=test, test_iac=False, showCalc=False) if test: filename = 'active_insulin_on_test_data.csv' else: filename = 'active_insulin_on_real_data.csv' csv_output(p5, filename, IOB_KEYS)