import warnings


def _determine_cy_weighting_func(weighting_function):
    """ Determine cython weight function value. """
    if weighting_function.upper() == 'GRIDRAD':
        cy_weighting_function = 4
    elif weighting_function.upper() == 'BARNES2':
        cy_weighting_function = 3
    elif weighting_function.upper() == 'NEAREST':
        cy_weighting_function = 2
    elif weighting_function.upper() == 'CRESSMAN':
        cy_weighting_function = 1
    elif weighting_function.upper() == 'BARNES':
        warnings.warn("Barnes weighting function is deprecated."
                      " Please use Barnes 2 to be consistent with"
                      " Pauley and Wu 1990.", DeprecationWarning)
        cy_weighting_function = 0
    else:
        raise ValueError('unknown weighting_function')
    return cy_weighting_function