def parse_parfile(fname):
    """Read the parameters from a pulsar parfile."""
    param = {}
    with open(fname, "r") as f:
        line = f.readline()
        while line != "":
            if line[0] != "#":
                line = [l.strip() for l in line.split()]
                if len(line) > 1:
                    param[line[0]] = line[1:] if len(line[1:]) > 1 else line[1]
            line = f.readline()
    return param