def lattice_to_spacegroup(lattice):
    """Convert a lattice e.g. tP into the minimal spacegroup number
    to represent this."""

    _lattice_to_spacegroup = {
        "aP": 1,
        "mP": 3,
        "mC": 5,
        "mI": 5,
        "oP": 16,
        "oC": 20,
        "oF": 22,
        "oI": 23,
        "tP": 75,
        "tI": 79,
        "hP": 143,
        "hR": 146,
        "cP": 195,
        "cF": 196,
        "cI": 197,
    }

    if lattice not in _lattice_to_spacegroup:
        raise RuntimeError('lattice "%s" unknown' % lattice)

    return _lattice_to_spacegroup[lattice]