from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000400085, 0.000332284, 0.000344068],
[0.00117697, 0.000939427, 0.000985067],
[0.00232158, 0.00180099, 0.00190599],
[0.00382216, 0.00289535, 0.0030883],
[0.00567315, 0.00420797, 0.00452012],
[0.00787202, 0.00572808, 0.00619309],
[0.010418, 0.00744721, 0.00810099],
[0.0133116, 0.00935846, 0.010239],
[0.016554, 0.011456, 0.0126033],
[0.020147, 0.013735, 0.0151909],
[0.024093, 0.016191, 0.0179993],
[0.0283946, 0.0188203, 0.0210264],
[0.0330547, 0.0216195, 0.0242708],
[0.0380765, 0.0245856, 0.0277311],
[0.0433508, 0.0277159, 0.0314062],
[0.0485814, 0.031008, 0.0352953],
[0.0537716, 0.0344595, 0.0393979],
[0.0589256, 0.0380684, 0.0435862],
[0.0640471, 0.0417962, 0.0477194],
[0.0691393, 0.0454754, 0.0518106],
[0.074205, 0.0491075, 0.055863],
[0.0792468, 0.0526955, 0.0598793],
[0.084267, 0.0562419, 0.063862],
[0.0892676, 0.0597491, 0.0678134],
[0.0942505, 0.0632192, 0.0717354],
[0.0992174, 0.0666541, 0.0756299],
[0.10417, 0.0700555, 0.0794987],
[0.109109, 0.0734252, 0.0833432],
[0.114037, 0.0767645, 0.0871648],
[0.118954, 0.0800748, 0.090965],
[0.123862, 0.0833575, 0.094745],
[0.128761, 0.0866137, 0.0985058],
[0.133653, 0.0898445, 0.102249],
[0.138538, 0.0930508, 0.105974],
[0.143418, 0.0962338, 0.109684],
[0.148293, 0.0993942, 0.113378],
[0.153164, 0.102533, 0.117058],
[0.158031, 0.105651, 0.120724],
[0.162896, 0.108748, 0.124377],
[0.167758, 0.111826, 0.128018],
[0.172619, 0.114885, 0.131647],
[0.177479, 0.117926, 0.135265],
[0.182339, 0.12095, 0.138872],
[0.187198, 0.123956, 0.14247],
[0.192058, 0.126946, 0.146058],
[0.19692, 0.12992, 0.149637],
[0.201782, 0.132878, 0.153208],
[0.206647, 0.135821, 0.156771],
[0.211513, 0.138749, 0.160327],
[0.216383, 0.141663, 0.163875],
[0.221255, 0.144563, 0.167416],
[0.226131, 0.14745, 0.170951],
[0.231011, 0.150323, 0.17448],
[0.235895, 0.153184, 0.178004],
[0.240783, 0.156032, 0.181522],
[0.245676, 0.158868, 0.185035],
[0.250574, 0.161692, 0.188544],
[0.255477, 0.164504, 0.192048],
[0.260386, 0.167305, 0.195548],
[0.265301, 0.170095, 0.199044],
[0.270221, 0.172874, 0.202537],
[0.275149, 0.175643, 0.206026],
[0.280083, 0.178401, 0.209513],
[0.285024, 0.181149, 0.212996],
[0.289972, 0.183888, 0.216478],
[0.294927, 0.186616, 0.219957],
[0.29989, 0.189335, 0.223433],
[0.304861, 0.192045, 0.226908],
[0.30984, 0.194746, 0.230382],
[0.314827, 0.197438, 0.233854],
[0.319823, 0.200121, 0.237325],
[0.324827, 0.202796, 0.240794],
[0.32984, 0.205462, 0.244263],
[0.334862, 0.20812, 0.247732],
[0.339894, 0.21077, 0.251199],
[0.344935, 0.213412, 0.254667],
[0.349985, 0.216046, 0.258134],
[0.355046, 0.218673, 0.261602],
[0.360116, 0.221292, 0.26507],
[0.365197, 0.223903, 0.268538],
[0.370288, 0.226508, 0.272006],
[0.37539, 0.229105, 0.275476],
[0.380502, 0.231695, 0.278946],
[0.385625, 0.234278, 0.282417],
[0.390759, 0.236855, 0.28589],
[0.395905, 0.239425, 0.289364],
[0.401062, 0.241988, 0.292839],
[0.40623, 0.244545, 0.296316],
[0.41141, 0.247095, 0.299794],
[0.416602, 0.24964, 0.303275],
[0.421806, 0.252177, 0.306757],
[0.427022, 0.254709, 0.310242],
[0.43225, 0.257235, 0.313728],
[0.437491, 0.259755, 0.317218],
[0.442744, 0.262269, 0.320709],
[0.44801, 0.264778, 0.324204],
[0.453289, 0.26728, 0.327701],
[0.458581, 0.269777, 0.331201],
[0.463887, 0.272269, 0.334703],
[0.469205, 0.274755, 0.33821],
[0.474537, 0.277236, 0.341719],
[0.479883, 0.279711, 0.345231],
[0.485243, 0.282181, 0.348747],
[0.490616, 0.284646, 0.352267],
[0.496004, 0.287106, 0.35579],
[0.501405, 0.289561, 0.359317],
[0.506822, 0.292011, 0.362848],
[0.512252, 0.294455, 0.366383],
[0.517697, 0.296895, 0.369923],
[0.523157, 0.29933, 0.373466],
[0.528632, 0.301761, 0.377013],
[0.534122, 0.304186, 0.380566],
[0.539627, 0.306607, 0.384122],
[0.545147, 0.309024, 0.387683],
[0.550683, 0.311435, 0.391249],
[0.556234, 0.313843, 0.39482],
[0.561801, 0.316245, 0.398396],
[0.567384, 0.318643, 0.401976],
[0.572983, 0.321037, 0.405562],
[0.578598, 0.323427, 0.409153],
[0.584229, 0.325812, 0.41275],
[0.589877, 0.328193, 0.416351],
[0.595541, 0.330569, 0.419959],
[0.601222, 0.332942, 0.423572],
[0.60692, 0.33531, 0.42719],
[0.612634, 0.337674, 0.430815],
[0.618366, 0.340034, 0.434445],
[0.622615, 0.3436, 0.438107],
[0.625363, 0.348373, 0.4418],
[0.628107, 0.353143, 0.4455],
[0.630846, 0.35791, 0.449206],
[0.63358, 0.362675, 0.452919],
[0.63631, 0.367439, 0.456638],
[0.639035, 0.372201, 0.460364],
[0.641757, 0.376963, 0.464096],
[0.644475, 0.381723, 0.467836],
[0.64719, 0.386483, 0.471582],
[0.649901, 0.391243, 0.475336],
[0.65261, 0.396003, 0.479097],
[0.655316, 0.400764, 0.482865],
[0.65802, 0.405525, 0.48664],
[0.660721, 0.410288, 0.490423],
[0.66342, 0.415051, 0.494213],
[0.666118, 0.419816, 0.498011],
[0.668814, 0.424582, 0.501817],
[0.671509, 0.42935, 0.50563],
[0.674203, 0.434121, 0.509451],
[0.676896, 0.438894, 0.513281],
[0.679589, 0.443669, 0.517118],
[0.682281, 0.448447, 0.520964],
[0.684973, 0.453228, 0.524817],
[0.687666, 0.458012, 0.528679],
[0.690358, 0.4628, 0.53255],
[0.693051, 0.467591, 0.536429],
[0.695745, 0.472385, 0.540317],
[0.698441, 0.477184, 0.544214],
[0.701137, 0.481987, 0.548119],
[0.703835, 0.486793, 0.552033],
[0.706534, 0.491605, 0.555957],
[0.709236, 0.496421, 0.559889],
[0.71194, 0.501241, 0.56383],
[0.714646, 0.506067, 0.567781],
[0.717354, 0.510897, 0.571742],
[0.720066, 0.515733, 0.575711],
[0.72278, 0.520574, 0.579691],
[0.725498, 0.525421, 0.58368],
[0.72822, 0.530273, 0.587679],
[0.730945, 0.535132, 0.591687],
[0.733674, 0.539996, 0.595706],
[0.736408, 0.544866, 0.599735],
[0.739146, 0.549743, 0.603774],
[0.741888, 0.554626, 0.607823],
[0.744635, 0.559515, 0.611882],
[0.747388, 0.564412, 0.615952],
[0.750146, 0.569315, 0.620033],
[0.752909, 0.574225, 0.624124],
[0.755678, 0.579142, 0.628226],
[0.758453, 0.584067, 0.632338],
[0.761235, 0.588998, 0.636462],
[0.764023, 0.593938, 0.640597],
[0.766818, 0.598885, 0.644743],
[0.769619, 0.603839, 0.6489],
[0.772428, 0.608802, 0.653069],
[0.775244, 0.613773, 0.657249],
[0.778068, 0.618752, 0.66144],
[0.7809, 0.623739, 0.665643],
[0.78374, 0.628734, 0.669859],
[0.786588, 0.633739, 0.674085],
[0.789445, 0.638751, 0.678324],
[0.79231, 0.643773, 0.682575],
[0.795185, 0.648803, 0.686839],
[0.798069, 0.653843, 0.691114],
[0.800963, 0.658892, 0.695402],
[0.803866, 0.66395, 0.699702],
[0.806779, 0.669017, 0.704015],
[0.809703, 0.674094, 0.708341],
[0.812637, 0.679181, 0.71268],
[0.815582, 0.684277, 0.717032],
[0.818539, 0.689383, 0.721396],
[0.821506, 0.694499, 0.725774],
[0.824485, 0.699626, 0.730166],
[0.827476, 0.704762, 0.73457],
[0.830479, 0.70991, 0.738988],
[0.833494, 0.715067, 0.74342],
[0.836522, 0.720235, 0.747866],
[0.839563, 0.725414, 0.752325],
[0.842617, 0.730604, 0.756799],
[0.845684, 0.735804, 0.761286],
[0.848765, 0.741016, 0.765788],
[0.85186, 0.746239, 0.770304],
[0.85497, 0.751473, 0.774835],
[0.858094, 0.756719, 0.77938],
[0.861232, 0.761976, 0.783941],
[0.864386, 0.767245, 0.788515],
[0.867556, 0.772525, 0.793105],
[0.870741, 0.777817, 0.79771],
[0.873942, 0.783122, 0.80233],
[0.87716, 0.788438, 0.806966],
[0.880395, 0.793766, 0.811617],
[0.883646, 0.799107, 0.816284],
[0.886915, 0.80446, 0.820966],
[0.890202, 0.809826, 0.825664],
[0.893507, 0.815204, 0.830379],
[0.89683, 0.820595, 0.835109],
[0.900172, 0.825999, 0.839856],
[0.903533, 0.831415, 0.844619],
[0.906914, 0.836845, 0.849399],
[0.910315, 0.842287, 0.854195],
[0.913737, 0.847743, 0.859008],
[0.917179, 0.853211, 0.863838],
[0.920643, 0.858693, 0.868685],
[0.924129, 0.864189, 0.87355],
[0.927637, 0.869697, 0.878432],
[0.931167, 0.875219, 0.883331],
[0.934722, 0.880755, 0.888248],
[0.9383, 0.886304, 0.893183],
[0.941903, 0.891866, 0.898136],
[0.945531, 0.897442, 0.903107],
[0.949185, 0.903031, 0.908096],
[0.952865, 0.908634, 0.913104],
[0.956574, 0.91425, 0.91813],
[0.960311, 0.91988, 0.923175],
[0.964077, 0.925523, 0.928239],
[0.967874, 0.931178, 0.933322],
[0.971703, 0.936846, 0.938424],
[0.975565, 0.942527, 0.943545],
[0.979463, 0.94822, 0.948686],
[0.983398, 0.953924, 0.953847],
[0.987372, 0.959639, 0.959027],
[0.991391, 0.965363, 0.964227],
[0.995457, 0.971096, 0.969447],
[0.999577, 0.976834, 0.974687],
[1., 0.982574, 0.979948],
[1., 0.988308, 0.985229],
[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()
