def get_insert_indices(my_timestamps, existing_timestamps):
    """
    Given new timestamps and an existing series of timestamps, find the indices
    overlap so that new data can be inserted into the middle of an existing
    dataset
    """
    existing_timestep = existing_timestamps[1] - existing_timestamps[0]
    my_timestep = my_timestamps[1] - my_timestamps[0]

    # make sure the time delta is ok
    if existing_timestep != my_timestep:
        raise Exception("Existing dataset has different timestep (mine=%d, existing=%d)"
                        % (my_timestep, existing_timestep))

    my_offset = (my_timestamps[0] - existing_timestamps[0]) // existing_timestep
    my_end = my_offset + len(my_timestamps)

    return my_offset, my_end