from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.643785, 0.658006, 0.437032],
[0.644168, 0.651842, 0.436778],
[0.644495, 0.645698, 0.436457],
[0.644769, 0.63957, 0.436069],
[0.644995, 0.633459, 0.43562],
[0.645175, 0.627361, 0.435112],
[0.645316, 0.621276, 0.434549],
[0.645418, 0.615201, 0.433936],
[0.645485, 0.609135, 0.433277],
[0.645521, 0.603078, 0.432578],
[0.645525, 0.597026, 0.431847],
[0.645502, 0.59098, 0.431089],
[0.645448, 0.584937, 0.430311],
[0.645366, 0.578898, 0.42952],
[0.645254, 0.572861, 0.428724],
[0.645109, 0.566827, 0.427929],
[0.644931, 0.560797, 0.427142],
[0.644715, 0.55477, 0.426369],
[0.64446, 0.548749, 0.425614],
[0.644161, 0.542733, 0.42488],
[0.643816, 0.536724, 0.424169],
[0.643422, 0.530723, 0.423481],
[0.642977, 0.524731, 0.422813],
[0.642481, 0.518749, 0.422165],
[0.641933, 0.512777, 0.421531],
[0.641337, 0.506815, 0.420906],
[0.640692, 0.500862, 0.420284],
[0.640004, 0.494917, 0.41966],
[0.639276, 0.488976, 0.419027],
[0.638513, 0.48304, 0.418382],
[0.637719, 0.477104, 0.417718],
[0.636901, 0.471166, 0.417033],
[0.634988, 0.465833, 0.416425],
[0.625551, 0.464737, 0.416482],
[0.616165, 0.46359, 0.416487],
[0.606826, 0.462391, 0.416438],
[0.597539, 0.461142, 0.416339],
[0.5883, 0.459843, 0.416187],
[0.57911, 0.458494, 0.415983],
[0.569971, 0.457097, 0.415729],
[0.560882, 0.455652, 0.415423],
[0.551843, 0.454161, 0.415068],
[0.542854, 0.452622, 0.414661],
[0.533916, 0.451037, 0.414206],
[0.525027, 0.449407, 0.413701],
[0.51619, 0.447731, 0.413149],
[0.507403, 0.446013, 0.412553],
[0.498664, 0.444249, 0.411914],
[0.489975, 0.442444, 0.411241],
[0.481333, 0.440594, 0.410542],
[0.472739, 0.438702, 0.409834],
[0.464197, 0.43676, 0.409137],
[0.455728, 0.434759, 0.408484],
[0.447388, 0.432676, 0.407901],
[0.439275, 0.430473, 0.407367],
[0.431515, 0.428117, 0.406779],
[0.424159, 0.425609, 0.405961],
[0.417118, 0.423002, 0.404801],
[0.410222, 0.420363, 0.403313],
[0.403333, 0.417737, 0.40159],
[0.396369, 0.415146, 0.399728],
[0.389289, 0.412594, 0.397795],
[0.382075, 0.410083, 0.395836],
[0.374718, 0.407609, 0.393877],
[0.369024, 0.40699, 0.393735],
[0.3686, 0.411867, 0.39903],
[0.368, 0.416786, 0.404371],
[0.36722, 0.421746, 0.40976],
[0.366254, 0.426746, 0.415202],
[0.365097, 0.431786, 0.420697],
[0.363742, 0.436865, 0.426249],
[0.36218, 0.441983, 0.431857],
[0.360405, 0.447141, 0.437524],
[0.358404, 0.452337, 0.44325],
[0.356168, 0.457572, 0.449035],
[0.353686, 0.462848, 0.454882],
[0.350941, 0.468161, 0.46079],
[0.347923, 0.473516, 0.466761],
[0.344611, 0.47891, 0.472794],
[0.340991, 0.484344, 0.478893],
[0.337039, 0.489819, 0.485055],
[0.332737, 0.495335, 0.491285],
[0.328053, 0.500894, 0.497582],
[0.32296, 0.506493, 0.503946],
[0.317426, 0.512135, 0.51038],
[0.311409, 0.51782, 0.516883],
[0.304868, 0.523548, 0.523458],
[0.297747, 0.52932, 0.530104],
[0.289987, 0.535136, 0.536825],
[0.281511, 0.540998, 0.543621],
[0.272231, 0.546903, 0.550492],
[0.26203, 0.552856, 0.55744],
[0.250765, 0.558855, 0.564466],
[0.238255, 0.564901, 0.571573],
[0.224248, 0.570995, 0.57876],
[0.208398, 0.577137, 0.586031],
[0.20612, 0.581649, 0.592715],
[0.227809, 0.583395, 0.598293],
[0.247504, 0.585174, 0.603854],
[0.265657, 0.586981, 0.609398],
[0.282569, 0.588821, 0.614929],
[0.298454, 0.590692, 0.620446],
[0.313474, 0.592596, 0.625956],
[0.32775, 0.594534, 0.63146],
[0.341378, 0.596503, 0.63696],
[0.354438, 0.598507, 0.642462],
[0.36699, 0.600544, 0.647966],
[0.379085, 0.602616, 0.65348],
[0.390771, 0.604721, 0.659005],
[0.402085, 0.606861, 0.664547],
[0.413058, 0.609034, 0.67011],
[0.423718, 0.611239, 0.675696],
[0.434091, 0.613478, 0.681316],
[0.444198, 0.615748, 0.686971],
[0.454062, 0.61805, 0.692669],
[0.463697, 0.620382, 0.698414],
[0.473127, 0.622743, 0.704212],
[0.482364, 0.625131, 0.710069],
[0.491422, 0.627543, 0.71599],
[0.500319, 0.629981, 0.721983],
[0.509066, 0.632439, 0.72805],
[0.517679, 0.634917, 0.734201],
[0.526169, 0.637411, 0.740437],
[0.534551, 0.63992, 0.746767],
[0.542836, 0.64244, 0.753194],
[0.551034, 0.644968, 0.759722],
[0.559161, 0.647503, 0.766357],
[0.567225, 0.650038, 0.773101],
[0.576242, 0.652613, 0.776961],
[0.586117, 0.655246, 0.777921],
[0.595829, 0.657908, 0.778979],
[0.605388, 0.660596, 0.780133],
[0.614806, 0.66331, 0.781386],
[0.624094, 0.666047, 0.782739],
[0.633262, 0.668806, 0.784193],
[0.642322, 0.671586, 0.785751],
[0.651283, 0.674382, 0.787412],
[0.660159, 0.677196, 0.789181],
[0.668958, 0.680021, 0.791056],
[0.677695, 0.682856, 0.79304],
[0.68638, 0.685697, 0.795133],
[0.695026, 0.68854, 0.797334],
[0.703646, 0.691382, 0.799644],
[0.712253, 0.694216, 0.80206],
[0.720861, 0.69704, 0.804581],
[0.729483, 0.699847, 0.807203],
[0.738135, 0.702634, 0.809922],
[0.74683, 0.705396, 0.812732],
[0.755579, 0.708125, 0.815625],
[0.764399, 0.71082, 0.818596],
[0.773297, 0.713474, 0.821634],
[0.782289, 0.716084, 0.824731],
[0.791381, 0.718645, 0.827875],
[0.800585, 0.721155, 0.831058],
[0.809905, 0.72361, 0.834269],
[0.819348, 0.726008, 0.837494],
[0.828919, 0.728347, 0.840727],
[0.838619, 0.730625, 0.843955],
[0.848452, 0.732842, 0.847172],
[0.858417, 0.734995, 0.850366],
[0.862404, 0.740184, 0.852267],
[0.862799, 0.747185, 0.853455],
[0.863259, 0.754141, 0.854705],
[0.863787, 0.761056, 0.856019],
[0.864382, 0.76793, 0.857395],
[0.86505, 0.774764, 0.858833],
[0.86579, 0.781558, 0.860332],
[0.866608, 0.788315, 0.861894],
[0.867507, 0.795032, 0.863516],
[0.868487, 0.801711, 0.865197],
[0.869557, 0.808351, 0.86694],
[0.870719, 0.814951, 0.868742],
[0.871982, 0.821512, 0.870606],
[0.873351, 0.82803, 0.872529],
[0.874838, 0.834504, 0.874516],
[0.876451, 0.840931, 0.876568],
[0.878204, 0.847305, 0.878689],
[0.880114, 0.853622, 0.880889],
[0.882194, 0.859875, 0.883181],
[0.88446, 0.866058, 0.885593],
[0.886911, 0.872167, 0.888164],
[0.889521, 0.878211, 0.890954],
[0.892204, 0.884217, 0.894021],
[0.894825, 0.890238, 0.897383],
[0.897241, 0.896338, 0.900977],
[0.899373, 0.902557, 0.904679],
[0.901219, 0.90891, 0.908375],
[0.902812, 0.915387, 0.911988],
[0.904196, 0.921976, 0.915492],
[0.905401, 0.92866, 0.918878],
[0.906453, 0.935432, 0.922153],
[0.907364, 0.942282, 0.925326],
[0.900475, 0.941554, 0.920816],
[0.890923, 0.938335, 0.913701],
[0.88127, 0.935172, 0.90652],
[0.871515, 0.932059, 0.899278],
[0.861659, 0.928997, 0.891981],
[0.8517, 0.925982, 0.884632],
[0.841638, 0.923013, 0.877234],
[0.83147, 0.92009, 0.869793],
[0.821191, 0.917209, 0.862308],
[0.810801, 0.914372, 0.854782],
[0.800294, 0.911576, 0.847216],
[0.789667, 0.908821, 0.839612],
[0.778914, 0.906105, 0.83197],
[0.76803, 0.903429, 0.824291],
[0.757011, 0.900792, 0.816577],
[0.745848, 0.898191, 0.808827],
[0.734538, 0.895629, 0.801042],
[0.723071, 0.893102, 0.793222],
[0.71144, 0.890612, 0.785368],
[0.699635, 0.888156, 0.777478],
[0.687646, 0.885734, 0.769553],
[0.675465, 0.883348, 0.761595],
[0.663079, 0.880995, 0.7536],
[0.650475, 0.878675, 0.745572],
[0.637638, 0.876386, 0.737506],
[0.624557, 0.87413, 0.729407],
[0.611207, 0.871904, 0.72127],
[0.597573, 0.869709, 0.713097],
[0.583632, 0.867546, 0.704888],
[0.569359, 0.865411, 0.69664],
[0.554726, 0.863305, 0.688356],
[0.539699, 0.861228, 0.680032],
[0.543465, 0.85496, 0.672739],
[0.549583, 0.848139, 0.665605],
[0.555336, 0.841368, 0.658477],
[0.560755, 0.834647, 0.651354],
[0.565858, 0.827973, 0.644228],
[0.570671, 0.821346, 0.637098],
[0.57521, 0.814763, 0.629956],
[0.579498, 0.808224, 0.622801],
[0.58355, 0.801725, 0.615625],
[0.587387, 0.795267, 0.608427],
[0.591019, 0.788845, 0.601199],
[0.594469, 0.782459, 0.593938],
[0.59775, 0.776107, 0.58664],
[0.600874, 0.769785, 0.579299],
[0.603859, 0.763492, 0.571913],
[0.606715, 0.757223, 0.564475],
[0.609457, 0.750979, 0.556984],
[0.612097, 0.744754, 0.549434],
[0.614647, 0.738545, 0.541824],
[0.617119, 0.732352, 0.534151],
[0.619523, 0.726169, 0.526412],
[0.621871, 0.719994, 0.518608],
[0.624169, 0.713822, 0.510735],
[0.626429, 0.707653, 0.502797],
[0.628655, 0.701481, 0.494789],
[0.630857, 0.695305, 0.486716],
[0.633039, 0.689122, 0.47858],
[0.635206, 0.682928, 0.470381],
[0.637362, 0.676722, 0.462124],
[0.639509, 0.670501, 0.45381],
[0.64165, 0.664263, 0.445446],
[0.643785, 0.658006, 0.437032]]

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