from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.00038926, 0.000346551, 0.000249987],
[0.00114175, 0.000989297, 0.000648277],
[0.00225249, 0.00190778, 0.00116452],
[0.003715, 0.00307964, 0.001769],
[0.00552993, 0.00448905, 0.00244083],
[0.00770176, 0.00612344, 0.00316415],
[0.0102374, 0.00797218, 0.00392641],
[0.0131454, 0.0100259, 0.00471743],
[0.0164356, 0.0122762, 0.00552882],
[0.0201188, 0.014715, 0.00635364],
[0.0242069, 0.0173349, 0.00718612],
[0.0287119, 0.0201289, 0.00802144],
[0.0336469, 0.0230901, 0.00885566],
[0.0390251, 0.0262119, 0.00968554],
[0.0446557, 0.0294878, 0.0105085],
[0.0502698, 0.0329116, 0.0113226],
[0.0558811, 0.0364772, 0.0121263],
[0.0614933, 0.0401784, 0.0129186],
[0.0671096, 0.0438637, 0.013699],
[0.0727328, 0.0474728, 0.0144673],
[0.078365, 0.0510125, 0.0152236],
[0.0840083, 0.0544854, 0.0159685],
[0.0896641, 0.0578936, 0.0167028],
[0.0953339, 0.0612394, 0.0174278],
[0.101019, 0.0645243, 0.0181449],
[0.10672, 0.0677503, 0.0188557],
[0.112437, 0.0709189, 0.0195623],
[0.118172, 0.0740314, 0.0202669],
[0.123924, 0.0770894, 0.020972],
[0.129695, 0.0800939, 0.0216802],
[0.135483, 0.0830463, 0.0223945],
[0.14129, 0.0859477, 0.023118],
[0.147115, 0.0887992, 0.0238541],
[0.152959, 0.0916017, 0.0246065],
[0.15882, 0.0943563, 0.0253788],
[0.164699, 0.097064, 0.0261753],
[0.170595, 0.0997257, 0.027],
[0.176509, 0.102342, 0.0278576],
[0.18244, 0.104915, 0.0287527],
[0.188387, 0.107444, 0.0296904],
[0.194349, 0.10993, 0.0306757],
[0.200327, 0.112376, 0.0317143],
[0.20632, 0.11478, 0.0328117],
[0.212327, 0.117145, 0.033974],
[0.218347, 0.11947, 0.0352076],
[0.22438, 0.121758, 0.0365188],
[0.230425, 0.124008, 0.0379148],
[0.236482, 0.126222, 0.0394026],
[0.24255, 0.128401, 0.0409786],
[0.248627, 0.130545, 0.0426123],
[0.254714, 0.132655, 0.0443161],
[0.260808, 0.134733, 0.0460927],
[0.266911, 0.136779, 0.0479446],
[0.27302, 0.138795, 0.0498741],
[0.279135, 0.14078, 0.0518833],
[0.285255, 0.142737, 0.0539742],
[0.291379, 0.144666, 0.0561487],
[0.297506, 0.146568, 0.0584083],
[0.303635, 0.148445, 0.0607546],
[0.309766, 0.150297, 0.0631889],
[0.315897, 0.152125, 0.0657126],
[0.322027, 0.153932, 0.0683267],
[0.328156, 0.155717, 0.0710322],
[0.334282, 0.157482, 0.0738301],
[0.340405, 0.159229, 0.0767211],
[0.346523, 0.160958, 0.079706],
[0.352636, 0.162671, 0.0827854],
[0.358742, 0.164369, 0.0859598],
[0.36484, 0.166053, 0.0892299],
[0.37093, 0.167726, 0.0925959],
[0.37701, 0.169387, 0.0960584],
[0.383079, 0.171039, 0.0996175],
[0.389137, 0.172684, 0.103274],
[0.395182, 0.174321, 0.107027],
[0.401212, 0.175954, 0.110878],
[0.407228, 0.177584, 0.114826],
[0.413227, 0.179211, 0.118872],
[0.419209, 0.180838, 0.123015],
[0.425173, 0.182467, 0.127257],
[0.431117, 0.184098, 0.131596],
[0.43704, 0.185734, 0.136032],
[0.442942, 0.187376, 0.140567],
[0.448821, 0.189027, 0.145198],
[0.454676, 0.190686, 0.149927],
[0.460505, 0.192358, 0.154752],
[0.466309, 0.194042, 0.159674],
[0.472084, 0.195741, 0.164693],
[0.477832, 0.197457, 0.169807],
[0.483549, 0.199192, 0.175017],
[0.489236, 0.200946, 0.180322],
[0.49489, 0.202723, 0.185721],
[0.500511, 0.204523, 0.191213],
[0.506098, 0.206349, 0.196799],
[0.511649, 0.208203, 0.202476],
[0.517163, 0.210085, 0.208245],
[0.52264, 0.211999, 0.214104],
[0.528077, 0.213945, 0.220053],
[0.533475, 0.215926, 0.22609],
[0.538831, 0.217943, 0.232214],
[0.544144, 0.219998, 0.238423],
[0.549414, 0.222093, 0.244718],
[0.554639, 0.224229, 0.251095],
[0.559819, 0.226408, 0.257554],
[0.564951, 0.228631, 0.264092],
[0.570036, 0.230901, 0.270709],
[0.575071, 0.233219, 0.277403],
[0.580056, 0.235586, 0.28417],
[0.58499, 0.238004, 0.291011],
[0.589871, 0.240473, 0.297922],
[0.594699, 0.242997, 0.304901],
[0.599473, 0.245575, 0.311947],
[0.604191, 0.24821, 0.319056],
[0.608853, 0.250901, 0.326227],
[0.613457, 0.253652, 0.333456],
[0.618003, 0.256462, 0.340742],
[0.62249, 0.259333, 0.348082],
[0.626917, 0.262265, 0.355472],
[0.631283, 0.26526, 0.36291],
[0.635587, 0.268318, 0.370393],
[0.639829, 0.271441, 0.377918],
[0.644007, 0.274629, 0.385481],
[0.648121, 0.277882, 0.393081],
[0.65217, 0.281201, 0.400713],
[0.656154, 0.284588, 0.408375],
[0.660071, 0.288041, 0.416062],
[0.663922, 0.291561, 0.423772],
[0.667705, 0.29515, 0.431501],
[0.671421, 0.298806, 0.439246],
[0.675068, 0.302531, 0.447002],
[0.678647, 0.306324, 0.454768],
[0.682156, 0.310184, 0.462538],
[0.685596, 0.314113, 0.47031],
[0.688967, 0.31811, 0.478079],
[0.692267, 0.322175, 0.485842],
[0.695498, 0.326307, 0.493596],
[0.698658, 0.330506, 0.501337],
[0.701748, 0.334771, 0.509061],
[0.704768, 0.339103, 0.516765],
[0.707718, 0.3435, 0.524444],
[0.710597, 0.347962, 0.532096],
[0.713407, 0.352489, 0.539717],
[0.716148, 0.357078, 0.547303],
[0.718819, 0.36173, 0.554851],
[0.721422, 0.366444, 0.562358],
[0.723956, 0.371219, 0.569819],
[0.726423, 0.376053, 0.577232],
[0.728823, 0.380946, 0.584594],
[0.731156, 0.385896, 0.591902],
[0.733424, 0.390903, 0.599152],
[0.735627, 0.395965, 0.606341],
[0.737767, 0.401081, 0.613466],
[0.739844, 0.40625, 0.620525],
[0.741859, 0.41147, 0.627515],
[0.743814, 0.41674, 0.634434],
[0.74571, 0.422058, 0.641278],
[0.747548, 0.427423, 0.648045],
[0.749329, 0.432834, 0.654734],
[0.751056, 0.43829, 0.661341],
[0.75273, 0.443787, 0.667865],
[0.754352, 0.449326, 0.674305],
[0.755924, 0.454904, 0.680657],
[0.757448, 0.46052, 0.686921],
[0.758926, 0.466173, 0.693095],
[0.76036, 0.47186, 0.699178],
[0.761752, 0.47758, 0.705167],
[0.763103, 0.483332, 0.711063],
[0.764418, 0.489114, 0.716864],
[0.765696, 0.494924, 0.722569],
[0.766942, 0.500761, 0.728178],
[0.768157, 0.506622, 0.733689],
[0.769343, 0.512507, 0.739103],
[0.770504, 0.518414, 0.744419],
[0.771642, 0.524342, 0.749637],
[0.772759, 0.530288, 0.754756],
[0.773859, 0.536251, 0.759778],
[0.774943, 0.54223, 0.764701],
[0.776016, 0.548223, 0.769527],
[0.777079, 0.554228, 0.774255],
[0.778135, 0.560245, 0.778886],
[0.779187, 0.566272, 0.783422],
[0.780239, 0.572307, 0.787862],
[0.781293, 0.578349, 0.792207],
[0.782353, 0.584397, 0.796459],
[0.78342, 0.59045, 0.800619],
[0.784499, 0.596505, 0.804687],
[0.785592, 0.602562, 0.808666],
[0.786702, 0.60862, 0.812556],
[0.787832, 0.614678, 0.816359],
[0.788985, 0.620734, 0.820076],
[0.790165, 0.626787, 0.82371],
[0.791373, 0.632837, 0.827261],
[0.792614, 0.638882, 0.830732],
[0.79389, 0.644921, 0.834124],
[0.795204, 0.650954, 0.83744],
[0.796558, 0.656979, 0.840682],
[0.797956, 0.662996, 0.843851],
[0.7994, 0.669004, 0.846949],
[0.800893, 0.675002, 0.849979],
[0.802438, 0.680989, 0.852943],
[0.804037, 0.686966, 0.855844],
[0.805692, 0.69293, 0.858683],
[0.807407, 0.698882, 0.861463],
[0.809183, 0.704821, 0.864186],
[0.811023, 0.710746, 0.866854],
[0.812929, 0.716658, 0.869471],
[0.814904, 0.722555, 0.872038],
[0.816948, 0.728437, 0.874559],
[0.819064, 0.734305, 0.877034],
[0.821255, 0.740157, 0.879468],
[0.823521, 0.745993, 0.881862],
[0.825864, 0.751813, 0.88422],
[0.828286, 0.757617, 0.886542],
[0.830789, 0.763405, 0.888833],
[0.833373, 0.769177, 0.891095],
[0.836041, 0.774932, 0.89333],
[0.838792, 0.78067, 0.895541],
[0.841629, 0.786392, 0.89773],
[0.844551, 0.792097, 0.899899],
[0.847561, 0.797786, 0.902053],
[0.850658, 0.803458, 0.904192],
[0.853844, 0.809114, 0.906319],
[0.857118, 0.814754, 0.908438],
[0.860481, 0.820377, 0.91055],
[0.863934, 0.825985, 0.912658],
[0.867476, 0.831577, 0.914765],
[0.871108, 0.837154, 0.916872],
[0.87483, 0.842715, 0.918983],
[0.878641, 0.848261, 0.9211],
[0.882542, 0.853793, 0.923225],
[0.886532, 0.859311, 0.925361],
[0.890611, 0.864814, 0.92751],
[0.894779, 0.870304, 0.929675],
[0.899034, 0.875781, 0.931858],
[0.903376, 0.881245, 0.934061],
[0.907805, 0.886697, 0.936287],
[0.91232, 0.892137, 0.938539],
[0.916919, 0.897565, 0.940818],
[0.921603, 0.902983, 0.943128],
[0.926369, 0.90839, 0.945471],
[0.931216, 0.913787, 0.94785],
[0.936144, 0.919176, 0.950266],
[0.941152, 0.924555, 0.952724],
[0.946237, 0.929926, 0.955225],
[0.951398, 0.93529, 0.957773],
[0.956633, 0.940647, 0.960372],
[0.961942, 0.945998, 0.963024],
[0.967321, 0.951343, 0.965733],
[0.972768, 0.956684, 0.968504],
[0.978282, 0.96202, 0.971342],
[0.983859, 0.967353, 0.974254],
[0.989496, 0.972684, 0.977248],
[0.995188, 0.978013, 0.980335],
[1., 0.983342, 0.983535],
[1., 0.988671, 0.986883],
[1., 0.994001, 0.990529]]

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