from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000333947, 0.000356554, 0.000360209],
[0.000933053, 0.0010289, 0.0010449],
[0.00177282, 0.00200223, 0.00204112],
[0.00282785, 0.00325989, 0.00333391],
[0.00408045, 0.00479177, 0.00491468],
[0.00551703, 0.00659113, 0.00677803],
[0.00712655, 0.00865325, 0.00892055],
[0.00889971, 0.0109748, 0.0113401],
[0.0108284, 0.0135532, 0.0140354],
[0.0129056, 0.016387, 0.0170059],
[0.0151249, 0.0194749, 0.0202516],
[0.0174804, 0.0228162, 0.0237729],
[0.0199667, 0.0264106, 0.0275705],
[0.022579, 0.0302581, 0.0316454],
[0.0253126, 0.0343587, 0.0359989],
[0.0281631, 0.0387129, 0.0406291],
[0.0311264, 0.0432168, 0.0452891],
[0.0341986, 0.0476689, 0.0499087],
[0.0373758, 0.0520803, 0.0544917],
[0.0406508, 0.0564545, 0.0590413],
[0.0438843, 0.0607945, 0.0635605],
[0.0470609, 0.0651029, 0.068052],
[0.0501833, 0.0693822, 0.0725181],
[0.0532539, 0.0736345, 0.076961],
[0.0562746, 0.0778619, 0.0813826],
[0.0592476, 0.0820661, 0.0857848],
[0.0621744, 0.0862488, 0.090169],
[0.0650568, 0.0904116, 0.0945368],
[0.0678962, 0.0945557, 0.0988896],
[0.0706938, 0.0986825, 0.103229],
[0.0734509, 0.102793, 0.107555],
[0.0761686, 0.106889, 0.11187],
[0.078848, 0.110971, 0.116174],
[0.08149, 0.115039, 0.120469],
[0.0840955, 0.119096, 0.124756],
[0.0866652, 0.123142, 0.129034],
[0.0891999, 0.127177, 0.133305],
[0.0917003, 0.131202, 0.137571],
[0.094167, 0.135218, 0.14183],
[0.0966007, 0.139226, 0.146085],
[0.0990017, 0.143226, 0.150335],
[0.101371, 0.147219, 0.154582],
[0.103708, 0.151206, 0.158825],
[0.106014, 0.155186, 0.163066],
[0.10829, 0.159162, 0.167305],
[0.110535, 0.163132, 0.171542],
[0.112749, 0.167097, 0.175778],
[0.114934, 0.171059, 0.180013],
[0.11709, 0.175017, 0.184248],
[0.119216, 0.178971, 0.188484],
[0.121313, 0.182923, 0.19272],
[0.123381, 0.186873, 0.196956],
[0.12542, 0.19082, 0.201195],
[0.127431, 0.194765, 0.205434],
[0.129413, 0.19871, 0.209676],
[0.131367, 0.202653, 0.21392],
[0.133292, 0.206595, 0.218167],
[0.13519, 0.210537, 0.222417],
[0.137059, 0.214479, 0.22667],
[0.1389, 0.21842, 0.230927],
[0.140713, 0.222363, 0.235187],
[0.142498, 0.226305, 0.239452],
[0.144255, 0.230249, 0.243721],
[0.145984, 0.234194, 0.247995],
[0.147684, 0.238141, 0.252273],
[0.149357, 0.242089, 0.256557],
[0.151001, 0.246039, 0.260846],
[0.152616, 0.249991, 0.265141],
[0.154203, 0.253945, 0.269442],
[0.155762, 0.257902, 0.273749],
[0.157292, 0.261862, 0.278062],
[0.158793, 0.265825, 0.282382],
[0.160264, 0.269791, 0.286709],
[0.161707, 0.27376, 0.291042],
[0.16312, 0.277733, 0.295383],
[0.164504, 0.28171, 0.299731],
[0.165857, 0.28569, 0.304087],
[0.167181, 0.289675, 0.30845],
[0.168474, 0.293664, 0.312822],
[0.169737, 0.297657, 0.317201],
[0.170968, 0.301655, 0.321589],
[0.172169, 0.305658, 0.325986],
[0.173338, 0.309666, 0.330391],
[0.174475, 0.313679, 0.334805],
[0.175579, 0.317697, 0.339228],
[0.176652, 0.321721, 0.343661],
[0.177691, 0.32575, 0.348102],
[0.178697, 0.329785, 0.352554],
[0.179669, 0.333826, 0.357015],
[0.180606, 0.337874, 0.361486],
[0.181509, 0.341927, 0.365967],
[0.182377, 0.345987, 0.370459],
[0.183209, 0.350053, 0.374961],
[0.184005, 0.354125, 0.379473],
[0.184764, 0.358205, 0.383996],
[0.185486, 0.362291, 0.38853],
[0.186169, 0.366385, 0.393075],
[0.186814, 0.370486, 0.397631],
[0.187419, 0.374594, 0.402199],
[0.187985, 0.378709, 0.406778],
[0.188509, 0.382832, 0.411369],
[0.188993, 0.386963, 0.415972],
[0.189434, 0.391102, 0.420586],
[0.189831, 0.395248, 0.425213],
[0.190185, 0.399403, 0.429852],
[0.190494, 0.403566, 0.434503],
[0.190757, 0.407738, 0.439167],
[0.190973, 0.411917, 0.443844],
[0.191141, 0.416106, 0.448533],
[0.19126, 0.420303, 0.453236],
[0.191329, 0.424509, 0.457951],
[0.191347, 0.428724, 0.46268],
[0.191312, 0.432948, 0.467423],
[0.191223, 0.437181, 0.472178],
[0.191079, 0.441424, 0.476948],
[0.190878, 0.445676, 0.481732],
[0.190619, 0.449938, 0.486529],
[0.190299, 0.454209, 0.491341],
[0.189918, 0.458491, 0.496167],
[0.189474, 0.462782, 0.501007],
[0.188964, 0.467083, 0.505862],
[0.188387, 0.471394, 0.510732],
[0.18774, 0.475716, 0.515617],
[0.187022, 0.480048, 0.520516],
[0.186229, 0.484391, 0.525431],
[0.185359, 0.488744, 0.530361],
[0.184409, 0.493108, 0.535307],
[0.189105, 0.49689, 0.539121],
[0.199197, 0.500087, 0.541801],
[0.208921, 0.50329, 0.54449],
[0.218326, 0.506501, 0.54719],
[0.22745, 0.509717, 0.549901],
[0.236325, 0.512941, 0.552622],
[0.244979, 0.516172, 0.555354],
[0.253434, 0.51941, 0.558096],
[0.261709, 0.522655, 0.56085],
[0.269822, 0.525907, 0.563613],
[0.277786, 0.529167, 0.566388],
[0.285616, 0.532434, 0.569174],
[0.293321, 0.535709, 0.57197],
[0.300912, 0.538992, 0.574778],
[0.308398, 0.542282, 0.577597],
[0.315786, 0.545581, 0.580426],
[0.323084, 0.548887, 0.583267],
[0.330298, 0.552202, 0.58612],
[0.337434, 0.555525, 0.588983],
[0.344498, 0.558857, 0.591858],
[0.351493, 0.562197, 0.594744],
[0.358425, 0.565545, 0.597642],
[0.365297, 0.568903, 0.600552],
[0.372114, 0.572269, 0.603473],
[0.378878, 0.575644, 0.606406],
[0.385593, 0.579029, 0.609351],
[0.392262, 0.582422, 0.612308],
[0.398887, 0.585825, 0.615276],
[0.405471, 0.589237, 0.618257],
[0.412017, 0.592659, 0.62125],
[0.418526, 0.59609, 0.624255],
[0.425001, 0.599531, 0.627272],
[0.431444, 0.602982, 0.630301],
[0.437855, 0.606443, 0.633343],
[0.444239, 0.609914, 0.636398],
[0.450594, 0.613395, 0.639465],
[0.456924, 0.616886, 0.642545],
[0.46323, 0.620388, 0.645637],
[0.469513, 0.6239, 0.648742],
[0.475774, 0.627423, 0.651861],
[0.482015, 0.630957, 0.654992],
[0.488237, 0.634501, 0.658136],
[0.49444, 0.638056, 0.661294],
[0.500626, 0.641622, 0.664464],
[0.506796, 0.6452, 0.667648],
[0.512951, 0.648789, 0.670846],
[0.519092, 0.652389, 0.674057],
[0.525219, 0.656, 0.677282],
[0.531334, 0.659624, 0.68052],
[0.537437, 0.663258, 0.683772],
[0.543529, 0.666905, 0.687038],
[0.54961, 0.670564, 0.690318],
[0.555682, 0.674235, 0.693612],
[0.561745, 0.677918, 0.696921],
[0.5678, 0.681613, 0.700243],
[0.573848, 0.685321, 0.70358],
[0.579888, 0.689041, 0.706932],
[0.585922, 0.692774, 0.710298],
[0.591949, 0.696519, 0.713678],
[0.597972, 0.700278, 0.717074],
[0.60399, 0.704049, 0.720484],
[0.610003, 0.707834, 0.72391],
[0.616013, 0.711631, 0.72735],
[0.622019, 0.715443, 0.730806],
[0.628022, 0.719267, 0.734277],
[0.634023, 0.723106, 0.737764],
[0.640021, 0.726958, 0.741266],
[0.646018, 0.730824, 0.744783],
[0.652014, 0.734703, 0.748317],
[0.658009, 0.738597, 0.751866],
[0.664004, 0.742506, 0.755432],
[0.669998, 0.746428, 0.759013],
[0.675993, 0.750365, 0.762611],
[0.681988, 0.754317, 0.766225],
[0.687984, 0.758283, 0.769856],
[0.693982, 0.762265, 0.773503],
[0.699981, 0.766261, 0.777167],
[0.705982, 0.770273, 0.780848],
[0.711986, 0.774299, 0.784545],
[0.717992, 0.778342, 0.78826],
[0.724, 0.782399, 0.791993],
[0.730012, 0.786473, 0.795742],
[0.736027, 0.790562, 0.79951],
[0.742046, 0.794668, 0.803295],
[0.748069, 0.798789, 0.807097],
[0.754095, 0.802927, 0.810918],
[0.760127, 0.807081, 0.814757],
[0.766163, 0.811252, 0.818614],
[0.772203, 0.81544, 0.82249],
[0.778249, 0.819644, 0.826384],
[0.7843, 0.823866, 0.830297],
[0.790357, 0.828105, 0.834229],
[0.796419, 0.832361, 0.838179],
[0.802487, 0.836634, 0.84215],
[0.808562, 0.840926, 0.846139],
[0.814642, 0.845235, 0.850148],
[0.820729, 0.849562, 0.854177],
[0.826823, 0.853908, 0.858226],
[0.832923, 0.858272, 0.862295],
[0.839031, 0.862654, 0.866385],
[0.845145, 0.867055, 0.870495],
[0.851267, 0.871475, 0.874626],
[0.857396, 0.875915, 0.878777],
[0.863532, 0.880374, 0.88295],
[0.869676, 0.884852, 0.887145],
[0.875827, 0.88935, 0.891361],
[0.881986, 0.893868, 0.895599],
[0.888152, 0.898406, 0.899859],
[0.894327, 0.902965, 0.904142],
[0.900508, 0.907544, 0.908448],
[0.906698, 0.912144, 0.912777],
[0.912894, 0.916766, 0.917129],
[0.919099, 0.921409, 0.921505],
[0.92531, 0.926074, 0.925905],
[0.931528, 0.930761, 0.93033],
[0.937753, 0.93547, 0.93478],
[0.943985, 0.940203, 0.939255],
[0.950222, 0.944958, 0.943757],
[0.956464, 0.949738, 0.948286],
[0.962711, 0.954542, 0.952842],
[0.968961, 0.95937, 0.957427],
[0.975213, 0.964225, 0.962041],
[0.981465, 0.969105, 0.966687],
[0.987713, 0.974014, 0.971365],
[0.993955, 0.978953, 0.97608],
[1., 0.983924, 0.980835],
[1., 0.988932, 0.985639],
[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()
