def _make_time_value_array(bg_df, start_index, end_index):
min_in_hour = 60
hour_in_day = 24
array_len = int((bg_df.iloc[end_index]['created_at'] - bg_df.iloc[start_index]['created_at']) / np.timedelta64(1, 'm')) + 1
time_value_array = np.zeros(array_len)
curr_minute = bg_df.iloc[start_index]['created_at'].minute
curr_hour = bg_df.iloc[start_index]['created_at'].hour
for array_index in range(array_len):
time_value_array[array_index] = _get_hours_from_midnight(curr_hour)
curr_minute += 1
if curr_minute >= min_in_hour:
curr_minute = curr_minute % min_in_hour
curr_hour = (curr_hour + 1) % hour_in_day
return time_value_array
#Function that adds data to fill in the gaps of the original data before the lomb-scargle is applied. IT helps make lomb-scargle more accurate
#Essentially, if there is a gap bigger than the size of the MAX_TIME_GAP, then this recursive function will add a data point in between the two time points, creating two more gaps.
#It will recursively call on both of these gaps until the gap size is less than or equal to the MAX_TIME_GAP
#To add data, this function takes the mean of the old and new time, and it sets the value at this middle time to be the mean of the values between the old and new time.
#It will update the array accordingly to make sure the time points are still in order and the indices are correct
评论列表
文章目录