import pkg_resources


def set_wmm_model(year):
    """
    Based on year of sample, determine which WMM model coefficients file to
    use. Raises an exception if the file does not exist.
    """
    # set the WMM Coefficients file name based on year input.
    cof_file = 'WMM%4d.COF' % year

    # see if the file exists, if not raise an exception error.
    try:
        wmm_model = pkg_resources.resource_filename(__name__, cof_file)
    except pkg_resources.ResolutionError as e:
        print("Error Type %s: Unable to find the WMM%4d.COF Coefficients file" % e, year)
    else:
        return wmm_model