from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.411765, 0.964706, 0.917647],
[0.411765, 0.964706, 0.917647],
[0.411765, 0.964706, 0.917647],
[0.411765, 0.964706, 0.917647],
[0.411765, 0.964706, 0.917647],
[0.411765, 0.964706, 0.917647],
[0.411765, 0.964706, 0.917647],
[0.411765, 0.964706, 0.917647],
[0.411765, 0.964706, 0.917647],
[0.431373, 0.984314, 0.870588],
[0.447059, 0.992157, 0.823529],
[0.482353, 0.956863, 0.729412],
[0.498039, 0.937255, 0.686275],
[0.513725, 0.921569, 0.643137],
[0.529412, 0.905882, 0.6],
[0.560784, 0.878431, 0.517647],
[0.576471, 0.870588, 0.478431],
[0.588235, 0.858824, 0.443137],
[0.615686, 0.847059, 0.372549],
[0.627451, 0.839216, 0.341176],
[0.639216, 0.839216, 0.309804],
[0.647059, 0.835294, 0.282353],
[0.666667, 0.839216, 0.231373],
[0.67451, 0.843137, 0.211765],
[0.682353, 0.847059, 0.192157],
[0.690196, 0.854902, 0.172549],
[0.701961, 0.87451, 0.145098],
[0.705882, 0.886275, 0.133333],
[0.705882, 0.898039, 0.12549],
[0.709804, 0.929412, 0.117647],
[0.713725, 0.945098, 0.113725],
[0.709804, 0.964706, 0.117647],
[0.709804, 0.984314, 0.121569],
[0.705882, 0.972549, 0.133333],
[0.701961, 0.952941, 0.145098],
[0.694118, 0.929412, 0.156863],
[0.682353, 0.882353, 0.192157],
[0.67451, 0.854902, 0.211765],
[0.666667, 0.831373, 0.231373],
[0.658824, 0.803922, 0.258824],
[0.639216, 0.752941, 0.309804],
[0.627451, 0.729412, 0.341176],
[0.615686, 0.701961, 0.372549],
[0.603922, 0.678431, 0.407843],
[0.576471, 0.627451, 0.478431],
[0.560784, 0.603922, 0.517647],
[0.545098, 0.580392, 0.556863],
[0.513725, 0.537255, 0.643137],
[0.498039, 0.517647, 0.686275],
[0.482353, 0.498039, 0.729412],
[0.466667, 0.478431, 0.776471],
[0.431373, 0.443137, 0.870588],
[0.411765, 0.427451, 0.917647],
[0.392157, 0.411765, 0.964706],
[0.376471, 0.4, 0.984314],
[0.341176, 0.376471, 0.890196],
[0.321569, 0.368627, 0.839216],
[0.301961, 0.360784, 0.792157],
[0.266667, 0.34902, 0.694118],
[0.247059, 0.345098, 0.647059],
[0.231373, 0.345098, 0.6],
[0.211765, 0.345098, 0.552941],
[0.180392, 0.345098, 0.462745],
[0.164706, 0.34902, 0.419608],
[0.14902, 0.352941, 0.376471],
[0.117647, 0.364706, 0.294118],
[0.101961, 0.372549, 0.254902],
[0.0901961, 0.380392, 0.219608],
[0.0745098, 0.388235, 0.184314],
[0.0509804, 0.407843, 0.117647],
[0.0509804, 0.419608, 0.0862745],
[0.0313725, 0.431373, 0.0588235],
[0.0196078, 0.443137, 0.0352941],
[0.00392157, 0.470588, 0.00784314],
[0., 0.486275, 0.027451],
[0.00784314, 0.498039, 0.0470588],
[0.0196078, 0.52549, 0.0745098],
[0.0235294, 0.541176, 0.0862745],
[0.0235294, 0.552941, 0.0941176],
[0.027451, 0.568627, 0.0980392],
[0.0313725, 0.596078, 0.105882],
[0.027451, 0.607843, 0.101961],
[0.027451, 0.619608, 0.0980392],
[0.0235294, 0.643137, 0.0862745],
[0.0196078, 0.65098, 0.0745098],
[0.0117647, 0.662745, 0.0627451],
[0.00784314, 0.670588, 0.0470588],
[0.00392157, 0.686275, 0.00784314],
[0.0117647, 0.690196, 0.00784314],
[0.0196078, 0.698039, 0.0352941],
[0.0313725, 0.701961, 0.0588235],
[0.0509804, 0.705882, 0.117647],
[0.0627451, 0.705882, 0.14902],
[0.0745098, 0.705882, 0.184314],
[0.101961, 0.705882, 0.254902],
[0.117647, 0.701961, 0.294118],
[0.133333, 0.698039, 0.333333],
[0.14902, 0.690196, 0.376471],
[0.180392, 0.678431, 0.462745],
[0.196078, 0.670588, 0.505882],
[0.211765, 0.662745, 0.552941],
[0.231373, 0.65098, 0.6],
[0.266667, 0.631373, 0.694118],
[0.286275, 0.619608, 0.741176],
[0.301961, 0.603922, 0.792157],
[0.337255, 0.580392, 0.886275],
[0.356863, 0.564706, 0.937255],
[0.376471, 0.54902, 0.984314],
[0.392157, 0.533333, 0.964706],
[0.431373, 0.501961, 0.870588],
[0.447059, 0.486275, 0.823529],
[0.466667, 0.470588, 0.776471],
[0.498039, 0.439216, 0.686275],
[0.513725, 0.423529, 0.643137],
[0.529412, 0.407843, 0.6],
[0.545098, 0.392157, 0.556863],
[0.576471, 0.360784, 0.478431],
[0.588235, 0.345098, 0.443137],
[0.603922, 0.333333, 0.407843],
[0.615686, 0.317647, 0.372549],
[0.639216, 0.290196, 0.309804],
[0.647059, 0.278431, 0.282353],
[0.658824, 0.266667, 0.258824],
[0.67451, 0.243137, 0.211765],
[0.682353, 0.235294, 0.192157],
[0.690196, 0.223529, 0.172549],
[0.694118, 0.215686, 0.156863],
[0.705882, 0.2, 0.133333],
[0.705882, 0.196078, 0.12549],
[0.709804, 0.188235, 0.121569],
[0.713725, 0.180392, 0.113725],
[0.709804, 0.176471, 0.117647],
[0.709804, 0.172549, 0.121569],
[0.705882, 0.172549, 0.12549],
[0.701961, 0.168627, 0.145098],
[0.694118, 0.168627, 0.156863],
[0.690196, 0.168627, 0.172549],
[0.682353, 0.172549, 0.192157],
[0.666667, 0.172549, 0.231373],
[0.658824, 0.176471, 0.258824],
[0.647059, 0.180392, 0.282353],
[0.627451, 0.184314, 0.341176],
[0.615686, 0.188235, 0.372549],
[0.603922, 0.192157, 0.407843],
[0.588235, 0.2, 0.443137],
[0.560784, 0.207843, 0.517647],
[0.545098, 0.211765, 0.556863],
[0.529412, 0.215686, 0.6],
[0.498039, 0.223529, 0.686275],
[0.482353, 0.231373, 0.729412],
[0.466667, 0.235294, 0.776471],
[0.447059, 0.239216, 0.823529],
[0.411765, 0.247059, 0.917647],
[0.392157, 0.25098, 0.964706],
[0.376471, 0.25098, 0.984314],
[0.356863, 0.254902, 0.937255],
[0.321569, 0.258824, 0.839216],
[0.301961, 0.262745, 0.792157],
[0.286275, 0.262745, 0.741176],
[0.247059, 0.262745, 0.647059],
[0.231373, 0.262745, 0.6],
[0.211765, 0.262745, 0.552941],
[0.196078, 0.262745, 0.505882],
[0.164706, 0.258824, 0.419608],
[0.14902, 0.258824, 0.376471],
[0.133333, 0.254902, 0.333333],
[0.117647, 0.25098, 0.294118],
[0.0901961, 0.243137, 0.219608],
[0.0745098, 0.239216, 0.184314],
[0.0627451, 0.235294, 0.14902],
[0.0509804, 0.227451, 0.0862745],
[0.0313725, 0.219608, 0.0588235],
[0.0196078, 0.215686, 0.0352941],
[0.0117647, 0.207843, 0.00784314],
[0., 0.196078, 0.027451],
[0.00784314, 0.188235, 0.0470588],
[0.0117647, 0.180392, 0.0627451],
[0.0235294, 0.168627, 0.0862745],
[0.0235294, 0.160784, 0.0941176],
[0.027451, 0.152941, 0.0980392],
[0.027451, 0.145098, 0.101961],
[0.027451, 0.133333, 0.101961],
[0.027451, 0.12549, 0.0980392],
[0.0235294, 0.117647, 0.0941176],
[0.0235294, 0.109804, 0.0862745],
[0.0117647, 0.0980392, 0.0627451],
[0.00784314, 0.0901961, 0.0470588],
[0., 0.0862745, 0.027451],
[0.0117647, 0.0745098, 0.00784314],
[0.0196078, 0.0666667, 0.0352941],
[0.0313725, 0.0627451, 0.0588235],
[0.0509804, 0.0588235, 0.0862745],
[0.0627451, 0.0470588, 0.14902],
[0.0745098, 0.0431373, 0.184314],
[0.0901961, 0.0509804, 0.219608],
[0.117647, 0.0313725, 0.294118],
[0.133333, 0.027451, 0.333333],
[0.14902, 0.0235294, 0.376471],
[0.164706, 0.0235294, 0.419608],
[0.196078, 0.0156863, 0.505882],
[0.211765, 0.0156863, 0.552941],
[0.231373, 0.0117647, 0.6],
[0.247059, 0.00784314, 0.647059],
[0.286275, 0.00392157, 0.741176],
[0.301961, 0.00392157, 0.792157],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0.321569, 0., 0.839216],
[0., 0., 0.],
[1., 1., 1.],
[1., 1., 1.]]

test_cm = LinearSegmentedColormap.from_list(__file__, cm_data)


if __name__ == "__main__":
    import matplotlib.pyplot as plt
    import numpy as np

    try:
        from pycam02ucs.cm.viscm import viscm
        viscm(test_cm)
    except ImportError:
        print("pycam02ucs not found, falling back on simple display")
        plt.imshow(np.linspace(0, 100, 256)[None, :], aspect='auto',
                   cmap=test_cm)
    plt.show()
