from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000386358, 0.000335727, 0.000362582],
[0.00112663, 0.000951974, 0.00105367],
[0.00220882, 0.00182896, 0.00206086],
[0.00361862, 0.00294562, 0.00336972],
[0.00534821, 0.00428792, 0.00497208],
[0.00739305, 0.00584551, 0.00686297],
[0.00975052, 0.00761032, 0.00903935],
[0.0124193, 0.0095758, 0.0114994],
[0.015399, 0.0117365, 0.0142423],
[0.0186899, 0.0140878, 0.0172677],
[0.0222928, 0.0166257, 0.0205761],
[0.0262087, 0.0193466, 0.024168],
[0.0304393, 0.0222476, 0.0280445],
[0.0349863, 0.0253258, 0.032207],
[0.0398518, 0.0285788, 0.0366569],
[0.04482, 0.0320044, 0.0413739],
[0.0497371, 0.0356005, 0.0460909],
[0.0546148, 0.0393654, 0.0507684],
[0.0594568, 0.043194, 0.0554102],
[0.0642665, 0.0469641, 0.0600196],
[0.0690469, 0.0506885, 0.0645995],
[0.0738005, 0.05437, 0.0691526],
[0.0785298, 0.0580113, 0.0736811],
[0.0832369, 0.0616145, 0.0781873],
[0.0879236, 0.0651819, 0.082673],
[0.0925919, 0.0687154, 0.08714],
[0.0972432, 0.0722165, 0.0915899],
[0.101879, 0.0756871, 0.0960242],
[0.106501, 0.0791284, 0.100444],
[0.11111, 0.082542, 0.104851],
[0.115707, 0.085929, 0.109246],
[0.120294, 0.0892905, 0.113631],
[0.124871, 0.0926278, 0.118006],
[0.12944, 0.0959417, 0.122372],
[0.134001, 0.0992333, 0.12673],
[0.138555, 0.102503, 0.13108],
[0.143102, 0.105753, 0.135425],
[0.147645, 0.108982, 0.139764],
[0.152182, 0.112193, 0.144098],
[0.156716, 0.115384, 0.148428],
[0.161246, 0.118558, 0.152754],
[0.165774, 0.121715, 0.157078],
[0.170298, 0.124855, 0.161398],
[0.174822, 0.127979, 0.165717],
[0.179344, 0.131088, 0.170035],
[0.183865, 0.134181, 0.174351],
[0.188386, 0.137259, 0.178667],
[0.192907, 0.140324, 0.182983],
[0.197428, 0.143375, 0.1873],
[0.201951, 0.146412, 0.191617],
[0.206474, 0.149436, 0.195936],
[0.211, 0.152448, 0.200256],
[0.215527, 0.155447, 0.204578],
[0.220058, 0.158435, 0.208902],
[0.22459, 0.161411, 0.213229],
[0.229126, 0.164376, 0.217559],
[0.233665, 0.167329, 0.221893],
[0.238208, 0.170272, 0.22623],
[0.242755, 0.173204, 0.230571],
[0.247307, 0.176127, 0.234916],
[0.251863, 0.179039, 0.239265],
[0.256423, 0.181942, 0.24362],
[0.260989, 0.184835, 0.247979],
[0.26556, 0.187719, 0.252344],
[0.270137, 0.190593, 0.256714],
[0.274719, 0.193459, 0.26109],
[0.279308, 0.196317, 0.265472],
[0.283903, 0.199166, 0.269861],
[0.288505, 0.202006, 0.274256],
[0.293113, 0.204839, 0.278657],
[0.297728, 0.207663, 0.283066],
[0.302351, 0.21048, 0.287482],
[0.306981, 0.21329, 0.291905],
[0.311618, 0.216091, 0.296336],
[0.316263, 0.218886, 0.300774],
[0.320917, 0.221674, 0.305221],
[0.325578, 0.224454, 0.309676],
[0.330248, 0.227228, 0.314139],
[0.334927, 0.229995, 0.318611],
[0.339614, 0.232755, 0.323091],
[0.34431, 0.235509, 0.327581],
[0.349015, 0.238256, 0.332079],
[0.35373, 0.240997, 0.336588],
[0.358453, 0.243732, 0.341105],
[0.363187, 0.246461, 0.345632],
[0.36793, 0.249184, 0.35017],
[0.372684, 0.251902, 0.354717],
[0.377447, 0.254613, 0.359274],
[0.382221, 0.257319, 0.363842],
[0.387005, 0.26002, 0.36842],
[0.3918, 0.262715, 0.373009],
[0.396606, 0.265404, 0.377609],
[0.401422, 0.268089, 0.38222],
[0.40625, 0.270768, 0.386842],
[0.411089, 0.273442, 0.391475],
[0.415939, 0.276111, 0.39612],
[0.420801, 0.278775, 0.400777],
[0.425674, 0.281434, 0.405446],
[0.430559, 0.284089, 0.410126],
[0.435457, 0.286738, 0.414819],
[0.440366, 0.289383, 0.419524],
[0.445288, 0.292024, 0.424241],
[0.450222, 0.29466, 0.428971],
[0.455168, 0.297291, 0.433714],
[0.460128, 0.299918, 0.438469],
[0.4651, 0.30254, 0.443238],
[0.470085, 0.305159, 0.44802],
[0.475083, 0.307772, 0.452815],
[0.480095, 0.310382, 0.457623],
[0.48512, 0.312988, 0.462446],
[0.490158, 0.315589, 0.467282],
[0.49521, 0.318187, 0.472132],
[0.500276, 0.32078, 0.476996],
[0.505356, 0.32337, 0.481874],
[0.51045, 0.325955, 0.486767],
[0.515559, 0.328537, 0.491674],
[0.520681, 0.331115, 0.496596],
[0.525819, 0.333689, 0.501533],
[0.530971, 0.336259, 0.506484],
[0.536137, 0.338825, 0.511451],
[0.541319, 0.341388, 0.516433],
[0.546515, 0.343947, 0.52143],
[0.551727, 0.346503, 0.526443],
[0.556954, 0.349055, 0.531472],
[0.562197, 0.351603, 0.536516],
[0.567455, 0.354148, 0.541576],
[0.572729, 0.356689, 0.546653],
[0.576766, 0.360316, 0.550502],
[0.579557, 0.365024, 0.553119],
[0.58235, 0.369726, 0.555745],
[0.585146, 0.374423, 0.558381],
[0.587946, 0.379114, 0.561026],
[0.590749, 0.383801, 0.56368],
[0.593556, 0.388483, 0.566344],
[0.596366, 0.393162, 0.569018],
[0.59918, 0.397837, 0.571701],
[0.601999, 0.402509, 0.574394],
[0.604822, 0.407178, 0.577097],
[0.607649, 0.411845, 0.57981],
[0.610481, 0.41651, 0.582533],
[0.613318, 0.421173, 0.585266],
[0.616159, 0.425836, 0.588009],
[0.619006, 0.430497, 0.590762],
[0.621858, 0.435157, 0.593526],
[0.624716, 0.439818, 0.5963],
[0.627579, 0.444478, 0.599085],
[0.630449, 0.449138, 0.601881],
[0.633324, 0.453799, 0.604687],
[0.636205, 0.458461, 0.607504],
[0.639093, 0.463124, 0.610331],
[0.641987, 0.467788, 0.61317],
[0.644887, 0.472454, 0.61602],
[0.647795, 0.477122, 0.618881],
[0.650709, 0.481791, 0.621753],
[0.653631, 0.486463, 0.624637],
[0.65656, 0.491138, 0.627532],
[0.659496, 0.495815, 0.630438],
[0.66244, 0.500495, 0.633356],
[0.665392, 0.505179, 0.636286],
[0.668351, 0.509866, 0.639227],
[0.671319, 0.514556, 0.642181],
[0.674295, 0.51925, 0.645146],
[0.67728, 0.523949, 0.648124],
[0.680273, 0.528651, 0.651114],
[0.683275, 0.533358, 0.654116],
[0.686285, 0.53807, 0.65713],
[0.689305, 0.542786, 0.660157],
[0.692334, 0.547507, 0.663196],
[0.695373, 0.552234, 0.666248],
[0.69842, 0.556966, 0.669313],
[0.701478, 0.561703, 0.672391],
[0.704546, 0.566446, 0.675481],
[0.707623, 0.571195, 0.678585],
[0.710711, 0.57595, 0.681702],
[0.713809, 0.580711, 0.684832],
[0.716918, 0.585478, 0.687975],
[0.720037, 0.590252, 0.691132],
[0.723167, 0.595032, 0.694303],
[0.726309, 0.59982, 0.697487],
[0.729461, 0.604614, 0.700686],
[0.732625, 0.609416, 0.703898],
[0.7358, 0.614225, 0.707124],
[0.738987, 0.619041, 0.710364],
[0.742186, 0.623865, 0.713618],
[0.745397, 0.628697, 0.716887],
[0.74862, 0.633537, 0.72017],
[0.751855, 0.638384, 0.723468],
[0.755103, 0.64324, 0.726781],
[0.758363, 0.648105, 0.730108],
[0.761637, 0.652978, 0.733451],
[0.764923, 0.657859, 0.736808],
[0.768223, 0.66275, 0.740181],
[0.771536, 0.667649, 0.743569],
[0.774862, 0.672557, 0.746972],
[0.778202, 0.677475, 0.750391],
[0.781557, 0.682402, 0.753826],
[0.784925, 0.687338, 0.757276],
[0.788307, 0.692285, 0.760742],
[0.791704, 0.697241, 0.764225],
[0.795116, 0.702206, 0.767723],
[0.798542, 0.707182, 0.771238],
[0.801983, 0.712169, 0.774769],
[0.80544, 0.717165, 0.778317],
[0.808912, 0.722172, 0.781882],
[0.812399, 0.72719, 0.785463],
[0.815903, 0.732218, 0.789062],
[0.819422, 0.737257, 0.792678],
[0.822957, 0.742308, 0.796311],
[0.826509, 0.747369, 0.799961],
[0.830077, 0.752442, 0.803629],
[0.833662, 0.757526, 0.807315],
[0.837263, 0.762622, 0.811018],
[0.840882, 0.767729, 0.81474],
[0.844519, 0.772848, 0.81848],
[0.848173, 0.777979, 0.822239],
[0.851844, 0.783122, 0.826015],
[0.855534, 0.788278, 0.829811],
[0.859242, 0.793445, 0.833626],
[0.862968, 0.798625, 0.837459],
[0.866714, 0.803818, 0.841312],
[0.870478, 0.809023, 0.845184],
[0.874261, 0.814242, 0.849076],
[0.878064, 0.819473, 0.852988],
[0.881886, 0.824717, 0.856919],
[0.885728, 0.829974, 0.860871],
[0.889591, 0.835244, 0.864843],
[0.893474, 0.840528, 0.868836],
[0.897378, 0.845826, 0.87285],
[0.901303, 0.851137, 0.876885],
[0.905249, 0.856461, 0.880941],
[0.909217, 0.8618, 0.885019],
[0.913207, 0.867152, 0.889118],
[0.917219, 0.872518, 0.89324],
[0.921255, 0.877898, 0.897384],
[0.925313, 0.883293, 0.901551],
[0.929394, 0.888701, 0.90574],
[0.9335, 0.894124, 0.909953],
[0.93763, 0.899561, 0.914189],
[0.941785, 0.905013, 0.91845],
[0.945965, 0.910479, 0.922735],
[0.950171, 0.915959, 0.927044],
[0.954403, 0.921453, 0.931379],
[0.958663, 0.926962, 0.93574],
[0.96295, 0.932485, 0.940127],
[0.967267, 0.938022, 0.944541],
[0.971613, 0.943573, 0.948983],
[0.97599, 0.949137, 0.953454],
[0.980399, 0.954715, 0.957954],
[0.984842, 0.960305, 0.962486],
[0.989322, 0.965907, 0.96705],
[0.99384, 0.97152, 0.971649],
[0.998401, 0.977143, 0.976286],
[1., 0.982771, 0.980966],
[1., 0.988399, 0.9857],
[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()
