from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.00035057, 0.000346263, 0.000396453],
[0.000996638, 0.000989766, 0.00118164],
[0.00192091, 0.00191169, 0.00235415],
[0.00310532, 0.00309146, 0.00390963],
[0.00453961, 0.00451505, 0.00584918],
[0.00621784, 0.00617178, 0.00817655],
[0.00813685, 0.00805298, 0.0108969],
[0.0102955, 0.0101512, 0.0140165],
[0.0126943, 0.0124601, 0.0175418],
[0.0153347, 0.0149735, 0.0214799],
[0.0182196, 0.0176861, 0.025838],
[0.0213525, 0.0205929, 0.0306234],
[0.0247378, 0.0236889, 0.0358435],
[0.0283807, 0.0269695, 0.0414799],
[0.032287, 0.0304302, 0.0471627],
[0.0364629, 0.0340666, 0.0528132],
[0.0409062, 0.0378746, 0.0584351],
[0.0453852, 0.0418126, 0.0640313],
[0.0498527, 0.0456921, 0.0696041],
[0.0543134, 0.0495107, 0.0751556],
[0.058771, 0.0532712, 0.0806872],
[0.0632293, 0.0569759, 0.0862002],
[0.0676913, 0.0606271, 0.0916956],
[0.0721602, 0.0642267, 0.0971741],
[0.0766384, 0.0677765, 0.102636],
[0.0811285, 0.0712779, 0.108082],
[0.0856325, 0.0747326, 0.113512],
[0.0901526, 0.0781417, 0.118926],
[0.0946904, 0.0815065, 0.124323],
[0.0992476, 0.0848283, 0.129705],
[0.103826, 0.0881079, 0.135069],
[0.108426, 0.0913464, 0.140416],
[0.11305, 0.0945447, 0.145745],
[0.117698, 0.0977038, 0.151055],
[0.122372, 0.100824, 0.156346],
[0.127072, 0.103907, 0.161616],
[0.131799, 0.106954, 0.166866],
[0.136554, 0.109964, 0.172093],
[0.141337, 0.112938, 0.177298],
[0.146149, 0.115879, 0.182478],
[0.150989, 0.118785, 0.187633],
[0.15586, 0.121658, 0.192761],
[0.160759, 0.124498, 0.197862],
[0.165689, 0.127307, 0.202934],
[0.170648, 0.130085, 0.207977],
[0.175638, 0.132832, 0.212987],
[0.180657, 0.13555, 0.217965],
[0.185706, 0.138238, 0.22291],
[0.190784, 0.140899, 0.227819],
[0.195892, 0.143532, 0.232691],
[0.201029, 0.146138, 0.237525],
[0.206194, 0.148718, 0.242321],
[0.211388, 0.151274, 0.247075],
[0.216611, 0.153804, 0.251787],
[0.22186, 0.156311, 0.256456],
[0.227137, 0.158796, 0.261081],
[0.23244, 0.161258, 0.265659],
[0.23777, 0.163699, 0.27019],
[0.243124, 0.166121, 0.274672],
[0.248504, 0.168522, 0.279104],
[0.253907, 0.170906, 0.283485],
[0.259334, 0.173271, 0.287814],
[0.264784, 0.175621, 0.292088],
[0.270256, 0.177954, 0.296308],
[0.275749, 0.180274, 0.300472],
[0.281262, 0.182579, 0.304578],
[0.286795, 0.184872, 0.308626],
[0.292346, 0.187153, 0.312615],
[0.297916, 0.189423, 0.316543],
[0.303503, 0.191684, 0.32041],
[0.309105, 0.193937, 0.324215],
[0.314723, 0.196182, 0.327956],
[0.320356, 0.198421, 0.331633],
[0.326001, 0.200654, 0.335246],
[0.33166, 0.202884, 0.338793],
[0.337329, 0.20511, 0.342274],
[0.34301, 0.207334, 0.345688],
[0.3487, 0.209558, 0.349035],
[0.354398, 0.211782, 0.352313],
[0.360104, 0.214008, 0.355524],
[0.365817, 0.216236, 0.358665],
[0.371536, 0.218468, 0.361738],
[0.377259, 0.220704, 0.364741],
[0.382986, 0.222947, 0.367675],
[0.388715, 0.225197, 0.370539],
[0.394446, 0.227455, 0.373333],
[0.400178, 0.229723, 0.376058],
[0.40591, 0.232001, 0.378713],
[0.41164, 0.234291, 0.381299],
[0.417367, 0.236593, 0.383815],
[0.423092, 0.23891, 0.386262],
[0.428812, 0.241241, 0.388641],
[0.434526, 0.243589, 0.390951],
[0.440234, 0.245953, 0.393194],
[0.445935, 0.248336, 0.395369],
[0.451627, 0.250738, 0.397477],
[0.45731, 0.25316, 0.39952],
[0.462983, 0.255604, 0.401497],
[0.468644, 0.258069, 0.40341],
[0.474293, 0.260558, 0.405259],
[0.479929, 0.263071, 0.407046],
[0.48555, 0.265609, 0.40877],
[0.491156, 0.268173, 0.410435],
[0.496746, 0.270764, 0.41204],
[0.502319, 0.273383, 0.413586],
[0.507874, 0.276031, 0.415075],
[0.51341, 0.278707, 0.416509],
[0.518926, 0.281415, 0.417888],
[0.524421, 0.284153, 0.419215],
[0.529894, 0.286923, 0.420489],
[0.535344, 0.289726, 0.421714],
[0.540771, 0.292561, 0.42289],
[0.546174, 0.295431, 0.424019],
[0.551551, 0.298336, 0.425104],
[0.556902, 0.301275, 0.426145],
[0.562226, 0.304251, 0.427144],
[0.567522, 0.307263, 0.428103],
[0.572789, 0.310312, 0.429024],
[0.578027, 0.313398, 0.42991],
[0.583234, 0.316523, 0.430761],
[0.58841, 0.319686, 0.43158],
[0.593554, 0.322888, 0.432369],
[0.598665, 0.326129, 0.433129],
[0.603742, 0.32941, 0.433864],
[0.608786, 0.332732, 0.434575],
[0.613794, 0.336093, 0.435264],
[0.618766, 0.339496, 0.435934],
[0.623701, 0.34294, 0.436586],
[0.6286, 0.346425, 0.437224],
[0.63346, 0.349951, 0.437849],
[0.638281, 0.35352, 0.438463],
[0.643063, 0.35713, 0.439069],
[0.647805, 0.360783, 0.43967],
[0.652506, 0.364478, 0.440267],
[0.657166, 0.368215, 0.440863],
[0.661784, 0.371995, 0.44146],
[0.666359, 0.375817, 0.442062],
[0.670891, 0.379682, 0.44267],
[0.675379, 0.383589, 0.443286],
[0.679823, 0.387539, 0.443914],
[0.684222, 0.391532, 0.444556],
[0.688576, 0.395567, 0.445214],
[0.692883, 0.399644, 0.44589],
[0.697145, 0.403764, 0.446588],
[0.701359, 0.407926, 0.44731],
[0.705526, 0.412129, 0.448058],
[0.709646, 0.416375, 0.448835],
[0.713717, 0.420662, 0.449643],
[0.71774, 0.42499, 0.450486],
[0.721713, 0.42936, 0.451364],
[0.725638, 0.43377, 0.452282],
[0.729513, 0.438221, 0.453241],
[0.733338, 0.442712, 0.454244],
[0.737113, 0.447242, 0.455294],
[0.740838, 0.451813, 0.456393],
[0.744513, 0.456422, 0.457543],
[0.748136, 0.46107, 0.458747],
[0.751709, 0.465757, 0.460007],
[0.755231, 0.470481, 0.461326],
[0.758702, 0.475242, 0.462706],
[0.762122, 0.480041, 0.46415],
[0.76549, 0.484876, 0.465659],
[0.768808, 0.489746, 0.467237],
[0.772075, 0.494653, 0.468885],
[0.77529, 0.499593, 0.470606],
[0.778455, 0.504568, 0.472402],
[0.781569, 0.509577, 0.474274],
[0.784633, 0.514618, 0.476226],
[0.787647, 0.519692, 0.478259],
[0.790611, 0.524798, 0.480375],
[0.793525, 0.529935, 0.482577],
[0.796391, 0.535102, 0.484865],
[0.799207, 0.540298, 0.487243],
[0.801975, 0.545524, 0.489711],
[0.804696, 0.550778, 0.492271],
[0.80737, 0.556059, 0.494926],
[0.809997, 0.561367, 0.497677],
[0.812578, 0.566701, 0.500525],
[0.815114, 0.57206, 0.503471],
[0.817606, 0.577444, 0.506518],
[0.820055, 0.582851, 0.509666],
[0.822461, 0.588281, 0.512917],
[0.824825, 0.593733, 0.516272],
[0.827149, 0.599206, 0.519732],
[0.829434, 0.604699, 0.523297],
[0.83168, 0.610212, 0.526969],
[0.833889, 0.615743, 0.530749],
[0.836063, 0.621292, 0.534636],
[0.838202, 0.626858, 0.538633],
[0.840308, 0.63244, 0.542739],
[0.842382, 0.638037, 0.546954],
[0.844426, 0.643648, 0.55128],
[0.846442, 0.649272, 0.555716],
[0.848431, 0.654909, 0.560262],
[0.850394, 0.660558, 0.564919],
[0.852335, 0.666217, 0.569686],
[0.854254, 0.671885, 0.574564],
[0.856153, 0.677563, 0.579551],
[0.858035, 0.683248, 0.584648],
[0.859902, 0.688941, 0.589853],
[0.861755, 0.694639, 0.595168],
[0.863596, 0.700343, 0.60059],
[0.865429, 0.706052, 0.606119],
[0.867255, 0.711763, 0.611754],
[0.869077, 0.717478, 0.617494],
[0.870897, 0.723195, 0.623339],
[0.872717, 0.728912, 0.629286],
[0.874541, 0.73463, 0.635335],
[0.87637, 0.740347, 0.641484],
[0.878207, 0.746063, 0.647732],
[0.880055, 0.751776, 0.654077],
[0.881916, 0.757487, 0.660518],
[0.883794, 0.763194, 0.667052],
[0.885691, 0.768896, 0.673679],
[0.88761, 0.774594, 0.680396],
[0.889553, 0.780285, 0.6872],
[0.891523, 0.78597, 0.694091],
[0.893524, 0.791648, 0.701066],
[0.895558, 0.797319, 0.708122],
[0.897628, 0.802981, 0.715258],
[0.899737, 0.808634, 0.72247],
[0.901887, 0.814278, 0.729757],
[0.904082, 0.819912, 0.737115],
[0.906325, 0.825535, 0.744543],
[0.908617, 0.831148, 0.752038],
[0.910963, 0.83675, 0.759596],
[0.913364, 0.84234, 0.767215],
[0.915823, 0.847919, 0.774892],
[0.918344, 0.853485, 0.782624],
[0.920928, 0.859039, 0.790409],
[0.923579, 0.86458, 0.798242],
[0.926298, 0.870108, 0.806122],
[0.929088, 0.875623, 0.814043],
[0.931952, 0.881126, 0.822005],
[0.934892, 0.886615, 0.830002],
[0.93791, 0.892091, 0.838032],
[0.941008, 0.897554, 0.846091],
[0.944188, 0.903004, 0.854176],
[0.947452, 0.908441, 0.862282],
[0.950802, 0.913865, 0.870407],
[0.95424, 0.919277, 0.878545],
[0.957767, 0.924676, 0.886694],
[0.961386, 0.930064, 0.894849],
[0.965096, 0.93544, 0.903005],
[0.968901, 0.940805, 0.911158],
[0.9728, 0.946159, 0.919302],
[0.976796, 0.951503, 0.927432],
[0.98089, 0.956838, 0.935541],
[0.985082, 0.962164, 0.943622],
[0.989375, 0.967483, 0.951667],
[0.99377, 0.972794, 0.959663],
[0.998269, 0.9781, 0.967595],
[1., 0.983401, 0.975439],
[1., 0.9887, 0.983147],
[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()
