def spline_type_to_id(spline_type):
    """ spline_type_to_id(spline_type)
    
    Method to map a spline name to an integer ID. This is used so that
    set_cubic_spline_coefs() can be efficient.
    
    The spline_type can also be a number between -1 and 1, representing
    the tension for a Cardinal spline.
    """
    
    # Handle tension given for Cardinal spline
    tension = 0.0
    if isinstance(spline_type, (float, int)):           
        if spline_type >= -1 and spline_type <= 1:
            tension = float(spline_type)
            spline_type = 'Cardinal'
        else:
            raise ValueError('Tension parameter must be between -1 and 1.')
    
    # Get id
    if spline_type.lower() in ['c', 'card', 'cardinal', 'catmull–rom']:
        return tension # For catmull-rom, we use default tension 0
    elif spline_type.lower() in ['b', 'basis', 'basic']:
        return 2.0
    elif spline_type.lower() in ['herm', 'hermite']:
        return 3.0
    elif spline_type.lower() in ['lag', 'lagrange']:
        return 4.0
    elif spline_type.lower() in ['lanc', 'lanczos']:
        return 5.0
    elif spline_type.lower() in ['near', 'nearest']:
        return 97.0    
    elif spline_type.lower() in ['lin', 'linear']:
        return 98.0        
    elif spline_type.lower() in ['quad', 'quadratic']:
        return 99.0
    else:
        raise ValueError('Unknown spline type: ' + str(spline_type))