import pickle


def get_pickle_trajectory(path_to_file):
    """ 
    Reads a trajectory as a `pickle` binary file.
    
    :param: path_to_file str the location for the input file
    
    :return: np.array An array of time points
    :return: np.array An array of (raw) location points, without noise
    :return: np.array An array of noisy locations
    :return: [dict] A list of segment dicts
    """    
    
    if path_to_file[-4:] != '.pkl':
        path_to_file += ".pkl"
        
    trajectory = pickle.load( open(path_to_file, "rb") )

    segments = trajectory['segments']
    t_arr = trajectory['time_arr']
    r_arr = trajectory['raw_locs_arr']
    x_arr = trajectory['nse_locs_arr']

    return t_arr, r_arr, x_arr, segments