from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000354727, 0.000346818, 0.000375297],
[0.00100989, 0.00099284, 0.0011013],
[0.00194603, 0.00192083, 0.00216928],
[0.00314222, 0.003112, 0.00356813],
[0.00458476, 0.0045543, 0.00529271],
[0.00626374, 0.0062392, 0.00734091],
[0.00817154, 0.00816032, 0.00971238],
[0.0103021, 0.0103127, 0.012408],
[0.0126505, 0.0126924, 0.0154293],
[0.0152127, 0.0152963, 0.0187787],
[0.0179851, 0.0181217, 0.022459],
[0.0209648, 0.0211665, 0.0264732],
[0.0241493, 0.0244291, 0.0308248],
[0.0275364, 0.027908, 0.0355175],
[0.0311243, 0.0316019, 0.0405535],
[0.0349112, 0.03551, 0.0456505],
[0.0388957, 0.0396315, 0.0507116],
[0.0429852, 0.043823, 0.0557408],
[0.0470161, 0.0479593, 0.0607418],
[0.0510008, 0.0520531, 0.0657178],
[0.0549423, 0.0561072, 0.0706717],
[0.0588437, 0.0601245, 0.0756059],
[0.0627074, 0.0641074, 0.0805227],
[0.0665357, 0.0680582, 0.0854243],
[0.0703309, 0.071979, 0.0903124],
[0.0740948, 0.0758715, 0.0951889],
[0.0778292, 0.0797375, 0.100055],
[0.0815357, 0.0835785, 0.104913],
[0.0852158, 0.0873959, 0.109763],
[0.0888709, 0.0911911, 0.114607],
[0.0925023, 0.0949653, 0.119446],
[0.0961111, 0.0987196, 0.12428],
[0.0996984, 0.102455, 0.129112],
[0.103265, 0.106173, 0.133942],
[0.106813, 0.109873, 0.138771],
[0.110342, 0.113558, 0.143599],
[0.113853, 0.117227, 0.148427],
[0.117347, 0.120882, 0.153257],
[0.120825, 0.124523, 0.158088],
[0.124288, 0.128151, 0.162922],
[0.127735, 0.131767, 0.167759],
[0.131169, 0.13537, 0.1726],
[0.134589, 0.138963, 0.177444],
[0.137996, 0.142544, 0.182294],
[0.141391, 0.146116, 0.187148],
[0.144774, 0.149677, 0.192009],
[0.148145, 0.153229, 0.196875],
[0.151505, 0.156773, 0.201749],
[0.154855, 0.160308, 0.206629],
[0.158194, 0.163835, 0.211517],
[0.161524, 0.167354, 0.216413],
[0.164845, 0.170866, 0.221317],
[0.168157, 0.174371, 0.22623],
[0.17146, 0.17787, 0.231152],
[0.174755, 0.181362, 0.236084],
[0.178042, 0.184849, 0.241025],
[0.181321, 0.188329, 0.245976],
[0.184594, 0.191805, 0.250938],
[0.187859, 0.195275, 0.255911],
[0.191118, 0.198741, 0.260894],
[0.19437, 0.202202, 0.265889],
[0.197616, 0.205659, 0.270896],
[0.200856, 0.209112, 0.275915],
[0.204091, 0.212561, 0.280946],
[0.20732, 0.216007, 0.28599],
[0.210545, 0.219449, 0.291046],
[0.213764, 0.222888, 0.296116],
[0.216979, 0.226325, 0.301198],
[0.220189, 0.229758, 0.306295],
[0.223395, 0.233189, 0.311405],
[0.226597, 0.236618, 0.31653],
[0.229795, 0.240045, 0.321669],
[0.232989, 0.243469, 0.326822],
[0.23618, 0.246892, 0.331991],
[0.239368, 0.250313, 0.337174],
[0.242553, 0.253733, 0.342373],
[0.245735, 0.257152, 0.347588],
[0.248914, 0.260569, 0.352818],
[0.25209, 0.263986, 0.358064],
[0.255264, 0.267401, 0.363327],
[0.258436, 0.270816, 0.368606],
[0.261606, 0.274231, 0.373901],
[0.264773, 0.277645, 0.379214],
[0.267939, 0.281059, 0.384544],
[0.271104, 0.284472, 0.389891],
[0.274266, 0.287886, 0.395255],
[0.277428, 0.2913, 0.400638],
[0.280588, 0.294714, 0.406038],
[0.283747, 0.298129, 0.411457],
[0.286905, 0.301544, 0.416894],
[0.290063, 0.304959, 0.42235],
[0.293219, 0.308376, 0.427824],
[0.296375, 0.311793, 0.433318],
[0.299531, 0.315211, 0.43883],
[0.302686, 0.318631, 0.444362],
[0.305841, 0.322051, 0.449914],
[0.308996, 0.325473, 0.455486],
[0.312152, 0.328896, 0.461078],
[0.315307, 0.332321, 0.46669],
[0.318462, 0.335747, 0.472322],
[0.321618, 0.339175, 0.477975],
[0.324775, 0.342605, 0.483649],
[0.327932, 0.346036, 0.489344],
[0.331089, 0.34947, 0.49506],
[0.334248, 0.352906, 0.500797],
[0.337407, 0.356343, 0.506557],
[0.340568, 0.359784, 0.512338],
[0.343729, 0.363226, 0.518141],
[0.346892, 0.366671, 0.523966],
[0.350056, 0.370118, 0.529814],
[0.353222, 0.373568, 0.535685],
[0.356389, 0.377021, 0.541578],
[0.359558, 0.380477, 0.547494],
[0.362728, 0.383935, 0.553434],
[0.365901, 0.387396, 0.559397],
[0.369075, 0.39086, 0.565384],
[0.372251, 0.394328, 0.571394],
[0.37543, 0.397798, 0.577429],
[0.37861, 0.401272, 0.583488],
[0.381793, 0.404749, 0.589571],
[0.384978, 0.40823, 0.595679],
[0.388166, 0.411714, 0.601812],
[0.391357, 0.415202, 0.60797],
[0.39455, 0.418693, 0.614153],
[0.397746, 0.422188, 0.620361],
[0.400944, 0.425686, 0.626596],
[0.404146, 0.429189, 0.632856],
[0.407801, 0.432904, 0.636779],
[0.411913, 0.436827, 0.638361],
[0.416032, 0.44075, 0.639962],
[0.420161, 0.444673, 0.641582],
[0.424297, 0.448597, 0.643221],
[0.428441, 0.452521, 0.644879],
[0.432594, 0.456446, 0.646555],
[0.436755, 0.460373, 0.64825],
[0.440923, 0.464301, 0.649964],
[0.4451, 0.468231, 0.651695],
[0.449285, 0.472163, 0.653445],
[0.453478, 0.476098, 0.655213],
[0.457679, 0.480035, 0.656999],
[0.461889, 0.483974, 0.658803],
[0.466106, 0.487917, 0.660625],
[0.470332, 0.491863, 0.662465],
[0.474566, 0.495813, 0.664323],
[0.478808, 0.499766, 0.666198],
[0.483058, 0.503723, 0.668091],
[0.487317, 0.507684, 0.670002],
[0.491584, 0.51165, 0.67193],
[0.49586, 0.51562, 0.673876],
[0.500144, 0.519595, 0.675839],
[0.504436, 0.523575, 0.67782],
[0.508737, 0.52756, 0.679818],
[0.513047, 0.53155, 0.681834],
[0.517365, 0.535546, 0.683867],
[0.521692, 0.539547, 0.685917],
[0.526027, 0.543554, 0.687985],
[0.530372, 0.547567, 0.69007],
[0.534725, 0.551587, 0.692173],
[0.539087, 0.555612, 0.694293],
[0.543458, 0.559645, 0.69643],
[0.547838, 0.563684, 0.698585],
[0.552228, 0.567729, 0.700757],
[0.556626, 0.571782, 0.702947],
[0.561034, 0.575842, 0.705154],
[0.565451, 0.57991, 0.707378],
[0.569877, 0.583984, 0.70962],
[0.574313, 0.588067, 0.71188],
[0.578759, 0.592157, 0.714157],
[0.583214, 0.596255, 0.716451],
[0.587679, 0.600362, 0.718763],
[0.592153, 0.604476, 0.721093],
[0.596638, 0.608599, 0.72344],
[0.601132, 0.612731, 0.725805],
[0.605637, 0.616871, 0.728188],
[0.610151, 0.62102, 0.730589],
[0.614676, 0.625178, 0.733007],
[0.619211, 0.629345, 0.735443],
[0.623756, 0.633521, 0.737898],
[0.628312, 0.637707, 0.74037],
[0.632878, 0.641903, 0.74286],
[0.637455, 0.646108, 0.745369],
[0.642042, 0.650323, 0.747895],
[0.646641, 0.654547, 0.75044],
[0.65125, 0.658782, 0.753003],
[0.65587, 0.663028, 0.755585],
[0.660501, 0.667283, 0.758185],
[0.665144, 0.671549, 0.760804],
[0.669798, 0.675826, 0.763441],
[0.674463, 0.680114, 0.766097],
[0.679139, 0.684412, 0.768771],
[0.683827, 0.688722, 0.771465],
[0.688527, 0.693043, 0.774177],
[0.693238, 0.697375, 0.776909],
[0.697961, 0.701718, 0.779659],
[0.702697, 0.706074, 0.782429],
[0.707444, 0.710441, 0.785218],
[0.712203, 0.71482, 0.788027],
[0.716975, 0.71921, 0.790855],
[0.721758, 0.723614, 0.793702],
[0.726555, 0.728029, 0.79657],
[0.731364, 0.732457, 0.799457],
[0.736185, 0.736897, 0.802364],
[0.741019, 0.74135, 0.805291],
[0.745867, 0.745816, 0.808239],
[0.750727, 0.750295, 0.811207],
[0.7556, 0.754787, 0.814195],
[0.760486, 0.759293, 0.817204],
[0.765386, 0.763811, 0.820233],
[0.770299, 0.768344, 0.823284],
[0.775225, 0.772889, 0.826355],
[0.780166, 0.777449, 0.829448],
[0.785119, 0.782023, 0.832561],
[0.790087, 0.786611, 0.835697],
[0.795069, 0.791213, 0.838853],
[0.800065, 0.795829, 0.842032],
[0.805074, 0.80046, 0.845232],
[0.810099, 0.805106, 0.848455],
[0.815137, 0.809767, 0.8517],
[0.82019, 0.814442, 0.854967],
[0.825258, 0.819133, 0.858257],
[0.83034, 0.823838, 0.86157],
[0.835437, 0.82856, 0.864906],
[0.840549, 0.833296, 0.868265],
[0.845677, 0.838049, 0.871647],
[0.850819, 0.842817, 0.875053],
[0.855977, 0.847601, 0.878483],
[0.86115, 0.852402, 0.881938],
[0.866338, 0.857218, 0.885416],
[0.871542, 0.862052, 0.88892],
[0.876762, 0.866901, 0.892448],
[0.881998, 0.871768, 0.896002],
[0.887249, 0.876651, 0.899581],
[0.892517, 0.881552, 0.903186],
[0.897801, 0.886469, 0.906817],
[0.903101, 0.891404, 0.910475],
[0.908417, 0.896357, 0.91416],
[0.913749, 0.901327, 0.917873],
[0.919098, 0.906315, 0.921613],
[0.924464, 0.911321, 0.925382],
[0.929846, 0.916346, 0.929179],
[0.935244, 0.921388, 0.933007],
[0.94066, 0.926449, 0.936864],
[0.946092, 0.931529, 0.940752],
[0.951541, 0.936628, 0.944673],
[0.957006, 0.941745, 0.948626],
[0.962488, 0.946882, 0.952612],
[0.967986, 0.952038, 0.956634],
[0.973501, 0.957214, 0.960693],
[0.979031, 0.962409, 0.964791],
[0.984577, 0.967624, 0.96893],
[0.990139, 0.972859, 0.973115],
[0.995714, 0.978114, 0.97735],
[1., 0.98339, 0.981643],
[1., 0.988685, 0.986013],
[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()
