from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0., 0., 0.],
[0.588235, 0., 0.588235],
[0.588235, 0., 0.588235],
[0.588235, 0., 0.588235],
[0.588235, 0., 0.588235],
[0.588235, 0., 0.588235],
[0.588235, 0., 0.588235],
[0.588235, 0., 0.588235],
[0.588235, 0., 0.588235],
[0.588235, 0., 0.588235],
[0.588235, 0., 0.588235],
[0.588235, 0., 0.588235],
[0.588235, 0., 0.588235],
[0.588235, 0., 0.588235],
[0.588235, 0., 0.588235],
[0.588235, 0., 0.588235],
[0.784314, 0., 0.784314],
[0.784314, 0., 0.784314],
[0.784314, 0., 0.784314],
[0.784314, 0., 0.784314],
[0.784314, 0., 0.784314],
[0.784314, 0., 0.784314],
[0.784314, 0., 0.784314],
[0.784314, 0., 0.784314],
[0.784314, 0., 0.784314],
[0.784314, 0., 0.784314],
[0.784314, 0., 0.784314],
[0.784314, 0., 0.784314],
[0.784314, 0., 0.784314],
[0.784314, 0., 0.784314],
[0.784314, 0., 0.784314],
[0.784314, 0., 0.784314],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.588235],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 0.784314],
[0.392157, 0.392157, 1.],
[0.392157, 0.392157, 1.],
[0.392157, 0.392157, 1.],
[0.392157, 0.392157, 1.],
[0.392157, 0.392157, 1.],
[0.392157, 0.392157, 1.],
[0.392157, 0.392157, 1.],
[0.392157, 0.392157, 1.],
[0.392157, 0.392157, 1.],
[0.392157, 0.392157, 1.],
[0.392157, 0.392157, 1.],
[0.392157, 0.392157, 1.],
[0.392157, 0.392157, 1.],
[0.392157, 0.392157, 1.],
[0.392157, 0.392157, 1.],
[0.392157, 0.392157, 1.],
[0., 0.54902, 0.],
[0., 0.54902, 0.],
[0., 0.54902, 0.],
[0., 0.54902, 0.],
[0., 0.54902, 0.],
[0., 0.54902, 0.],
[0., 0.54902, 0.],
[0., 0.54902, 0.],
[0., 0.54902, 0.],
[0., 0.54902, 0.],
[0., 0.54902, 0.],
[0., 0.54902, 0.],
[0., 0.54902, 0.],
[0., 0.54902, 0.],
[0., 0.54902, 0.],
[0., 0.54902, 0.],
[0.588235, 0.666667, 0.],
[0.588235, 0.666667, 0.],
[0.588235, 0.666667, 0.],
[0.588235, 0.666667, 0.],
[0.588235, 0.666667, 0.],
[0.588235, 0.666667, 0.],
[0.588235, 0.666667, 0.],
[0.588235, 0.666667, 0.],
[0.588235, 0.666667, 0.],
[0.588235, 0.666667, 0.],
[0.588235, 0.666667, 0.],
[0.588235, 0.666667, 0.],
[0.588235, 0.666667, 0.],
[0.588235, 0.666667, 0.],
[0.588235, 0.666667, 0.],
[0.588235, 0.666667, 0.],
[0.784314, 0.784314, 0.],
[0.784314, 0.784314, 0.],
[0.784314, 0.784314, 0.],
[0.784314, 0.784314, 0.],
[0.784314, 0.784314, 0.],
[0.784314, 0.784314, 0.],
[0.784314, 0.784314, 0.],
[0.784314, 0.784314, 0.],
[0.784314, 0.784314, 0.],
[0.784314, 0.784314, 0.],
[0.784314, 0.784314, 0.],
[0.784314, 0.784314, 0.],
[0.784314, 0.784314, 0.],
[0.784314, 0.784314, 0.],
[0.784314, 0.784314, 0.],
[0.784314, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.588235, 0.784314, 0.],
[0.784314, 1., 0.470588],
[0.784314, 1., 0.470588],
[0.784314, 1., 0.470588],
[0.784314, 1., 0.470588],
[0.784314, 1., 0.470588],
[0.784314, 1., 0.470588],
[0.784314, 1., 0.470588],
[0.784314, 1., 0.470588],
[0.784314, 1., 0.470588],
[0.784314, 1., 0.470588],
[0.784314, 1., 0.470588],
[0.784314, 1., 0.470588],
[0.784314, 1., 0.470588],
[0.784314, 1., 0.470588],
[0.784314, 1., 0.470588],
[0.784314, 1., 0.470588],
[1., 1., 0.],
[1., 1., 0.],
[1., 1., 0.],
[1., 1., 0.],
[1., 1., 0.],
[1., 1., 0.],
[1., 1., 0.],
[1., 1., 0.],
[1., 1., 0.],
[1., 1., 0.],
[1., 1., 0.],
[1., 1., 0.],
[1., 1., 0.],
[1., 1., 0.],
[1., 1., 0.],
[1., 1., 0.],
[1., 0.784314, 0.],
[1., 0.784314, 0.],
[1., 0.784314, 0.],
[1., 0.784314, 0.],
[1., 0.784314, 0.],
[1., 0.784314, 0.],
[1., 0.784314, 0.],
[1., 0.784314, 0.],
[1., 0.784314, 0.],
[1., 0.784314, 0.],
[1., 0.784314, 0.],
[1., 0.784314, 0.],
[1., 0.784314, 0.],
[1., 0.784314, 0.],
[1., 0.784314, 0.],
[1., 0.784314, 0.],
[1., 0.627451, 0.],
[1., 0.627451, 0.],
[1., 0.627451, 0.],
[1., 0.627451, 0.],
[1., 0.627451, 0.],
[1., 0.627451, 0.],
[1., 0.627451, 0.],
[1., 0.627451, 0.],
[1., 0.627451, 0.],
[1., 0.627451, 0.],
[1., 0.627451, 0.],
[1., 0.627451, 0.],
[1., 0.627451, 0.],
[1., 0.627451, 0.],
[1., 0.627451, 0.],
[1., 0.627451, 0.],
[1., 0.490196, 0.],
[1., 0.490196, 0.],
[1., 0.490196, 0.],
[1., 0.490196, 0.],
[1., 0.490196, 0.],
[1., 0.490196, 0.],
[1., 0.490196, 0.],
[1., 0.490196, 0.],
[1., 0.490196, 0.],
[1., 0.490196, 0.],
[1., 0.490196, 0.],
[1., 0.490196, 0.],
[1., 0.490196, 0.],
[1., 0.490196, 0.],
[1., 0.490196, 0.],
[1., 0.490196, 0.],
[0.784314, 0.196078, 0.392157],
[0.784314, 0.196078, 0.392157],
[0.784314, 0.196078, 0.392157],
[0.784314, 0.196078, 0.392157],
[0.784314, 0.196078, 0.392157],
[0.784314, 0.196078, 0.392157],
[0.784314, 0.196078, 0.392157],
[0.784314, 0.196078, 0.392157],
[0.784314, 0.196078, 0.392157],
[0.784314, 0.196078, 0.392157],
[0.784314, 0.196078, 0.392157],
[0.784314, 0.196078, 0.392157],
[0.784314, 0.196078, 0.392157],
[0.784314, 0.196078, 0.392157],
[0.784314, 0.196078, 0.392157],
[0.784314, 0.196078, 0.392157],
[0.686275, 0.196078, 0.294118],
[0.686275, 0.196078, 0.294118],
[0.686275, 0.196078, 0.294118],
[0.686275, 0.196078, 0.294118],
[0.686275, 0.196078, 0.294118],
[0.686275, 0.196078, 0.294118],
[0.686275, 0.196078, 0.294118],
[0.686275, 0.196078, 0.294118],
[0.686275, 0.196078, 0.294118],
[0.686275, 0.196078, 0.294118],
[0.686275, 0.196078, 0.294118],
[0.686275, 0.196078, 0.294118],
[0.686275, 0.196078, 0.294118],
[0.686275, 0.196078, 0.294118],
[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()
