from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000308792, 0.000372257, 0.000304882],
[0.000842789, 0.0010861, 0.000838633],
[0.00157516, 0.00212944, 0.00157157],
[0.00247946, 0.00348773, 0.00247297],
[0.00353812, 0.00515242, 0.00351935],
[0.00473872, 0.00711785, 0.00469111],
[0.00607226, 0.00937999, 0.00597105],
[0.00753233, 0.0119358, 0.00734362],
[0.00911455, 0.0147829, 0.00879452],
[0.0108162, 0.0179191, 0.0103104],
[0.0126361, 0.0213429, 0.0118787],
[0.0145743, 0.0250523, 0.0134875],
[0.016632, 0.029046, 0.0151257],
[0.0188117, 0.0333221, 0.0167824],
[0.0211165, 0.0378792, 0.0184475],
[0.023551, 0.042642, 0.0201112],
[0.0261202, 0.0473522, 0.0217644],
[0.0288304, 0.052008, 0.0233983],
[0.0316886, 0.0566122, 0.0250045],
[0.0347024, 0.0611673, 0.0265753],
[0.0378805, 0.0656754, 0.0281031],
[0.0412149, 0.0701383, 0.0295811],
[0.0445701, 0.0745574, 0.0310027],
[0.0479464, 0.0789342, 0.0323618],
[0.0513488, 0.0832697, 0.0336529],
[0.054782, 0.0875649, 0.0348708],
[0.0582502, 0.0918206, 0.0360106],
[0.0617575, 0.0960374, 0.0370682],
[0.0653075, 0.100216, 0.0380396],
[0.0689036, 0.104357, 0.0389213],
[0.0725488, 0.10846, 0.0397104],
[0.076246, 0.112527, 0.0404043],
[0.0799976, 0.116557, 0.0409893],
[0.0838059, 0.12055, 0.0414726],
[0.0876729, 0.124507, 0.0418556],
[0.0916003, 0.128428, 0.042139],
[0.0955897, 0.132312, 0.0423234],
[0.0996424, 0.136161, 0.0424094],
[0.103759, 0.139973, 0.0423972],
[0.107942, 0.14375, 0.0422873],
[0.11219, 0.147491, 0.0420799],
[0.116505, 0.151195, 0.041775],
[0.120887, 0.154864, 0.0413726],
[0.125336, 0.158497, 0.0408726],
[0.129852, 0.162094, 0.0402719],
[0.134436, 0.165655, 0.039569],
[0.139086, 0.169179, 0.0387749],
[0.143804, 0.172668, 0.0378919],
[0.148587, 0.176121, 0.0369231],
[0.153437, 0.179537, 0.0358711],
[0.158352, 0.182917, 0.0347393],
[0.163331, 0.186261, 0.0335309],
[0.168374, 0.189569, 0.0322492],
[0.173481, 0.192841, 0.030898],
[0.178649, 0.196076, 0.0294807],
[0.183879, 0.199276, 0.0280014],
[0.189168, 0.202439, 0.0264638],
[0.194517, 0.205566, 0.0248719],
[0.199924, 0.208658, 0.0232299],
[0.205388, 0.211713, 0.0215417],
[0.210908, 0.214733, 0.0198117],
[0.216482, 0.217717, 0.018044],
[0.22211, 0.220666, 0.016243],
[0.227789, 0.22358, 0.014413],
[0.23352, 0.226458, 0.0125584],
[0.2393, 0.229302, 0.0106835],
[0.245128, 0.23211, 0.00879276],
[0.251003, 0.234885, 0.00689073],
[0.256923, 0.237625, 0.00498186],
[0.262887, 0.240331, 0.00307069],
[0.268895, 0.243004, 0.00116178],
[0.274943, 0.245643, 0.],
[0.281032, 0.248249, 0.],
[0.287159, 0.250823, 0.],
[0.293323, 0.253365, 0.],
[0.299523, 0.255875, 0.],
[0.305757, 0.258354, 0.],
[0.312024, 0.260802, 0.],
[0.318323, 0.26322, 0.],
[0.324652, 0.265607, 0.],
[0.331009, 0.267966, 0.],
[0.337394, 0.270296, 0.],
[0.343804, 0.272599, 0.],
[0.350239, 0.274873, 0.],
[0.356697, 0.277122, 0.],
[0.363176, 0.279344, 0.],
[0.369675, 0.281541, 0.],
[0.376193, 0.283713, 0.],
[0.382727, 0.285862, 0.],
[0.389278, 0.287987, 0.],
[0.395843, 0.290091, 0.],
[0.402421, 0.292173, 0.],
[0.40901, 0.294236, 0.],
[0.415609, 0.296278, 0.],
[0.422217, 0.298303, 0.],
[0.428831, 0.30031, 0.],
[0.435451, 0.3023, 0.],
[0.442076, 0.304276, 0.],
[0.448703, 0.306237, 0.],
[0.455331, 0.308185, 0.],
[0.46196, 0.310121, 0.],
[0.468586, 0.312046, 0.],
[0.47521, 0.313962, 0.],
[0.481829, 0.315869, 0.],
[0.488442, 0.317769, 0.],
[0.495047, 0.319663, 0.],
[0.501644, 0.321553, 0.],
[0.50823, 0.32344, 0.],
[0.514805, 0.325325, 0.],
[0.521366, 0.32721, 0.],
[0.527912, 0.329096, 0.],
[0.534442, 0.330984, 0.],
[0.540954, 0.332876, 0.00331529],
[0.547448, 0.334774, 0.00832827],
[0.55392, 0.336679, 0.0138013],
[0.56037, 0.338592, 0.0197592],
[0.566797, 0.340516, 0.0262278],
[0.573199, 0.342451, 0.0332342],
[0.579574, 0.3444, 0.0407996],
[0.585922, 0.346363, 0.0483661],
[0.59224, 0.348342, 0.0557284],
[0.598527, 0.35034, 0.062944],
[0.604781, 0.352358, 0.0700549],
[0.611002, 0.354396, 0.0770931],
[0.617188, 0.356458, 0.0840832],
[0.623337, 0.358544, 0.091045],
[0.629448, 0.360656, 0.0979942],
[0.635519, 0.362797, 0.104944],
[0.641549, 0.364966, 0.111904],
[0.647537, 0.367167, 0.118885],
[0.653481, 0.3694, 0.125893],
[0.65938, 0.371667, 0.132935],
[0.665233, 0.37397, 0.140016],
[0.671037, 0.37631, 0.147141],
[0.676793, 0.378689, 0.154314],
[0.682497, 0.381108, 0.161538],
[0.68815, 0.383569, 0.168816],
[0.693749, 0.386074, 0.17615],
[0.699294, 0.388622, 0.183542],
[0.704782, 0.391217, 0.190994],
[0.710214, 0.393859, 0.198507],
[0.715588, 0.39655, 0.206081],
[0.720901, 0.39929, 0.213718],
[0.726155, 0.402082, 0.221418],
[0.731346, 0.404925, 0.229181],
[0.736474, 0.407822, 0.237006],
[0.741538, 0.410774, 0.244894],
[0.746537, 0.413781, 0.252843],
[0.751469, 0.416844, 0.260854],
[0.756334, 0.419964, 0.268924],
[0.761131, 0.423143, 0.277053],
[0.765859, 0.426381, 0.28524],
[0.770517, 0.429678, 0.293483],
[0.775104, 0.433036, 0.30178],
[0.779619, 0.436454, 0.310129],
[0.784062, 0.439935, 0.318529],
[0.788431, 0.443477, 0.326978],
[0.792726, 0.447082, 0.335472],
[0.796947, 0.45075, 0.344011],
[0.801093, 0.454481, 0.352591],
[0.805163, 0.458275, 0.361209],
[0.809157, 0.462134, 0.369863],
[0.813075, 0.466056, 0.378551],
[0.816915, 0.470042, 0.387268],
[0.820679, 0.474092, 0.396013],
[0.824365, 0.478206, 0.404781],
[0.827973, 0.482384, 0.413571],
[0.831504, 0.486625, 0.422378],
[0.834957, 0.49093, 0.431199],
[0.838333, 0.495297, 0.440031],
[0.841631, 0.499728, 0.448871],
[0.844851, 0.504221, 0.457714],
[0.847994, 0.508776, 0.466558],
[0.851061, 0.513393, 0.475399],
[0.854051, 0.51807, 0.484234],
[0.856965, 0.522808, 0.493058],
[0.859804, 0.527605, 0.501868],
[0.862568, 0.532461, 0.510661],
[0.865258, 0.537375, 0.519434],
[0.867875, 0.542347, 0.528182],
[0.870419, 0.547375, 0.536902],
[0.872892, 0.552459, 0.545591],
[0.875294, 0.557598, 0.554245],
[0.877627, 0.56279, 0.562861],
[0.879893, 0.568036, 0.571436],
[0.882091, 0.573332, 0.579966],
[0.884224, 0.57868, 0.588449],
[0.886294, 0.584077, 0.59688],
[0.8883, 0.589522, 0.605258],
[0.890247, 0.595014, 0.613578],
[0.892134, 0.600553, 0.621839],
[0.893964, 0.606136, 0.630037],
[0.895739, 0.611763, 0.638171],
[0.89746, 0.617432, 0.646236],
[0.899131, 0.623142, 0.654232],
[0.900752, 0.628892, 0.662155],
[0.902326, 0.63468, 0.670004],
[0.903856, 0.640505, 0.677776],
[0.905344, 0.646365, 0.685469],
[0.906791, 0.65226, 0.693082],
[0.908202, 0.658188, 0.700613],
[0.909577, 0.664148, 0.708061],
[0.910921, 0.670138, 0.715423],
[0.912235, 0.676156, 0.722699],
[0.913523, 0.682202, 0.729888],
[0.914787, 0.688275, 0.736989],
[0.916031, 0.694372, 0.744],
[0.917256, 0.700492, 0.750921],
[0.918466, 0.706635, 0.757752],
[0.919665, 0.712798, 0.764492],
[0.920855, 0.718981, 0.771141],
[0.922039, 0.725182, 0.777698],
[0.92322, 0.7314, 0.784164],
[0.924402, 0.737633, 0.790538],
[0.925588, 0.743881, 0.796822],
[0.926781, 0.750142, 0.803015],
[0.927985, 0.756414, 0.809117],
[0.929202, 0.762698, 0.81513],
[0.930436, 0.768991, 0.821054],
[0.93169, 0.775292, 0.82689],
[0.932967, 0.781601, 0.83264],
[0.934271, 0.787916, 0.838303],
[0.935605, 0.794236, 0.843881],
[0.936972, 0.80056, 0.849376],
[0.938375, 0.806888, 0.85479],
[0.939818, 0.813218, 0.860122],
[0.941304, 0.819549, 0.865376],
[0.942835, 0.82588, 0.870553],
[0.944416, 0.832211, 0.875654],
[0.946048, 0.83854, 0.880683],
[0.947736, 0.844868, 0.885639],
[0.949482, 0.851192, 0.890527],
[0.951289, 0.857513, 0.895347],
[0.953159, 0.863829, 0.900103],
[0.955097, 0.87014, 0.904796],
[0.957104, 0.876445, 0.909429],
[0.959184, 0.882743, 0.914005],
[0.961338, 0.889034, 0.918526],
[0.96357, 0.895318, 0.922994],
[0.965883, 0.901593, 0.927414],
[0.968279, 0.907859, 0.931787],
[0.97076, 0.914115, 0.936116],
[0.97333, 0.92036, 0.940406],
[0.97599, 0.926595, 0.944659],
[0.978744, 0.932818, 0.948878],
[0.981594, 0.939028, 0.953069],
[0.984544, 0.945225, 0.957233],
[0.987596, 0.951407, 0.961378],
[0.990755, 0.957574, 0.965506],
[0.994025, 0.963722, 0.969625],
[0.997412, 0.969851, 0.973741],
[1., 0.975956, 0.977864],
[1., 0.982032, 0.982009],
[1., 0.988065, 0.986199],
[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()
