def get_within_time(df, time, tolerance):
    """Get data within tolerance of time."""
    start_time = time - tolerance
    end_time = time + tolerance
    return df[(df['valid'] >= start_time) & (df['valid'] <= end_time)]