def _make_actual_bg_array(bg_df, start_index, end_index, prediction_start_time):
total_len = start_index - end_index + 1
time_bg_array = np.zeros(total_len)
actual_bg_array = np.zeros(total_len)
array_index = 0
miss = 0
for df_index in range(start_index, end_index - 1, -1):
#Keep track of the time starting at 0 at the start_index
time = (bg_df.iloc[df_index]['created_at'] - bg_df.iloc[start_index]['created_at']) / np.timedelta64(1, 'm')
if time > prediction_start_time:
time_bg_array[array_index] = time
try:
actual_bg_array[array_index] = bg_df.iloc[df_index]['openaps']['enacted']['bg']
array_index += 1
last_time = time
except:
try:
actual_bg_array[array_index] = bg_df.iloc[df_index]['openaps']['suggested']['bg']
array_index += 1
last_time = time
except:
#If a miss, don't move to the next index and instead add one to the number missed
miss += 1
else:
miss += 1
#Remove the number of missed data
time_bg_array = np.resize(time_bg_array, total_len - miss)
actual_bg_array = np.resize(actual_bg_array, total_len - miss)
return time_bg_array, actual_bg_array
#Returns true if the data lies in a data gap, so it will not be used
评论列表
文章目录