def extract_delta_time(data): ''' Creates array of delta times between points in seconds ''' times, coordinates = data[:, 0], data[:, 1:] return np.array([delta_float_time(times[i], times[i+1]) for i in range(len(times)-1)])
def test_delta_time(): datestr_array = [ '04-08-2015_14-35-50_PDT', '04-08-2015_14-52-31_PDT', '04-08-2015_14-52-37_PDT', '04-08-2015_14-59-30_PDT', '04-08-2015_14-59-30_PDT', '05-08-2015_15-46-30_PDT', '05-09-2015_15-46-38_PDT', ] dates_nums = [date_str_to_num_converter(el) for el in datestr_array] dts = [] for i in range(len(dates_nums) - 1): dts.append(delta_float_time(dates_nums[i], dates_nums[i+1])) expected_dts = [1001, 6, 413, 0, 89220, 2678408] assert(expected_dts == dts)