import pickle


def read_gridded_predictions(pickle_file_name):
    """Reads gridded predictions from Pickle file.

    :param pickle_file_name: Path to input file.
    :return: predicted_label_matrix: See doc for `write_gridded_predictions`.
    :return: metadata_dict: Dictionary with the following keys.
    metadata_dict['valid_times_unix_sec']: See doc for
        `write_gridded_predictions`.
    metadata_dict['narr_mask_matrix']: Same.
    metadata_dict['pressure_level_mb']: Same.
    metadata_dict['smoothing_radius_pixels']: Same.
    metadata_dict['cutoff_radius_pixels']: Same.
    metadata_dict['warm_front_percentile']: Same.
    metadata_dict['cold_front_percentile']: Same.
    metadata_dict['num_closing_iters']: Same.
    """

    pickle_file_handle = open(pickle_file_name, 'rb')
    predicted_label_matrix = pickle.load(pickle_file_handle)
    metadata_dict = pickle.load(pickle_file_handle)
    pickle_file_handle.close()

    return predicted_label_matrix, metadata_dict