def get_result_file_type(file_name):
    """
    Given a name of an Ocellaris output file (either log or restart file)
    return 'h5' or 'log' depending on the file type. Returns None for
    unknown files
    """
    if file_name.endswith('.h5'):
        return 'h5'
    elif file_name.endswith('.log'):
        return 'log'

    with open(file_name, 'rb') as f:
        head = f.read(200).decode('ascii', 'ignore')

    if head.startswith('HDF'):
        return 'h5'
    elif head.startswith('==========') and 'Ocellaris' in head:
        return 'log'