from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000425245, 0.000322551, 0.000342986],
[0.00127115, 0.000903353, 0.000977924],
[0.00253654, 0.00171942, 0.00188283],
[0.00421712, 0.00274687, 0.00303345],
[0.00631422, 0.00396916, 0.00441164],
[0.00883183, 0.00537371, 0.00600224],
[0.0117755, 0.00695044, 0.00779175],
[0.0151514, 0.00869098, 0.00976767],
[0.0189667, 0.0105882, 0.0119182],
[0.0232284, 0.0126361, 0.0142318],
[0.027944, 0.0148292, 0.0166975],
[0.0331209, 0.017163, 0.0193043],
[0.0387667, 0.0196332, 0.0220415],
[0.0446821, 0.0222364, 0.0248985],
[0.0505503, 0.0249693, 0.0278646],
[0.0563838, 0.0278291, 0.0309295],
[0.062186, 0.0308135, 0.0340829],
[0.0679603, 0.0339203, 0.0373144],
[0.073709, 0.0371478, 0.0406111],
[0.0794345, 0.0404938, 0.0438286],
[0.0851383, 0.043817, 0.0469491],
[0.090822, 0.0470956, 0.0499745],
[0.0964868, 0.0503329, 0.0529066],
[0.102134, 0.053532, 0.0557469],
[0.107763, 0.0566959, 0.058497],
[0.113376, 0.0598273, 0.0611582],
[0.118973, 0.0629287, 0.0637316],
[0.124554, 0.0660027, 0.0662185],
[0.130119, 0.0690514, 0.06862],
[0.135668, 0.0720771, 0.0709371],
[0.141202, 0.075082, 0.0731709],
[0.14672, 0.078068, 0.0753224],
[0.152223, 0.0810371, 0.0773925],
[0.157709, 0.0839911, 0.0793823],
[0.163179, 0.086932, 0.0812927],
[0.168632, 0.0898613, 0.0831247],
[0.174067, 0.092781, 0.0848793],
[0.179486, 0.0956925, 0.0865575],
[0.184886, 0.0985976, 0.0881603],
[0.190268, 0.101498, 0.0896888],
[0.19563, 0.104395, 0.091144],
[0.200973, 0.107289, 0.0925271],
[0.206295, 0.110184, 0.0938391],
[0.211597, 0.113079, 0.0950812],
[0.216877, 0.115977, 0.0962545],
[0.222134, 0.118878, 0.0973603],
[0.227369, 0.121784, 0.0983997],
[0.23258, 0.124697, 0.0993741],
[0.237767, 0.127617, 0.100285],
[0.242928, 0.130546, 0.101133],
[0.248064, 0.133485, 0.10192],
[0.253173, 0.136435, 0.102647],
[0.258255, 0.139397, 0.103317],
[0.263309, 0.142373, 0.103929],
[0.268334, 0.145363, 0.104486],
[0.273329, 0.148368, 0.10499],
[0.278294, 0.15139, 0.105441],
[0.283227, 0.154429, 0.105842],
[0.288129, 0.157487, 0.106194],
[0.292997, 0.160564, 0.106498],
[0.297832, 0.163661, 0.106758],
[0.302633, 0.166779, 0.106973],
[0.307399, 0.169919, 0.107147],
[0.312128, 0.173082, 0.107281],
[0.316821, 0.176268, 0.107376],
[0.321477, 0.179479, 0.107436],
[0.326094, 0.182714, 0.107461],
[0.330673, 0.185974, 0.107455],
[0.335211, 0.189261, 0.107418],
[0.339709, 0.192575, 0.107354],
[0.344166, 0.195915, 0.107264],
[0.348581, 0.199284, 0.10715],
[0.352953, 0.202681, 0.107016],
[0.357281, 0.206107, 0.106863],
[0.361566, 0.209562, 0.106695],
[0.365805, 0.213046, 0.106512],
[0.369999, 0.216561, 0.106319],
[0.374147, 0.220106, 0.106117],
[0.378248, 0.223681, 0.105911],
[0.382301, 0.227288, 0.105701],
[0.386307, 0.230925, 0.105492],
[0.390263, 0.234594, 0.105287],
[0.39417, 0.238294, 0.105088],
[0.398028, 0.242026, 0.104898],
[0.401834, 0.24579, 0.104722],
[0.40559, 0.249585, 0.104563],
[0.409294, 0.253413, 0.104423],
[0.412945, 0.257272, 0.104308],
[0.416545, 0.261163, 0.104219],
[0.420091, 0.265085, 0.104162],
[0.423583, 0.26904, 0.10414],
[0.427022, 0.273026, 0.104156],
[0.430406, 0.277043, 0.104216],
[0.433735, 0.281092, 0.104323],
[0.437009, 0.285172, 0.104481],
[0.440228, 0.289283, 0.104695],
[0.443391, 0.293424, 0.104968],
[0.446498, 0.297596, 0.105305],
[0.449548, 0.301798, 0.10571],
[0.452542, 0.306029, 0.106188],
[0.45548, 0.31029, 0.106742],
[0.45836, 0.31458, 0.107378],
[0.461184, 0.318898, 0.108098],
[0.463951, 0.323245, 0.108906],
[0.466661, 0.327619, 0.109808],
[0.469313, 0.332021, 0.110806],
[0.471909, 0.336449, 0.111904],
[0.474448, 0.340904, 0.113105],
[0.47693, 0.345384, 0.114413],
[0.479355, 0.349889, 0.115831],
[0.481724, 0.354419, 0.117361],
[0.484037, 0.358972, 0.119007],
[0.486294, 0.36355, 0.120769],
[0.488495, 0.368149, 0.122652],
[0.490642, 0.372771, 0.124656],
[0.492734, 0.377414, 0.126783],
[0.494772, 0.382078, 0.129034],
[0.496757, 0.386762, 0.131411],
[0.498689, 0.391465, 0.133914],
[0.500568, 0.396187, 0.136544],
[0.502397, 0.400926, 0.139302],
[0.504175, 0.405682, 0.142187],
[0.505904, 0.410455, 0.1452],
[0.507584, 0.415243, 0.148341],
[0.509216, 0.420046, 0.151608],
[0.510802, 0.424862, 0.155003],
[0.512343, 0.429692, 0.158523],
[0.51384, 0.434534, 0.162169],
[0.515294, 0.439387, 0.165938],
[0.516707, 0.44425, 0.169831],
[0.51808, 0.449124, 0.173846],
[0.519415, 0.454006, 0.177982],
[0.520714, 0.458896, 0.182238],
[0.521978, 0.463793, 0.186611],
[0.523208, 0.468697, 0.191101],
[0.524408, 0.473605, 0.195707],
[0.525579, 0.478519, 0.200426],
[0.526722, 0.483435, 0.205257],
[0.527841, 0.488355, 0.210198],
[0.528937, 0.493276, 0.215247],
[0.530013, 0.498199, 0.220404],
[0.531071, 0.503121, 0.225666],
[0.532113, 0.508043, 0.231031],
[0.533142, 0.512963, 0.236497],
[0.534161, 0.51788, 0.242063],
[0.535173, 0.522795, 0.247727],
[0.53618, 0.527705, 0.253487],
[0.537184, 0.53261, 0.25934],
[0.53819, 0.537509, 0.265286],
[0.5392, 0.542402, 0.271321],
[0.540217, 0.547287, 0.277445],
[0.541244, 0.552164, 0.283654],
[0.542285, 0.557032, 0.289947],
[0.543342, 0.56189, 0.296322],
[0.544418, 0.566738, 0.302777],
[0.545518, 0.571575, 0.309309],
[0.546645, 0.5764, 0.315917],
[0.547801, 0.581212, 0.322598],
[0.548991, 0.586011, 0.329349],
[0.550217, 0.590797, 0.33617],
[0.551484, 0.595567, 0.343057],
[0.552794, 0.600323, 0.350008],
[0.55415, 0.605063, 0.357021],
[0.555557, 0.609787, 0.364094],
[0.557018, 0.614495, 0.371223],
[0.558535, 0.619185, 0.378408],
[0.560113, 0.623858, 0.385645],
[0.561754, 0.628512, 0.392932],
[0.563461, 0.633149, 0.400267],
[0.565239, 0.637766, 0.407647],
[0.567088, 0.642364, 0.415069],
[0.569014, 0.646943, 0.422532],
[0.571017, 0.651503, 0.430032],
[0.573102, 0.656042, 0.437567],
[0.57527, 0.660561, 0.445136],
[0.577525, 0.66506, 0.452734],
[0.579868, 0.669539, 0.46036],
[0.582302, 0.673997, 0.468011],
[0.584829, 0.678434, 0.475685],
[0.58745, 0.682851, 0.483379],
[0.590168, 0.687247, 0.491091],
[0.592984, 0.691623, 0.498818],
[0.595899, 0.695978, 0.506557],
[0.598915, 0.700313, 0.514307],
[0.602034, 0.704627, 0.522065],
[0.605255, 0.708922, 0.529828],
[0.60858, 0.713197, 0.537594],
[0.61201, 0.717452, 0.545361],
[0.615544, 0.721688, 0.553126],
[0.619183, 0.725905, 0.560886],
[0.622928, 0.730103, 0.568641],
[0.626778, 0.734283, 0.576387],
[0.630733, 0.738445, 0.584122],
[0.634792, 0.74259, 0.591844],
[0.638956, 0.746718, 0.599552],
[0.643223, 0.75083, 0.607242],
[0.647593, 0.754926, 0.614913],
[0.652064, 0.759007, 0.622562],
[0.656636, 0.763073, 0.630189],
[0.661308, 0.767125, 0.637791],
[0.666078, 0.771164, 0.645366],
[0.670945, 0.77519, 0.652912],
[0.675906, 0.779205, 0.660429],
[0.680962, 0.783208, 0.667913],
[0.686109, 0.7872, 0.675364],
[0.691347, 0.791183, 0.68278],
[0.696672, 0.795157, 0.69016],
[0.702084, 0.799123, 0.697501],
[0.707581, 0.803081, 0.704804],
[0.713159, 0.807033, 0.712067],
[0.718818, 0.81098, 0.719288],
[0.724554, 0.814922, 0.726466],
[0.730366, 0.81886, 0.7336],
[0.736252, 0.822795, 0.74069],
[0.742209, 0.826729, 0.747735],
[0.748235, 0.830661, 0.754733],
[0.754328, 0.834593, 0.761684],
[0.760485, 0.838526, 0.768587],
[0.766704, 0.842461, 0.775441],
[0.772983, 0.846398, 0.782247],
[0.77932, 0.85034, 0.789004],
[0.785711, 0.854286, 0.79571],
[0.792156, 0.858237, 0.802367],
[0.798651, 0.862196, 0.808973],
[0.805194, 0.866162, 0.815528],
[0.811783, 0.870136, 0.822033],
[0.818416, 0.87412, 0.828487],
[0.825091, 0.878115, 0.83489],
[0.831805, 0.882122, 0.841243],
[0.838556, 0.886141, 0.847545],
[0.845342, 0.890174, 0.853798],
[0.852162, 0.894221, 0.86],
[0.859011, 0.898284, 0.866152],
[0.86589, 0.902364, 0.872256],
[0.872795, 0.906461, 0.87831],
[0.879724, 0.910577, 0.884317],
[0.886675, 0.914712, 0.890276],
[0.893647, 0.918868, 0.896188],
[0.900637, 0.923046, 0.902054],
[0.907642, 0.927247, 0.907875],
[0.914662, 0.931471, 0.913651],
[0.921693, 0.935721, 0.919384],
[0.928733, 0.939996, 0.925074],
[0.93578, 0.944299, 0.930723],
[0.942831, 0.94863, 0.936332],
[0.949884, 0.952991, 0.941901],
[0.956936, 0.957383, 0.947433],
[0.963982, 0.961809, 0.952928],
[0.97102, 0.966268, 0.958388],
[0.978044, 0.970765, 0.963815],
[0.985047, 0.975302, 0.969211],
[0.992022, 0.979882, 0.974577],
[0.998952, 0.984512, 0.979916],
[1., 0.989203, 0.985232],
[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()
