def wavelength_to_colour(lam):
    """Convert a wavelength to a RGB colour

    Will return the color associated to a particular wavelength.

    Args:
        lam (float): The wavelength lambda.

    Returns:
        A tuple (R,G,B) of colors in the 0 to 1 range.

    """
    if lam >= 380 and lam < 440:
        R = -(lam - 440.0) / (440.0 - 350.0)
        G = 0.0
        B = 1.0
    elif lam >= 440 and lam < 490:
        R = 0.0
        G = (lam - 440.0) / (490.0 - 440.0)
        B = 1.0
    elif lam >= 490 and lam < 510:
        R = 0.0
        G = 1.0
        B = -(lam - 510.0) / (510.0 - 490.0)
    elif lam >= 510 and lam < 580:
        R = (lam - 510.0) / (580.0 - 510.0)
        G = 1.0
        B = 0.0
    elif lam >= 580 and lam < 645:
        R = 1.0
        G = -(lam - 645.0) / (645.0 - 580.0)
        B = 0.0
    elif lam >= 645 and lam <= 780:
        R = 1.0
        G = 0.0
        B = 0.0
    else:
        R = 0.0
        G = 0.0
        B = 0.0
    if lam >= 380 and lam < 420:
        SSS = 0.3 + 0.7 * (lam - 350) / (420 - 350)
    elif lam >= 420 and lam <= 700:
        SSS = 1.0
    elif lam > 700 and lam <= 780:
        SSS = 0.3 + 0.7 * (780 - lam) / (780 - 700)
    else:
        SSS = 0.0
    return SSS * R, SSS * G, SSS * B
