from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.874607, 0.555776, 0.0185319],
[0.867178, 0.55459, 0.0469253],
[0.859775, 0.553379, 0.0693763],
[0.852403, 0.552145, 0.0873397],
[0.845059, 0.550887, 0.102661],
[0.837743, 0.549605, 0.116209],
[0.830455, 0.5483, 0.128451],
[0.823195, 0.546972, 0.139694],
[0.815965, 0.545622, 0.150132],
[0.808762, 0.54425, 0.159904],
[0.801586, 0.542854, 0.169117],
[0.794441, 0.541437, 0.177847],
[0.787322, 0.539999, 0.18616],
[0.780232, 0.538539, 0.194099],
[0.773169, 0.537057, 0.201709],
[0.766135, 0.535555, 0.20902],
[0.759129, 0.534032, 0.216058],
[0.75215, 0.532488, 0.22285],
[0.745199, 0.530923, 0.229409],
[0.738276, 0.529339, 0.23576],
[0.731381, 0.527734, 0.241911],
[0.724514, 0.526111, 0.247879],
[0.717673, 0.524466, 0.253673],
[0.710862, 0.522803, 0.259302],
[0.704078, 0.521121, 0.264777],
[0.697322, 0.51942, 0.270104],
[0.690592, 0.517699, 0.275291],
[0.683892, 0.51596, 0.280343],
[0.677219, 0.514203, 0.285269],
[0.670574, 0.512427, 0.290069],
[0.663955, 0.510633, 0.294751],
[0.657365, 0.508821, 0.29932],
[0.650804, 0.506992, 0.303776],
[0.644269, 0.505145, 0.308127],
[0.637762, 0.50328, 0.31237],
[0.631284, 0.501398, 0.316516],
[0.624834, 0.499499, 0.320561],
[0.618412, 0.497583, 0.324511],
[0.612017, 0.495649, 0.328367],
[0.605652, 0.4937, 0.33213],
[0.599315, 0.491733, 0.335805],
[0.593008, 0.48975, 0.33939],
[0.586727, 0.48775, 0.342889],
[0.580477, 0.485734, 0.346303],
[0.574256, 0.483702, 0.349634],
[0.568064, 0.481654, 0.352883],
[0.561902, 0.479588, 0.356048],
[0.55577, 0.477508, 0.359134],
[0.549669, 0.475411, 0.36214],
[0.543599, 0.473299, 0.365068],
[0.53756, 0.471169, 0.367916],
[0.531553, 0.469025, 0.370688],
[0.525579, 0.466864, 0.373383],
[0.519637, 0.464686, 0.375999],
[0.513731, 0.462493, 0.378541],
[0.507859, 0.460284, 0.381006],
[0.502024, 0.458058, 0.383395],
[0.496226, 0.455815, 0.385707],
[0.490467, 0.453555, 0.387943],
[0.48475, 0.451278, 0.390103],
[0.479076, 0.448982, 0.392185],
[0.473448, 0.446667, 0.394189],
[0.46787, 0.444332, 0.396115],
[0.462348, 0.441976, 0.397962],
[0.458392, 0.441071, 0.401166],
[0.459018, 0.444566, 0.408625],
[0.45971, 0.448032, 0.416024],
[0.46049, 0.451464, 0.423355],
[0.461387, 0.454853, 0.430604],
[0.462445, 0.458189, 0.437742],
[0.463718, 0.461452, 0.44471],
[0.465263, 0.464636, 0.451408],
[0.467084, 0.467754, 0.457704],
[0.469069, 0.470859, 0.46354],
[0.471043, 0.474008, 0.469015],
[0.472892, 0.477227, 0.474322],
[0.474599, 0.480508, 0.479608],
[0.476185, 0.483835, 0.484949],
[0.47767, 0.487195, 0.490372],
[0.479074, 0.490579, 0.495887],
[0.480408, 0.493983, 0.501494],
[0.481681, 0.497404, 0.507194],
[0.482896, 0.50084, 0.512982],
[0.484055, 0.504289, 0.518857],
[0.485162, 0.507752, 0.524817],
[0.486218, 0.511227, 0.530862],
[0.487221, 0.514714, 0.536989],
[0.488172, 0.518212, 0.543199],
[0.489072, 0.521722, 0.54949],
[0.489921, 0.525245, 0.555865],
[0.490717, 0.528778, 0.56232],
[0.491459, 0.532322, 0.568856],
[0.492147, 0.535877, 0.575475],
[0.492781, 0.539445, 0.582178],
[0.493358, 0.543022, 0.588962],
[0.493878, 0.546611, 0.59583],
[0.494339, 0.550211, 0.602783],
[0.494743, 0.553822, 0.609821],
[0.495084, 0.557444, 0.616944],
[0.495363, 0.561076, 0.624154],
[0.495579, 0.56472, 0.631452],
[0.49573, 0.568375, 0.638838],
[0.495813, 0.57204, 0.646315],
[0.495828, 0.575716, 0.653882],
[0.495774, 0.579404, 0.661541],
[0.495646, 0.583101, 0.669293],
[0.495444, 0.586809, 0.677139],
[0.495166, 0.590528, 0.685081],
[0.494811, 0.594258, 0.693121],
[0.494374, 0.597998, 0.701259],
[0.493854, 0.601748, 0.709496],
[0.49325, 0.605508, 0.717834],
[0.492558, 0.60928, 0.726277],
[0.491775, 0.613061, 0.734823],
[0.490898, 0.616852, 0.743475],
[0.489925, 0.620653, 0.752234],
[0.488853, 0.624465, 0.761104],
[0.487677, 0.628286, 0.770085],
[0.486396, 0.632116, 0.779177],
[0.485005, 0.635956, 0.788385],
[0.483501, 0.639806, 0.797709],
[0.481879, 0.643665, 0.807152],
[0.480135, 0.647532, 0.816714],
[0.478264, 0.651409, 0.8264],
[0.476263, 0.655295, 0.836212],
[0.474126, 0.659189, 0.846147],
[0.471846, 0.663091, 0.856213],
[0.46942, 0.667002, 0.866408],
[0.472757, 0.670359, 0.86992],
[0.481834, 0.673157, 0.866734],
[0.490741, 0.675957, 0.86366],
[0.499486, 0.678758, 0.8607],
[0.508081, 0.681563, 0.857849],
[0.516533, 0.684371, 0.855103],
[0.524848, 0.687182, 0.852464],
[0.533037, 0.689997, 0.849926],
[0.541105, 0.692819, 0.847492],
[0.549057, 0.695645, 0.845155],
[0.5569, 0.698476, 0.842916],
[0.56464, 0.701314, 0.840771],
[0.572281, 0.70416, 0.838721],
[0.579826, 0.707012, 0.836763],
[0.587282, 0.709871, 0.834894],
[0.594651, 0.712738, 0.833117],
[0.601939, 0.715614, 0.831426],
[0.609146, 0.718498, 0.829823],
[0.616278, 0.721391, 0.828303],
[0.623337, 0.724293, 0.826867],
[0.630328, 0.727205, 0.825516],
[0.63725, 0.730126, 0.824245],
[0.644108, 0.733058, 0.823055],
[0.650903, 0.735999, 0.821944],
[0.65764, 0.738952, 0.820913],
[0.664318, 0.741915, 0.819959],
[0.67094, 0.744888, 0.819081],
[0.67751, 0.747874, 0.818282],
[0.684026, 0.750871, 0.817557],
[0.690492, 0.753879, 0.816906],
[0.696909, 0.756899, 0.816331],
[0.70328, 0.759932, 0.81583],
[0.709604, 0.762977, 0.815402],
[0.715883, 0.766034, 0.815047],
[0.722118, 0.769104, 0.814765],
[0.728313, 0.772188, 0.814557],
[0.734464, 0.775284, 0.814421],
[0.740575, 0.778393, 0.814359],
[0.746647, 0.781516, 0.814369],
[0.75268, 0.784655, 0.814454],
[0.758673, 0.787806, 0.814613],
[0.764628, 0.790972, 0.814847],
[0.770544, 0.794152, 0.815157],
[0.776423, 0.79735, 0.815546],
[0.78226, 0.800562, 0.816014],
[0.788057, 0.80379, 0.816563],
[0.793811, 0.807037, 0.817196],
[0.799519, 0.810304, 0.817918],
[0.805173, 0.813591, 0.818728],
[0.810767, 0.816903, 0.819632],
[0.816285, 0.820247, 0.820629],
[0.82171, 0.823632, 0.82171],
[0.82701, 0.827072, 0.822842],
[0.832163, 0.830586, 0.82394],
[0.837188, 0.834185, 0.824835],
[0.842212, 0.837844, 0.825305],
[0.847436, 0.841491, 0.825226],
[0.852991, 0.845069, 0.824664],
[0.858879, 0.84856, 0.823765],
[0.86504, 0.851976, 0.822645],
[0.87141, 0.855332, 0.821366],
[0.877944, 0.858644, 0.819963],
[0.884611, 0.861922, 0.818451],
[0.891391, 0.865173, 0.816839],
[0.892327, 0.862587, 0.809426],
[0.891359, 0.858047, 0.800043],
[0.890456, 0.853492, 0.790597],
[0.889609, 0.848924, 0.781089],
[0.888816, 0.844345, 0.771524],
[0.888072, 0.839756, 0.761901],
[0.887374, 0.835157, 0.752222],
[0.886716, 0.830548, 0.742486],
[0.886099, 0.82593, 0.732699],
[0.88552, 0.821304, 0.722858],
[0.884975, 0.816669, 0.712966],
[0.884463, 0.812025, 0.703021],
[0.883983, 0.807373, 0.693027],
[0.883532, 0.802713, 0.682983],
[0.883109, 0.798043, 0.672889],
[0.882714, 0.793366, 0.662746],
[0.882343, 0.78868, 0.652556],
[0.881997, 0.783986, 0.642316],
[0.881672, 0.779281, 0.632028],
[0.881369, 0.774569, 0.621691],
[0.881087, 0.769848, 0.611307],
[0.880824, 0.765117, 0.600875],
[0.880578, 0.760376, 0.590392],
[0.88035, 0.755627, 0.579863],
[0.880137, 0.750868, 0.569283],
[0.87994, 0.746099, 0.558655],
[0.879755, 0.741319, 0.547974],
[0.879584, 0.73653, 0.537241],
[0.879425, 0.731731, 0.526459],
[0.879277, 0.726921, 0.51562],
[0.879137, 0.722099, 0.504727],
[0.879008, 0.717268, 0.493777],
[0.878886, 0.712425, 0.48277],
[0.878773, 0.707571, 0.4717],
[0.878664, 0.702704, 0.460566],
[0.878562, 0.697827, 0.449368],
[0.878464, 0.692938, 0.4381],
[0.87837, 0.688037, 0.42676],
[0.878278, 0.683122, 0.41534],
[0.878189, 0.678197, 0.403841],
[0.878102, 0.673258, 0.392253],
[0.878014, 0.668307, 0.380572],
[0.877926, 0.663341, 0.368787],
[0.877837, 0.658363, 0.356894],
[0.877746, 0.653373, 0.344882],
[0.877653, 0.648368, 0.332738],
[0.877554, 0.643349, 0.32045],
[0.877452, 0.638317, 0.308],
[0.877345, 0.633271, 0.295374],
[0.877233, 0.62821, 0.282543],
[0.877112, 0.623134, 0.269482],
[0.876985, 0.618045, 0.256163],
[0.87685, 0.612941, 0.242538],
[0.876705, 0.607822, 0.228562],
[0.876551, 0.602686, 0.214161],
[0.876386, 0.597537, 0.199258],
[0.876211, 0.592372, 0.183732],
[0.876024, 0.587192, 0.167426],
[0.875822, 0.581995, 0.150114],
[0.875609, 0.576784, 0.13144],
[0.875382, 0.571556, 0.110832],
[0.87514, 0.566313, 0.0871996],
[0.874881, 0.561052, 0.0580595],
[0.874607, 0.555776, 0.0185319]]

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()
