from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000374163, 0.000347346, 0.000297641],
[0.00108157, 0.000994643, 0.00081651],
[0.00210723, 0.00192467, 0.00153118],
[0.00343423, 0.00311863, 0.00241583],
[0.00505239, 0.00456448, 0.00345238],
[0.006955, 0.00625366, 0.00462695],
[0.00913745, 0.00817979, 0.00592834],
[0.0115965, 0.0103379, 0.00734715],
[0.0143299, 0.012724, 0.00887532],
[0.0173362, 0.015335, 0.0105058],
[0.0206143, 0.0181681, 0.0122322],
[0.0241638, 0.0212213, 0.0140491],
[0.0279846, 0.0244929, 0.0159511],
[0.0320768, 0.0279813, 0.0179338],
[0.0364407, 0.0316854, 0.0199926],
[0.0410638, 0.0356042, 0.0221237],
[0.0456909, 0.0397369, 0.0243232],
[0.0502733, 0.0439326, 0.0265877],
[0.0548151, 0.0480737, 0.0289139],
[0.0593195, 0.052172, 0.0312986],
[0.0637897, 0.0562306, 0.033739],
[0.0682284, 0.0602522, 0.0362321],
[0.0726379, 0.0642393, 0.0387754],
[0.0770206, 0.0681943, 0.0413449],
[0.0813784, 0.072119, 0.043857],
[0.0857132, 0.0760154, 0.0463214],
[0.0900265, 0.0798852, 0.0487401],
[0.09432, 0.0837299, 0.0511149],
[0.098595, 0.087551, 0.0534473],
[0.102853, 0.0913497, 0.0557388],
[0.107095, 0.0951273, 0.0579909],
[0.111322, 0.098885, 0.0602048],
[0.115535, 0.102624, 0.0623816],
[0.119735, 0.106345, 0.0645226],
[0.123924, 0.110049, 0.0666286],
[0.128101, 0.113736, 0.0687007],
[0.132268, 0.117409, 0.0707398],
[0.136426, 0.121067, 0.0727467],
[0.140575, 0.124711, 0.0747221],
[0.144716, 0.128342, 0.0766669],
[0.148849, 0.13196, 0.0785818],
[0.152975, 0.135566, 0.0804673],
[0.157095, 0.139162, 0.0823241],
[0.161209, 0.142746, 0.0841527],
[0.165318, 0.14632, 0.0859538],
[0.169422, 0.149885, 0.0877279],
[0.173522, 0.15344, 0.0894754],
[0.177618, 0.156986, 0.0911967],
[0.18171, 0.160524, 0.0928924],
[0.185799, 0.164054, 0.0945628],
[0.189886, 0.167576, 0.0962084],
[0.193971, 0.171091, 0.0978295],
[0.198053, 0.174599, 0.0994264],
[0.202135, 0.178101, 0.101],
[0.206215, 0.181596, 0.102549],
[0.210294, 0.185086, 0.104076],
[0.214372, 0.18857, 0.105579],
[0.21845, 0.192049, 0.10706],
[0.222529, 0.195523, 0.108518],
[0.226607, 0.198992, 0.109955],
[0.230687, 0.202457, 0.111369],
[0.234767, 0.205917, 0.112762],
[0.238848, 0.209374, 0.114133],
[0.24293, 0.212827, 0.115483],
[0.247015, 0.216277, 0.116812],
[0.251101, 0.219723, 0.11812],
[0.255189, 0.223167, 0.119407],
[0.259279, 0.226607, 0.120673],
[0.263373, 0.230045, 0.121919],
[0.267468, 0.233481, 0.123144],
[0.271567, 0.236915, 0.12435],
[0.275669, 0.240347, 0.125535],
[0.279774, 0.243777, 0.1267],
[0.283883, 0.247205, 0.127845],
[0.287996, 0.250632, 0.12897],
[0.292112, 0.254058, 0.130076],
[0.296233, 0.257483, 0.131162],
[0.300358, 0.260907, 0.132228],
[0.304487, 0.26433, 0.133275],
[0.308621, 0.267752, 0.134303],
[0.31276, 0.271174, 0.135311],
[0.316904, 0.274596, 0.136299],
[0.321053, 0.278018, 0.137269],
[0.325207, 0.28144, 0.138219],
[0.329367, 0.284862, 0.139149],
[0.333532, 0.288284, 0.140061],
[0.337703, 0.291707, 0.140953],
[0.34188, 0.29513, 0.141826],
[0.346063, 0.298555, 0.14268],
[0.350253, 0.30198, 0.143515],
[0.354448, 0.305405, 0.14433],
[0.358651, 0.308832, 0.145126],
[0.362859, 0.312261, 0.145903],
[0.367075, 0.31569, 0.146661],
[0.371298, 0.319122, 0.147399],
[0.375527, 0.322554, 0.148118],
[0.379764, 0.325989, 0.148817],
[0.384008, 0.329425, 0.149497],
[0.38826, 0.332863, 0.150158],
[0.392519, 0.336303, 0.150799],
[0.396786, 0.339746, 0.15142],
[0.40106, 0.34319, 0.152021],
[0.405343, 0.346637, 0.152603],
[0.409634, 0.350087, 0.153165],
[0.413933, 0.353539, 0.153707],
[0.41824, 0.356994, 0.154229],
[0.422556, 0.360452, 0.154731],
[0.426881, 0.363912, 0.155212],
[0.431214, 0.367376, 0.155673],
[0.435556, 0.370842, 0.156113],
[0.439907, 0.374312, 0.156533],
[0.444267, 0.377785, 0.156932],
[0.448636, 0.381262, 0.15731],
[0.453015, 0.384742, 0.157667],
[0.457403, 0.388225, 0.158003],
[0.461801, 0.391713, 0.158318],
[0.466208, 0.395204, 0.15861],
[0.470625, 0.398699, 0.158881],
[0.475052, 0.402198, 0.15913],
[0.479489, 0.405701, 0.159357],
[0.483936, 0.409208, 0.159562],
[0.488393, 0.412719, 0.159744],
[0.492861, 0.416235, 0.159903],
[0.497339, 0.419755, 0.160039],
[0.501828, 0.423279, 0.160152],
[0.506327, 0.426809, 0.160241],
[0.510838, 0.430343, 0.160307],
[0.514735, 0.434044, 0.16359],
[0.518013, 0.437912, 0.170072],
[0.521294, 0.441784, 0.176511],
[0.524578, 0.44566, 0.182912],
[0.527867, 0.44954, 0.189279],
[0.531159, 0.453424, 0.195617],
[0.534455, 0.457313, 0.201929],
[0.537756, 0.461207, 0.208218],
[0.54106, 0.465105, 0.214487],
[0.54437, 0.469007, 0.220739],
[0.547684, 0.472915, 0.226976],
[0.551003, 0.476827, 0.2332],
[0.554327, 0.480744, 0.239412],
[0.557657, 0.484667, 0.245616],
[0.560992, 0.488594, 0.251811],
[0.564332, 0.492527, 0.257999],
[0.567679, 0.496465, 0.264183],
[0.571031, 0.500409, 0.270362],
[0.574389, 0.504358, 0.276538],
[0.577754, 0.508313, 0.282712],
[0.581125, 0.512273, 0.288884],
[0.584503, 0.51624, 0.295057],
[0.587888, 0.520212, 0.301229],
[0.59128, 0.524191, 0.307403],
[0.594678, 0.528175, 0.313578],
[0.598084, 0.532166, 0.319755],
[0.601498, 0.536164, 0.325935],
[0.604919, 0.540167, 0.332119],
[0.608348, 0.544178, 0.338306],
[0.611784, 0.548195, 0.344497],
[0.615229, 0.552219, 0.350693],
[0.618682, 0.55625, 0.356894],
[0.622144, 0.560287, 0.3631],
[0.625614, 0.564332, 0.369312],
[0.629092, 0.568385, 0.37553],
[0.63258, 0.572444, 0.381753],
[0.636076, 0.576511, 0.387984],
[0.639582, 0.580586, 0.394221],
[0.643097, 0.584668, 0.400465],
[0.646621, 0.588758, 0.406716],
[0.650155, 0.592856, 0.412974],
[0.653699, 0.596962, 0.41924],
[0.657253, 0.601076, 0.425514],
[0.660816, 0.605198, 0.431795],
[0.66439, 0.609328, 0.438085],
[0.667975, 0.613467, 0.444383],
[0.671569, 0.617615, 0.450689],
[0.675175, 0.621771, 0.457003],
[0.678791, 0.625937, 0.463326],
[0.682418, 0.630111, 0.469658],
[0.686056, 0.634294, 0.475998],
[0.689706, 0.638486, 0.482347],
[0.693367, 0.642687, 0.488705],
[0.697039, 0.646898, 0.495073],
[0.700723, 0.651119, 0.501449],
[0.704419, 0.655349, 0.507834],
[0.708127, 0.659589, 0.514229],
[0.711847, 0.663838, 0.520633],
[0.71558, 0.668098, 0.527046],
[0.719325, 0.672368, 0.533469],
[0.723082, 0.676648, 0.539901],
[0.726852, 0.680938, 0.546343],
[0.730635, 0.685239, 0.552795],
[0.734431, 0.689551, 0.559256],
[0.73824, 0.693873, 0.565726],
[0.742063, 0.698206, 0.572207],
[0.745899, 0.70255, 0.578697],
[0.749748, 0.706906, 0.585197],
[0.753612, 0.711272, 0.591706],
[0.757489, 0.71565, 0.598226],
[0.76138, 0.720039, 0.604755],
[0.765286, 0.724441, 0.611294],
[0.769206, 0.728853, 0.617844],
[0.77314, 0.733278, 0.624403],
[0.77709, 0.737715, 0.630972],
[0.781054, 0.742164, 0.63755],
[0.785033, 0.746626, 0.644139],
[0.789027, 0.751099, 0.650738],
[0.793037, 0.755586, 0.657347],
[0.797062, 0.760085, 0.663965],
[0.801103, 0.764597, 0.670594],
[0.80516, 0.769122, 0.677232],
[0.809232, 0.77366, 0.68388],
[0.813321, 0.778212, 0.690539],
[0.817426, 0.782777, 0.697207],
[0.821548, 0.787355, 0.703885],
[0.825686, 0.791947, 0.710573],
[0.829841, 0.796553, 0.71727],
[0.834013, 0.801174, 0.723978],
[0.838202, 0.805808, 0.730695],
[0.842409, 0.810456, 0.737421],
[0.846633, 0.81512, 0.744158],
[0.850874, 0.819797, 0.750904],
[0.855134, 0.82449, 0.757659],
[0.859412, 0.829197, 0.764424],
[0.863708, 0.833919, 0.771198],
[0.868023, 0.838657, 0.777981],
[0.872356, 0.84341, 0.784774],
[0.876708, 0.848179, 0.791575],
[0.881079, 0.852963, 0.798386],
[0.88547, 0.857763, 0.805205],
[0.88988, 0.862579, 0.812033],
[0.894309, 0.867412, 0.818869],
[0.898759, 0.87226, 0.825713],
[0.903229, 0.877126, 0.832566],
[0.907719, 0.882008, 0.839426],
[0.91223, 0.886906, 0.846293],
[0.916762, 0.891822, 0.853168],
[0.921315, 0.896755, 0.86005],
[0.92589, 0.901706, 0.866938],
[0.930486, 0.906673, 0.873832],
[0.935105, 0.911659, 0.880731],
[0.939746, 0.916663, 0.887636],
[0.944409, 0.921684, 0.894545],
[0.949096, 0.926724, 0.901457],
[0.953806, 0.931783, 0.908372],
[0.95854, 0.93686, 0.915288],
[0.963299, 0.941955, 0.922205],
[0.968083, 0.94707, 0.92912],
[0.972893, 0.952205, 0.936033],
[0.977728, 0.957358, 0.94294],
[0.982592, 0.962532, 0.949839],
[0.987484, 0.967725, 0.956725],
[0.992405, 0.972938, 0.963594],
[0.997359, 0.978172, 0.970436],
[1., 0.983427, 0.977239],
[1., 0.988703, 0.983975],
[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()
