from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0., 0., 0.],
[0., 0.329412, 0.],
[0., 0.329412, 0.],
[0., 0.329412, 0.],
[0., 0.329412, 0.],
[0., 0.329412, 0.],
[0., 0.329412, 0.],
[0., 0.329412, 0.],
[0., 0.329412, 0.],
[0., 0.329412, 0.],
[0., 0.329412, 0.],
[0., 0.329412, 0.],
[0., 0.329412, 0.],
[0., 0.329412, 0.],
[0., 0.329412, 0.],
[0., 0.329412, 0.],
[0., 0.658824, 0.],
[0., 0.658824, 0.],
[0., 0.658824, 0.],
[0., 0.658824, 0.],
[0., 0.658824, 0.],
[0., 0.658824, 0.],
[0., 0.658824, 0.],
[0., 0.658824, 0.],
[0., 0.658824, 0.],
[0., 0.658824, 0.],
[0., 0.658824, 0.],
[0., 0.658824, 0.],
[0., 0.658824, 0.],
[0., 0.658824, 0.],
[0., 0.658824, 0.],
[0., 0.658824, 0.],
[0., 1., 0.],
[0., 1., 0.],
[0., 1., 0.],
[0., 1., 0.],
[0., 1., 0.],
[0., 1., 0.],
[0., 1., 0.],
[0., 1., 0.],
[0., 1., 0.],
[0., 1., 0.],
[0., 1., 0.],
[0., 1., 0.],
[0., 1., 0.],
[0., 1., 0.],
[0., 1., 0.],
[0., 1., 0.],
[0., 1., 0.329412],
[0., 1., 0.329412],
[0., 1., 0.329412],
[0., 1., 0.329412],
[0., 1., 0.329412],
[0., 1., 0.329412],
[0., 1., 0.329412],
[0., 1., 0.329412],
[0., 1., 0.329412],
[0., 1., 0.329412],
[0., 1., 0.329412],
[0., 1., 0.329412],
[0., 1., 0.329412],
[0., 1., 0.329412],
[0., 1., 0.329412],
[0., 1., 0.329412],
[0., 1., 0.658824],
[0., 1., 0.658824],
[0., 1., 0.658824],
[0., 1., 0.658824],
[0., 1., 0.658824],
[0., 1., 0.658824],
[0., 1., 0.658824],
[0., 1., 0.658824],
[0., 1., 0.658824],
[0., 1., 0.658824],
[0., 1., 0.658824],
[0., 1., 0.658824],
[0., 1., 0.658824],
[0., 1., 0.658824],
[0., 1., 0.658824],
[0., 1., 0.658824],
[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., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0., 0., 1.],
[0.501961, 0., 1.],
[0.501961, 0., 1.],
[0.501961, 0., 1.],
[0.501961, 0., 1.],
[0.501961, 0., 1.],
[0.501961, 0., 1.],
[0.501961, 0., 1.],
[0.501961, 0., 1.],
[0.501961, 0., 1.],
[0.501961, 0., 1.],
[0.501961, 0., 1.],
[0.501961, 0., 1.],
[0.501961, 0., 1.],
[0.501961, 0., 1.],
[0.501961, 0., 1.],
[0.501961, 0., 1.],
[1., 0., 0.862745],
[1., 0., 0.862745],
[1., 0., 0.862745],
[1., 0., 0.862745],
[1., 0., 0.862745],
[1., 0., 0.862745],
[1., 0., 0.862745],
[1., 0., 0.862745],
[1., 0., 0.862745],
[1., 0., 0.862745],
[1., 0., 0.862745],
[1., 0., 0.862745],
[1., 0., 0.862745],
[1., 0., 0.862745],
[1., 0., 0.862745],
[1., 0., 0.862745],
[1., 0., 0.705882],
[1., 0., 0.705882],
[1., 0., 0.705882],
[1., 0., 0.705882],
[1., 0., 0.705882],
[1., 0., 0.705882],
[1., 0., 0.705882],
[1., 0., 0.705882],
[1., 0., 0.705882],
[1., 0., 0.705882],
[1., 0., 0.705882],
[1., 0., 0.705882],
[1., 0., 0.705882],
[1., 0., 0.705882],
[1., 0., 0.705882],
[1., 0., 0.705882],
[1., 0., 0.501961],
[1., 0., 0.501961],
[1., 0., 0.501961],
[1., 0., 0.501961],
[1., 0., 0.501961],
[1., 0., 0.501961],
[1., 0., 0.501961],
[1., 0., 0.501961],
[1., 0., 0.501961],
[1., 0., 0.501961],
[1., 0., 0.501961],
[1., 0., 0.501961],
[1., 0., 0.501961],
[1., 0., 0.501961],
[1., 0., 0.501961],
[1., 0., 0.501961],
[1., 0., 0.25098],
[1., 0., 0.25098],
[1., 0., 0.25098],
[1., 0., 0.25098],
[1., 0., 0.25098],
[1., 0., 0.25098],
[1., 0., 0.25098],
[1., 0., 0.25098],
[1., 0., 0.25098],
[1., 0., 0.25098],
[1., 0., 0.25098],
[1., 0., 0.25098],
[1., 0., 0.25098],
[1., 0., 0.25098],
[1., 0., 0.25098],
[1., 0., 0.25098],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[0.862745, 0.745098, 0.745098],
[0.862745, 0.745098, 0.745098],
[0.862745, 0.745098, 0.745098],
[0.862745, 0.745098, 0.745098],
[0.862745, 0.745098, 0.745098],
[0.866667, 0.745098, 0.745098],
[0.866667, 0.745098, 0.745098],
[0.866667, 0.745098, 0.745098],
[0.866667, 0.745098, 0.745098],
[0.866667, 0.745098, 0.745098],
[0.870588, 0.745098, 0.745098],
[0.870588, 0.745098, 0.745098],
[0.870588, 0.745098, 0.745098],
[0.870588, 0.745098, 0.745098],
[0.870588, 0.745098, 0.745098],
[0.87451, 0.745098, 0.745098],
[0.862745, 0.862745, 0.862745],
[0.862745, 0.862745, 0.862745],
[0.862745, 0.862745, 0.862745],
[0.862745, 0.862745, 0.862745],
[0.862745, 0.862745, 0.862745],
[0.862745, 0.862745, 0.862745],
[0.862745, 0.862745, 0.862745],
[0.862745, 0.862745, 0.862745],
[0.862745, 0.862745, 0.862745],
[0.862745, 0.862745, 0.862745],
[0.862745, 0.862745, 0.862745],
[0.862745, 0.862745, 0.862745],
[0.862745, 0.862745, 0.862745],
[0.862745, 0.862745, 0.862745],
[0.862745, 0.862745, 0.862745],
[0.862745, 0.862745, 0.862745],
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.],
[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()
