def name_and_code(name_str):
    """
    Extract phase name and possible model code from string.

    Args:
        name_str: (str) Raw string of phase name, possibly including a model code.

    Returns:
        ph_name (str) The phase name.
        code (str) The model code, if present. If not present, None.
    """
    try:
        ph_name, code = name_str.split(':')
    except ValueError:
        ph_name = name_str
        code = None

    if code not in ['G', 'A', 'Y', 'L', 'I', 'F', 'B']:
        ph_name = name_str
        code = None

    return ph_name, code