from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.829587, 0.477372, 0.35371],
[0.822484, 0.47735, 0.356374],
[0.815408, 0.477294, 0.358985],
[0.808352, 0.477203, 0.361542],
[0.80132, 0.477079, 0.364048],
[0.794312, 0.476924, 0.366504],
[0.787326, 0.476735, 0.368909],
[0.780362, 0.476515, 0.371263],
[0.773424, 0.476264, 0.373568],
[0.766506, 0.475981, 0.375824],
[0.759611, 0.475668, 0.378032],
[0.75274, 0.475327, 0.380193],
[0.745891, 0.474954, 0.382305],
[0.739064, 0.474553, 0.384369],
[0.732261, 0.474124, 0.386389],
[0.725479, 0.473666, 0.388361],
[0.71872, 0.47318, 0.390288],
[0.711983, 0.472667, 0.39217],
[0.705269, 0.472127, 0.394005],
[0.698577, 0.471559, 0.395795],
[0.691907, 0.470966, 0.397543],
[0.68526, 0.470346, 0.399245],
[0.678634, 0.4697, 0.400902],
[0.672032, 0.469029, 0.402517],
[0.665451, 0.468333, 0.404087],
[0.658893, 0.467611, 0.405613],
[0.652357, 0.466866, 0.407098],
[0.645844, 0.466096, 0.408538],
[0.639352, 0.465301, 0.409935],
[0.632884, 0.464484, 0.41129],
[0.626437, 0.463642, 0.412601],
[0.620013, 0.462777, 0.413869],
[0.613613, 0.46189, 0.415096],
[0.607235, 0.460979, 0.416279],
[0.600879, 0.460045, 0.417419],
[0.594548, 0.45909, 0.418517],
[0.588238, 0.458111, 0.419571],
[0.581953, 0.45711, 0.420582],
[0.575692, 0.456089, 0.421551],
[0.569454, 0.455044, 0.422475],
[0.563241, 0.453978, 0.423356],
[0.557054, 0.452892, 0.424193],
[0.55089, 0.451783, 0.424985],
[0.544753, 0.450653, 0.425731],
[0.538642, 0.449502, 0.426433],
[0.532558, 0.448329, 0.427088],
[0.526501, 0.447135, 0.427695],
[0.520474, 0.445921, 0.428255],
[0.514476, 0.444684, 0.428764],
[0.508508, 0.443427, 0.429223],
[0.502572, 0.442149, 0.429629],
[0.49667, 0.440849, 0.429979],
[0.490803, 0.439527, 0.430272],
[0.484974, 0.438184, 0.430503],
[0.479184, 0.436818, 0.430667],
[0.473438, 0.43543, 0.430758],
[0.46774, 0.434021, 0.430767],
[0.462095, 0.432587, 0.430678],
[0.456514, 0.43113, 0.430467],
[0.451017, 0.429646, 0.430095],
[0.445648, 0.428124, 0.429483],
[0.44053, 0.426529, 0.428519],
[0.435878, 0.42478, 0.427182],
[0.431674, 0.422854, 0.425774],
[0.429024, 0.422111, 0.425081],
[0.430689, 0.425084, 0.426211],
[0.432207, 0.428095, 0.427573],
[0.433421, 0.43123, 0.42892],
[0.434427, 0.434469, 0.430051],
[0.435333, 0.437769, 0.430972],
[0.436179, 0.441108, 0.431733],
[0.436976, 0.444476, 0.432372],
[0.437732, 0.447869, 0.432914],
[0.438448, 0.451283, 0.433375],
[0.439123, 0.454717, 0.433763],
[0.439759, 0.458171, 0.434088],
[0.440356, 0.461643, 0.434354],
[0.440913, 0.465131, 0.434564],
[0.441432, 0.468638, 0.434723],
[0.441911, 0.47216, 0.434832],
[0.44235, 0.475698, 0.434892],
[0.44275, 0.479252, 0.434906],
[0.44311, 0.482822, 0.434874],
[0.443429, 0.486406, 0.434796],
[0.443708, 0.490006, 0.434676],
[0.443947, 0.493621, 0.434512],
[0.444143, 0.497249, 0.434303],
[0.444298, 0.500893, 0.434053],
[0.444411, 0.504551, 0.433761],
[0.44448, 0.508222, 0.433425],
[0.444507, 0.511909, 0.433048],
[0.44449, 0.515609, 0.432629],
[0.444428, 0.519323, 0.432167],
[0.444321, 0.523051, 0.431663],
[0.444168, 0.526794, 0.431117],
[0.443968, 0.530549, 0.430528],
[0.443721, 0.534318, 0.429897],
[0.443426, 0.538102, 0.429224],
[0.443081, 0.541898, 0.428506],
[0.442687, 0.545709, 0.427746],
[0.442242, 0.549534, 0.426943],
[0.441745, 0.553371, 0.426095],
[0.441196, 0.557223, 0.425203],
[0.440592, 0.561089, 0.424268],
[0.439934, 0.564967, 0.423286],
[0.439219, 0.568859, 0.42226],
[0.438449, 0.572766, 0.421188],
[0.437617, 0.576685, 0.420069],
[0.436729, 0.580618, 0.418904],
[0.435778, 0.584566, 0.417692],
[0.434765, 0.588525, 0.416433],
[0.433688, 0.5925, 0.415125],
[0.432547, 0.596488, 0.413768],
[0.431336, 0.60049, 0.41236],
[0.43006, 0.604505, 0.410904],
[0.428711, 0.608535, 0.409398],
[0.427291, 0.612577, 0.407838],
[0.425796, 0.616634, 0.406227],
[0.424227, 0.620705, 0.404563],
[0.422577, 0.624789, 0.402844],
[0.420848, 0.628888, 0.401073],
[0.419038, 0.633, 0.399246],
[0.41714, 0.637126, 0.39736],
[0.415157, 0.641266, 0.395419],
[0.413083, 0.645421, 0.393419],
[0.410915, 0.649588, 0.391361],
[0.408651, 0.653771, 0.389241],
[0.40629, 0.657968, 0.38706],
[0.409608, 0.660913, 0.38526],
[0.418581, 0.6626, 0.383852],
[0.427431, 0.664288, 0.382392],
[0.436163, 0.665975, 0.380881],
[0.444795, 0.667663, 0.379316],
[0.453331, 0.66935, 0.377695],
[0.461782, 0.671034, 0.376018],
[0.470154, 0.672718, 0.374284],
[0.478458, 0.674399, 0.372493],
[0.486697, 0.676075, 0.37064],
[0.494879, 0.677749, 0.368728],
[0.50301, 0.679418, 0.366753],
[0.511092, 0.681081, 0.364715],
[0.519135, 0.682739, 0.362617],
[0.52714, 0.684391, 0.360451],
[0.535113, 0.686034, 0.358219],
[0.543057, 0.687672, 0.355922],
[0.550977, 0.689301, 0.353557],
[0.558873, 0.690921, 0.351124],
[0.566752, 0.692532, 0.348621],
[0.574614, 0.694134, 0.346048],
[0.582464, 0.695724, 0.343403],
[0.590302, 0.697306, 0.340686],
[0.598134, 0.698875, 0.337898],
[0.605956, 0.700433, 0.335033],
[0.613777, 0.701979, 0.332093],
[0.621595, 0.703512, 0.329076],
[0.62941, 0.705032, 0.325981],
[0.637226, 0.70654, 0.322809],
[0.645045, 0.708034, 0.319554],
[0.652866, 0.709513, 0.316217],
[0.660693, 0.710978, 0.312796],
[0.668525, 0.712429, 0.309289],
[0.676362, 0.713864, 0.305696],
[0.684208, 0.715285, 0.302011],
[0.692063, 0.71669, 0.298234],
[0.699925, 0.718078, 0.294362],
[0.707798, 0.719451, 0.290392],
[0.715681, 0.720807, 0.286324],
[0.723575, 0.722146, 0.282149],
[0.731481, 0.723469, 0.277866],
[0.739399, 0.724775, 0.273472],
[0.747329, 0.726062, 0.26896],
[0.755273, 0.727333, 0.26433],
[0.76323, 0.728586, 0.25957],
[0.771201, 0.72982, 0.254675],
[0.779187, 0.731036, 0.249641],
[0.787187, 0.732234, 0.244459],
[0.795201, 0.733413, 0.239123],
[0.803232, 0.734573, 0.233617],
[0.811278, 0.735715, 0.227934],
[0.819339, 0.736836, 0.222059],
[0.827417, 0.737938, 0.215981],
[0.835512, 0.739021, 0.20968],
[0.843622, 0.740083, 0.203142],
[0.851751, 0.741126, 0.196337],
[0.859896, 0.742149, 0.189242],
[0.868058, 0.74315, 0.181824],
[0.87624, 0.744131, 0.174046],
[0.884438, 0.745091, 0.165864],
[0.892654, 0.746029, 0.157209],
[0.900889, 0.746946, 0.148014],
[0.909144, 0.747842, 0.138177],
[0.917415, 0.748715, 0.127568],
[0.918559, 0.745632, 0.131983],
[0.917314, 0.74124, 0.140948],
[0.916063, 0.736857, 0.14929],
[0.914803, 0.73248, 0.1571],
[0.913536, 0.728112, 0.16445],
[0.912264, 0.723751, 0.171396],
[0.910983, 0.719396, 0.177989],
[0.909695, 0.715049, 0.184265],
[0.908402, 0.710709, 0.190256],
[0.907101, 0.706374, 0.195986],
[0.905795, 0.702046, 0.201476],
[0.904484, 0.697726, 0.206755],
[0.903165, 0.69341, 0.211832],
[0.901841, 0.6891, 0.216725],
[0.900512, 0.684797, 0.221448],
[0.899178, 0.680498, 0.226007],
[0.897837, 0.676205, 0.23042],
[0.896492, 0.671917, 0.234695],
[0.895141, 0.667634, 0.238838],
[0.893784, 0.663356, 0.242858],
[0.892424, 0.659083, 0.246759],
[0.891058, 0.654814, 0.250553],
[0.889686, 0.65055, 0.254244],
[0.888311, 0.646291, 0.257837],
[0.886929, 0.642034, 0.261335],
[0.885543, 0.637782, 0.264743],
[0.884153, 0.633535, 0.26807],
[0.882756, 0.62929, 0.271316],
[0.881355, 0.625049, 0.274486],
[0.87995, 0.620812, 0.277584],
[0.878539, 0.616578, 0.280608],
[0.877123, 0.612347, 0.283569],
[0.875703, 0.608119, 0.286466],
[0.874277, 0.603894, 0.289301],
[0.872845, 0.599672, 0.292078],
[0.87141, 0.595453, 0.294796],
[0.86997, 0.591235, 0.297462],
[0.868523, 0.58702, 0.300075],
[0.867073, 0.582808, 0.302639],
[0.865616, 0.578597, 0.305153],
[0.864155, 0.574387, 0.30762],
[0.86269, 0.57018, 0.31004],
[0.861219, 0.565974, 0.312417],
[0.859743, 0.561769, 0.314751],
[0.858264, 0.557565, 0.317044],
[0.856779, 0.553361, 0.319295],
[0.855291, 0.549158, 0.321505],
[0.853799, 0.544955, 0.323679],
[0.852301, 0.540752, 0.325814],
[0.850801, 0.536547, 0.327911],
[0.849297, 0.532343, 0.329974],
[0.84779, 0.528136, 0.331997],
[0.846279, 0.523928, 0.333988],
[0.844768, 0.519718, 0.335945],
[0.843252, 0.515505, 0.337867],
[0.841735, 0.511289, 0.339755],
[0.840218, 0.50707, 0.34161],
[0.838699, 0.502845, 0.343433],
[0.837178, 0.498616, 0.345223],
[0.835659, 0.494381, 0.346983],
[0.834138, 0.49014, 0.348711],
[0.83262, 0.485891, 0.350406],
[0.831103, 0.481637, 0.352074],
[0.829587, 0.477372, 0.35371]]

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()
