def nm_to_rgb(nm):
    """Convert a wavelength to corresponding RGB values [0.0-1.0].

    Parameters
    ----------
    nm : int or float
        The wavelength of light.

    Returns
    -------
    List of [R,G,B] values between 0 and 1


    `original code`__

    __ http://www.physics.sfasu.edu/astro/color/spectra.html
    """
    w = int(nm)
    # color ---------------------------------------------------------------------------------------
    if w >= 380 and w < 440:
        R = -(w - 440.) / (440. - 350.)
        G = 0.0
        B = 1.0
    elif w >= 440 and w < 490:
        R = 0.0
        G = (w - 440.) / (490. - 440.)
        B = 1.0
    elif w >= 490 and w < 510:
        R = 0.0
        G = 1.0
        B = -(w - 510.) / (510. - 490.)
    elif w >= 510 and w < 580:
        R = (w - 510.) / (580. - 510.)
        G = 1.0
        B = 0.0
    elif w >= 580 and w < 645:
        R = 1.0
        G = -(w - 645.) / (645. - 580.)
        B = 0.0
    elif w >= 645 and w <= 780:
        R = 1.0
        G = 0.0
        B = 0.0
    else:
        R = 0.0
        G = 0.0
        B = 0.0
    # intensity correction ------------------------------------------------------------------------
    if w >= 380 and w < 420:
        SSS = 0.3 + 0.7 * (w - 350) / (420 - 350)
    elif w >= 420 and w <= 700:
        SSS = 1.0
    elif w > 700 and w <= 780:
        SSS = 0.3 + 0.7 * (780 - w) / (780 - 700)
    else:
        SSS = 0.0
    SSS *= 255
    return [float(int(SSS * R) / 256.), float(int(SSS * G) / 256.), float(int(SSS * B) / 256.)]
def nm_to_rgb ( nm ) : w = int ( nm ) if w >= 380 and w < 440 : R = - ( w - 440. ) / ( 440. - 350. ) G = 0.0 B = 1.0 elif w >= 440 and w < 490 : R = 0.0 G = ( w - 440. ) / ( 490. - 440. ) B = 1.0 elif w >= 490 and w < 510 : R = 0.0 G = 1.0 B = - ( w - 510. ) / ( 510. - 490. ) elif w >= 510 and w < 580 : R = ( w - 510. ) / ( 580. - 510. ) G = 1.0 B = 0.0 elif w >= 580 and w < 645 : R = 1.0 G = - ( w - 645. ) / ( 645. - 580. ) B = 0.0 elif w >= 645 and w <= 780 : R = 1.0 G = 0.0 B = 0.0 else : R = 0.0 G = 0.0 B = 0.0 if w >= 380 and w < 420 : SSS = 0.3 + 0.7 * ( w - 350 ) / ( 420 - 350 ) elif w >= 420 and w <= 700 : SSS = 1.0 elif w > 700 and w <= 780 : SSS = 0.3 + 0.7 * ( 780 - w ) / ( 780 - 700 ) else : SSS = 0.0 SSS *= 255 return [ float ( int ( SSS * R ) / 256. ) , float ( int ( SSS * G ) / 256. ) , float ( int ( SSS * B ) / 256. ) ]
Convert a wavelength to corresponding RGB values [0.0-1.0].

    Parameters
    ----------
    nm : int or float
        The wavelength of light.

    Returns
    -------
    List of [R,G,B] values between 0 and 1


    `original code`__

    __ http://www.physics.sfasu.edu/astro/color/spectra.html