from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.00033134, 0.000359198, 0.000344694],
[0.000923553, 0.00103863, 0.000987377],
[0.00175165, 0.00202409, 0.00191119],
[0.00278982, 0.00329945, 0.00309771],
[0.00401999, 0.00485507, 0.0045352],
[0.00542826, 0.00668461, 0.0062154],
[0.00700328, 0.00878376, 0.00813217],
[0.0087355, 0.0111495, 0.0102808],
[0.0106166, 0.0137798, 0.0126575],
[0.0126392, 0.0166733, 0.0152595],
[0.0147967, 0.0198292, 0.0180842],
[0.0170831, 0.0232471, 0.0211298],
[0.0194928, 0.0269269, 0.0243948],
[0.0220207, 0.0308689, 0.0278779],
[0.0246618, 0.0350736, 0.0315781],
[0.0274118, 0.0395417, 0.0354948],
[0.0302662, 0.044111, 0.0396273],
[0.033221, 0.0486275, 0.0438319],
[0.0362722, 0.0531045, 0.0479824],
[0.0394161, 0.0575452, 0.0520914],
[0.0425788, 0.0619527, 0.0561618],
[0.0456733, 0.0663295, 0.0601964],
[0.0487119, 0.0706782, 0.0641977],
[0.0516971, 0.0750008, 0.068168],
[0.0546309, 0.0792994, 0.0721092],
[0.0575153, 0.0835758, 0.0760232],
[0.060352, 0.0878315, 0.0799117],
[0.0631425, 0.0920681, 0.0837763],
[0.0658885, 0.096287, 0.0876184],
[0.068591, 0.100489, 0.0914392],
[0.0712515, 0.104677, 0.0952401],
[0.0738709, 0.108849, 0.0990222],
[0.0764504, 0.113009, 0.102786],
[0.0789907, 0.117157, 0.106534],
[0.0814929, 0.121293, 0.110265],
[0.0839577, 0.125419, 0.113982],
[0.0863858, 0.129535, 0.117684],
[0.0887778, 0.133643, 0.121373],
[0.0911345, 0.137742, 0.125049],
[0.0934564, 0.141833, 0.128714],
[0.0957439, 0.145918, 0.132366],
[0.0979976, 0.149996, 0.136008],
[0.100218, 0.154068, 0.13964],
[0.102405, 0.158135, 0.143262],
[0.10456, 0.162198, 0.146875],
[0.106682, 0.166256, 0.150479],
[0.108773, 0.170311, 0.154076],
[0.110831, 0.174362, 0.157664],
[0.112858, 0.17841, 0.161245],
[0.114854, 0.182455, 0.164819],
[0.116819, 0.186499, 0.168387],
[0.118753, 0.190541, 0.171949],
[0.120656, 0.194581, 0.175505],
[0.122528, 0.198621, 0.179055],
[0.12437, 0.20266, 0.182601],
[0.126181, 0.206698, 0.186142],
[0.127962, 0.210736, 0.189678],
[0.129713, 0.214775, 0.19321],
[0.131433, 0.218814, 0.196739],
[0.133122, 0.222854, 0.200264],
[0.134782, 0.226895, 0.203785],
[0.13641, 0.230938, 0.207304],
[0.138009, 0.234982, 0.21082],
[0.139576, 0.239028, 0.214334],
[0.141113, 0.243076, 0.217845],
[0.142619, 0.247126, 0.221354],
[0.144094, 0.251179, 0.224861],
[0.145538, 0.255235, 0.228367],
[0.146951, 0.259294, 0.231872],
[0.148333, 0.263356, 0.235375],
[0.149683, 0.267422, 0.238878],
[0.151001, 0.271491, 0.242379],
[0.152286, 0.275564, 0.24588],
[0.15354, 0.279642, 0.249381],
[0.154761, 0.283723, 0.252882],
[0.155949, 0.287809, 0.256382],
[0.157104, 0.2919, 0.259883],
[0.158225, 0.295995, 0.263384],
[0.159313, 0.300096, 0.266885],
[0.160366, 0.304201, 0.270388],
[0.161384, 0.308312, 0.273891],
[0.162368, 0.312429, 0.277395],
[0.163316, 0.316551, 0.2809],
[0.164228, 0.320679, 0.284406],
[0.165104, 0.324813, 0.287914],
[0.165943, 0.328953, 0.291424],
[0.166745, 0.333099, 0.294935],
[0.167508, 0.337252, 0.298448],
[0.168233, 0.341411, 0.301963],
[0.168919, 0.345578, 0.30548],
[0.169565, 0.349751, 0.309],
[0.170171, 0.353931, 0.312522],
[0.170735, 0.358118, 0.316046],
[0.171258, 0.362313, 0.319574],
[0.171737, 0.366515, 0.323104],
[0.172174, 0.370725, 0.326636],
[0.172566, 0.374943, 0.330172],
[0.172913, 0.379168, 0.333711],
[0.173214, 0.383402, 0.337254],
[0.173468, 0.387644, 0.3408],
[0.173674, 0.391894, 0.344349],
[0.17383, 0.396152, 0.347902],
[0.173937, 0.400419, 0.351459],
[0.173991, 0.404695, 0.355019],
[0.173994, 0.408979, 0.358584],
[0.173942, 0.413273, 0.362152],
[0.173834, 0.417576, 0.365725],
[0.17367, 0.421887, 0.369302],
[0.173448, 0.426209, 0.372884],
[0.173165, 0.430539, 0.37647],
[0.172821, 0.434879, 0.38006],
[0.172413, 0.439229, 0.383656],
[0.17194, 0.443589, 0.387256],
[0.171399, 0.447959, 0.390861],
[0.170788, 0.452338, 0.394471],
[0.170106, 0.456728, 0.398087],
[0.169349, 0.461129, 0.401707],
[0.168515, 0.465539, 0.405333],
[0.167601, 0.469961, 0.408964],
[0.166604, 0.474393, 0.412601],
[0.165521, 0.478835, 0.416244],
[0.164349, 0.483289, 0.419892],
[0.163083, 0.487754, 0.423546],
[0.161719, 0.49223, 0.427206],
[0.160254, 0.496717, 0.430872],
[0.158683, 0.501215, 0.434545],
[0.157, 0.505726, 0.438223],
[0.162061, 0.509546, 0.441892],
[0.173471, 0.512672, 0.44555],
[0.184332, 0.515803, 0.449215],
[0.19473, 0.518939, 0.452887],
[0.204733, 0.522081, 0.456565],
[0.214394, 0.525229, 0.460249],
[0.223757, 0.528383, 0.463941],
[0.232857, 0.531543, 0.467639],
[0.241722, 0.534709, 0.471344],
[0.250379, 0.537882, 0.475056],
[0.258848, 0.541061, 0.478775],
[0.267147, 0.544246, 0.482502],
[0.275292, 0.547438, 0.486236],
[0.283296, 0.550637, 0.489977],
[0.291172, 0.553843, 0.493725],
[0.298929, 0.557056, 0.497481],
[0.306578, 0.560277, 0.501245],
[0.314126, 0.563504, 0.505017],
[0.321581, 0.566739, 0.508796],
[0.32895, 0.569982, 0.512584],
[0.336239, 0.573233, 0.516379],
[0.343453, 0.576491, 0.520183],
[0.350598, 0.579758, 0.523994],
[0.357678, 0.583032, 0.527815],
[0.364697, 0.586315, 0.531643],
[0.371659, 0.589606, 0.53548],
[0.378568, 0.592906, 0.539326],
[0.385426, 0.596214, 0.54318],
[0.392237, 0.599531, 0.547043],
[0.399005, 0.602857, 0.550915],
[0.40573, 0.606192, 0.554796],
[0.412416, 0.609536, 0.558686],
[0.419065, 0.612889, 0.562586],
[0.42568, 0.616252, 0.566494],
[0.432261, 0.619624, 0.570412],
[0.438812, 0.623006, 0.57434],
[0.445333, 0.626397, 0.578276],
[0.451827, 0.629799, 0.582223],
[0.458294, 0.63321, 0.586179],
[0.464737, 0.636632, 0.590146],
[0.471157, 0.640063, 0.594122],
[0.477555, 0.643505, 0.598108],
[0.483932, 0.646958, 0.602104],
[0.49029, 0.650421, 0.606111],
[0.49663, 0.653895, 0.610127],
[0.502952, 0.65738, 0.614155],
[0.509257, 0.660876, 0.618193],
[0.515548, 0.664383, 0.622241],
[0.521824, 0.667901, 0.6263],
[0.528086, 0.671431, 0.63037],
[0.534336, 0.674972, 0.634451],
[0.540574, 0.678524, 0.638543],
[0.5468, 0.682089, 0.642646],
[0.553017, 0.685665, 0.646761],
[0.559223, 0.689254, 0.650886],
[0.565421, 0.692854, 0.655023],
[0.57161, 0.696467, 0.659172],
[0.577792, 0.700092, 0.663332],
[0.583966, 0.70373, 0.667505],
[0.590134, 0.70738, 0.671688],
[0.596295, 0.711043, 0.675884],
[0.602452, 0.714719, 0.680092],
[0.608603, 0.718408, 0.684313],
[0.61475, 0.72211, 0.688545],
[0.620893, 0.725826, 0.69279],
[0.627033, 0.729555, 0.697047],
[0.633169, 0.733298, 0.701317],
[0.639303, 0.737054, 0.7056],
[0.645435, 0.740824, 0.709895],
[0.651565, 0.744608, 0.714204],
[0.657693, 0.748407, 0.718525],
[0.663821, 0.752219, 0.72286],
[0.669948, 0.756047, 0.727208],
[0.676075, 0.759888, 0.73157],
[0.682202, 0.763744, 0.735944],
[0.688329, 0.767616, 0.740333],
[0.694458, 0.771502, 0.744735],
[0.700587, 0.775403, 0.749152],
[0.706718, 0.77932, 0.753582],
[0.712851, 0.783252, 0.758026],
[0.718986, 0.7872, 0.762484],
[0.725123, 0.791163, 0.766957],
[0.731262, 0.795142, 0.771445],
[0.737405, 0.799138, 0.775946],
[0.743551, 0.803149, 0.780463],
[0.7497, 0.807177, 0.784994],
[0.755853, 0.811222, 0.789541],
[0.76201, 0.815283, 0.794102],
[0.768171, 0.819361, 0.798679],
[0.774337, 0.823456, 0.803271],
[0.780507, 0.827568, 0.807878],
[0.786682, 0.831698, 0.812502],
[0.792861, 0.835845, 0.81714],
[0.799047, 0.84001, 0.821795],
[0.805237, 0.844193, 0.826466],
[0.811433, 0.848394, 0.831153],
[0.817635, 0.852613, 0.835856],
[0.823843, 0.85685, 0.840575],
[0.830057, 0.861107, 0.845311],
[0.836277, 0.865382, 0.850064],
[0.842503, 0.869676, 0.854834],
[0.848736, 0.87399, 0.85962],
[0.854976, 0.878323, 0.864424],
[0.861222, 0.882675, 0.869245],
[0.867474, 0.887048, 0.874083],
[0.873734, 0.891441, 0.878939],
[0.88, 0.895854, 0.883813],
[0.886274, 0.900288, 0.888704],
[0.892554, 0.904743, 0.893613],
[0.89884, 0.909219, 0.898541],
[0.905134, 0.913717, 0.903487],
[0.911434, 0.918236, 0.908451],
[0.917741, 0.922778, 0.913434],
[0.924053, 0.927342, 0.918436],
[0.930372, 0.931929, 0.923456],
[0.936697, 0.936539, 0.928496],
[0.943026, 0.941173, 0.933555],
[0.949361, 0.945832, 0.938634],
[0.955699, 0.950515, 0.943732],
[0.96204, 0.955223, 0.94885],
[0.968383, 0.959958, 0.953987],
[0.974726, 0.96472, 0.959145],
[0.981067, 0.96951, 0.964324],
[0.987404, 0.97433, 0.969523],
[0.99373, 0.979182, 0.974742],
[1., 0.98407, 0.979983],
[1., 0.989, 0.985245],
[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()
