from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000315717, 0.000362572, 0.000371318],
[0.000866164, 0.00105072, 0.0010885],
[0.00162333, 0.00205037, 0.00214489],
[0.00255906, 0.00334534, 0.00353206],
[0.00365356, 0.00492566, 0.00524814],
[0.00489167, 0.0067845, 0.00729475],
[0.00626125, 0.00891687, 0.0096757],
[0.00775232, 0.0113189, 0.0123963],
[0.00935648, 0.0139876, 0.0154632],
[0.0110667, 0.0169204, 0.0188839],
[0.0128769, 0.0201152, 0.0226665],
[0.014782, 0.0235702, 0.0268201],
[0.0167778, 0.0272836, 0.0313542],
[0.0188608, 0.0312541, 0.0362788],
[0.021028, 0.0354801, 0.0415758],
[0.0232773, 0.0399604, 0.0469171],
[0.0256068, 0.0445012, 0.0522471],
[0.0280157, 0.048983, 0.0575702],
[0.0305031, 0.0534155, 0.0628901],
[0.0330692, 0.0578017, 0.06821],
[0.0357142, 0.0621441, 0.073533],
[0.0384392, 0.0664448, 0.0788614],
[0.0412278, 0.0707058, 0.0841975],
[0.0439814, 0.0749288, 0.0895433],
[0.0467087, 0.0791152, 0.0949004],
[0.0494141, 0.0832664, 0.10027],
[0.0521014, 0.0873836, 0.105655],
[0.0547748, 0.0914677, 0.111054],
[0.0574379, 0.0955197, 0.11647],
[0.0600944, 0.0995404, 0.121903],
[0.0627481, 0.10353, 0.127353],
[0.0654022, 0.107491, 0.132822],
[0.0680603, 0.111421, 0.138311],
[0.0707257, 0.115323, 0.143818],
[0.0734015, 0.119196, 0.149345],
[0.076091, 0.123042, 0.154891],
[0.078797, 0.126859, 0.160458],
[0.0815227, 0.13065, 0.166044],
[0.0842708, 0.134413, 0.17165],
[0.0870441, 0.138149, 0.177275],
[0.0898453, 0.141858, 0.18292],
[0.092677, 0.145541, 0.188584],
[0.0955415, 0.149197, 0.194266],
[0.0984413, 0.152828, 0.199966],
[0.101379, 0.156432, 0.205684],
[0.104356, 0.16001, 0.211419],
[0.107374, 0.163562, 0.217171],
[0.110436, 0.167089, 0.222938],
[0.113544, 0.17059, 0.22872],
[0.116699, 0.174065, 0.234516],
[0.119902, 0.177514, 0.240325],
[0.123156, 0.180938, 0.246147],
[0.126461, 0.184337, 0.25198],
[0.129819, 0.187711, 0.257823],
[0.13323, 0.191059, 0.263675],
[0.136697, 0.194382, 0.269536],
[0.140219, 0.19768, 0.275403],
[0.143797, 0.200953, 0.281276],
[0.147433, 0.204202, 0.287153],
[0.151126, 0.207425, 0.293034],
[0.154877, 0.210625, 0.298916],
[0.158686, 0.213799, 0.304799],
[0.162555, 0.21695, 0.310681],
[0.166481, 0.220076, 0.316561],
[0.170467, 0.223179, 0.322436],
[0.174512, 0.226258, 0.328307],
[0.178615, 0.229313, 0.33417],
[0.182776, 0.232345, 0.340025],
[0.186996, 0.235354, 0.34587],
[0.191273, 0.238341, 0.351704],
[0.195608, 0.241305, 0.357524],
[0.199999, 0.244248, 0.363329],
[0.204447, 0.247168, 0.369118],
[0.20895, 0.250067, 0.374889],
[0.213508, 0.252946, 0.38064],
[0.21812, 0.255803, 0.38637],
[0.222785, 0.258641, 0.392077],
[0.227502, 0.261459, 0.397759],
[0.232271, 0.264258, 0.403414],
[0.237091, 0.267038, 0.409041],
[0.24196, 0.269799, 0.414639],
[0.246878, 0.272544, 0.420205],
[0.251842, 0.275271, 0.425738],
[0.256854, 0.277981, 0.431236],
[0.26191, 0.280676, 0.436698],
[0.267011, 0.283356, 0.442121],
[0.272154, 0.286021, 0.447506],
[0.277339, 0.288672, 0.452848],
[0.282565, 0.291309, 0.458149],
[0.28783, 0.293935, 0.463405],
[0.293132, 0.296548, 0.468615],
[0.298472, 0.29915, 0.473778],
[0.303847, 0.301742, 0.478893],
[0.309256, 0.304325, 0.483957],
[0.314698, 0.306899, 0.48897],
[0.320172, 0.309465, 0.493931],
[0.325676, 0.312023, 0.498837],
[0.331209, 0.314576, 0.503689],
[0.336769, 0.317123, 0.508484],
[0.342356, 0.319666, 0.513221],
[0.347968, 0.322205, 0.5179],
[0.353604, 0.324741, 0.522519],
[0.359262, 0.327275, 0.527078],
[0.364941, 0.329809, 0.531575],
[0.37064, 0.332342, 0.536009],
[0.376358, 0.334877, 0.540381],
[0.382093, 0.337413, 0.544688],
[0.387843, 0.339951, 0.548931],
[0.393609, 0.342494, 0.553108],
[0.399388, 0.345041, 0.55722],
[0.405179, 0.347593, 0.561264],
[0.410981, 0.350152, 0.565243],
[0.416792, 0.352718, 0.569153],
[0.422612, 0.355293, 0.572996],
[0.428439, 0.357876, 0.576772],
[0.434273, 0.36047, 0.580479],
[0.440111, 0.363075, 0.584118],
[0.445952, 0.365691, 0.587689],
[0.451797, 0.368321, 0.591191],
[0.457642, 0.370964, 0.594626],
[0.463488, 0.373621, 0.597992],
[0.469333, 0.376294, 0.60129],
[0.475175, 0.378983, 0.604521],
[0.481015, 0.381689, 0.607684],
[0.48685, 0.384413, 0.610781],
[0.49268, 0.387155, 0.613811],
[0.498504, 0.389917, 0.616775],
[0.50432, 0.3927, 0.619674],
[0.510128, 0.395503, 0.622509],
[0.515926, 0.398328, 0.625279],
[0.521714, 0.401176, 0.627986],
[0.52749, 0.404046, 0.63063],
[0.533254, 0.406941, 0.633214],
[0.539005, 0.40986, 0.635736],
[0.544741, 0.412804, 0.638199],
[0.550462, 0.415775, 0.640603],
[0.556167, 0.418771, 0.64295],
[0.561855, 0.421795, 0.645241],
[0.567525, 0.424847, 0.647477],
[0.573176, 0.427927, 0.649658],
[0.578808, 0.431035, 0.651788],
[0.584419, 0.434173, 0.653866],
[0.590009, 0.437341, 0.655894],
[0.595577, 0.440539, 0.657874],
[0.601122, 0.443768, 0.659807],
[0.606644, 0.447028, 0.661695],
[0.612141, 0.45032, 0.663539],
[0.617613, 0.453644, 0.66534],
[0.623059, 0.457001, 0.667101],
[0.628478, 0.460391, 0.668823],
[0.63387, 0.463813, 0.670508],
[0.639235, 0.46727, 0.672158],
[0.64457, 0.47076, 0.673774],
[0.649876, 0.474285, 0.675357],
[0.655153, 0.477844, 0.676911],
[0.660398, 0.481438, 0.678436],
[0.665613, 0.485067, 0.679935],
[0.670796, 0.488732, 0.68141],
[0.675946, 0.492432, 0.682861],
[0.681063, 0.496167, 0.684292],
[0.686147, 0.499939, 0.685705],
[0.691197, 0.503747, 0.6871],
[0.696212, 0.507591, 0.688481],
[0.701192, 0.511471, 0.689849],
[0.706137, 0.515388, 0.691206],
[0.711045, 0.519342, 0.692554],
[0.715917, 0.523332, 0.693895],
[0.720752, 0.52736, 0.695232],
[0.72555, 0.531424, 0.696565],
[0.73031, 0.535525, 0.697898],
[0.735031, 0.539663, 0.699233],
[0.739714, 0.543838, 0.700571],
[0.744358, 0.54805, 0.701914],
[0.748962, 0.552299, 0.703265],
[0.753527, 0.556585, 0.704626],
[0.758052, 0.560908, 0.705998],
[0.762536, 0.565268, 0.707384],
[0.76698, 0.569665, 0.708785],
[0.771383, 0.574098, 0.710205],
[0.775745, 0.578568, 0.711644],
[0.780066, 0.583075, 0.713105],
[0.784345, 0.587618, 0.71459],
[0.788582, 0.592198, 0.716101],
[0.792778, 0.596813, 0.71764],
[0.796931, 0.601465, 0.719209],
[0.801043, 0.606152, 0.72081],
[0.805112, 0.610876, 0.722445],
[0.809138, 0.615634, 0.724115],
[0.813123, 0.620428, 0.725824],
[0.817064, 0.625257, 0.727572],
[0.820964, 0.630121, 0.729362],
[0.824821, 0.635019, 0.731195],
[0.828636, 0.639952, 0.733074],
[0.832408, 0.644918, 0.735],
[0.836138, 0.649919, 0.736975],
[0.839826, 0.654953, 0.739001],
[0.843473, 0.66002, 0.74108],
[0.847077, 0.66512, 0.743213],
[0.85064, 0.670252, 0.745402],
[0.854162, 0.675417, 0.747649],
[0.857643, 0.680613, 0.749956],
[0.861083, 0.685841, 0.752324],
[0.864483, 0.691101, 0.754755],
[0.867842, 0.69639, 0.75725],
[0.871163, 0.70171, 0.759812],
[0.874444, 0.70706, 0.76244],
[0.877687, 0.71244, 0.765138],
[0.880892, 0.717848, 0.767906],
[0.884059, 0.723286, 0.770746],
[0.887189, 0.728751, 0.773659],
[0.890284, 0.734244, 0.776646],
[0.893342, 0.739764, 0.779709],
[0.896367, 0.745311, 0.78285],
[0.899357, 0.750884, 0.786068],
[0.902314, 0.756483, 0.789366],
[0.905239, 0.762107, 0.792744],
[0.908133, 0.767756, 0.796203],
[0.910997, 0.773429, 0.799745],
[0.913832, 0.779126, 0.803371],
[0.916638, 0.784845, 0.80708],
[0.919418, 0.790587, 0.810875],
[0.922172, 0.796351, 0.814755],
[0.924902, 0.802137, 0.818722],
[0.927609, 0.807943, 0.822776],
[0.930294, 0.813769, 0.826918],
[0.932959, 0.819614, 0.831148],
[0.935606, 0.825479, 0.835466],
[0.938236, 0.831362, 0.839874],
[0.940851, 0.837262, 0.844371],
[0.943452, 0.843179, 0.848957],
[0.946042, 0.849112, 0.853633],
[0.948622, 0.855061, 0.858398],
[0.951195, 0.861025, 0.863253],
[0.953763, 0.867002, 0.868198],
[0.956327, 0.872994, 0.873232],
[0.95889, 0.878997, 0.878354],
[0.961456, 0.885013, 0.883565],
[0.964025, 0.89104, 0.888864],
[0.966601, 0.897077, 0.894249],
[0.969188, 0.903124, 0.899721],
[0.971787, 0.909179, 0.905278],
[0.974402, 0.915241, 0.910919],
[0.977036, 0.921311, 0.916643],
[0.979694, 0.927386, 0.922448],
[0.98238, 0.933465, 0.928332],
[0.985097, 0.939548, 0.934293],
[0.987851, 0.945633, 0.940328],
[0.990647, 0.951718, 0.946435],
[0.993492, 0.957802, 0.952609],
[0.996395, 0.963882, 0.958845],
[0.999365, 0.969955, 0.965138],
[1., 0.976017, 0.971479],
[1., 0.982061, 0.977854],
[1., 0.988074, 0.984236],
[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()
