from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000344093, 0.000360408, 0.000285794],
[0.00096857, 0.00104331, 0.000776065],
[0.00184798, 0.0020355, 0.00144647],
[0.00295512, 0.00332204, 0.00227285],
[0.00426977, 0.0048946, 0.00323927],
[0.00577528, 0.00674826, 0.00433445],
[0.0074571, 0.00888022, 0.00555011],
[0.00930204, 0.0112891, 0.0068801],
[0.0112979, 0.0139744, 0.00831985],
[0.0134329, 0.0169365, 0.00986609],
[0.0156962, 0.0201764, 0.0115166],
[0.0180769, 0.0236955, 0.0132699],
[0.0205646, 0.0274956, 0.0151255],
[0.0231491, 0.0315788, 0.0170835],
[0.0258203, 0.0359473, 0.0191443],
[0.0285684, 0.0406012, 0.0213093],
[0.0313837, 0.0452925, 0.0235801],
[0.0342566, 0.0499485, 0.0259589],
[0.0371775, 0.0545728, 0.0284482],
[0.0401371, 0.0591688, 0.0310511],
[0.0430321, 0.0637392, 0.033771],
[0.0458264, 0.0682867, 0.0366117],
[0.048526, 0.0728136, 0.0395772],
[0.0511324, 0.0773218, 0.0426009],
[0.0536467, 0.0818131, 0.0456132],
[0.0560698, 0.0862893, 0.0486267],
[0.0584027, 0.0907516, 0.0516446],
[0.0606458, 0.0952015, 0.0546699],
[0.0627999, 0.09964, 0.0577055],
[0.0648652, 0.104068, 0.0607539],
[0.0668422, 0.108487, 0.0638177],
[0.0687311, 0.112898, 0.0668994],
[0.070532, 0.1173, 0.0700012],
[0.0722451, 0.121696, 0.0731252],
[0.0738704, 0.126085, 0.0762736],
[0.0754078, 0.130468, 0.0794482],
[0.0768574, 0.134846, 0.082651],
[0.0782189, 0.139219, 0.0858836],
[0.0794923, 0.143587, 0.0891479],
[0.0806773, 0.14795, 0.0924453],
[0.0817737, 0.15231, 0.0957774],
[0.0827813, 0.156665, 0.0991456],
[0.0836997, 0.161017, 0.102551],
[0.0845288, 0.165365, 0.105996],
[0.0852682, 0.16971, 0.10948],
[0.0859175, 0.174052, 0.113006],
[0.0864765, 0.17839, 0.116574],
[0.0869448, 0.182724, 0.120185],
[0.087322, 0.187056, 0.12384],
[0.0876079, 0.191384, 0.127541],
[0.087802, 0.195708, 0.131287],
[0.0879041, 0.200029, 0.13508],
[0.0879138, 0.204346, 0.138921],
[0.0878309, 0.20866, 0.14281],
[0.0876551, 0.212969, 0.146747],
[0.087386, 0.217275, 0.150734],
[0.0870236, 0.221576, 0.15477],
[0.0865676, 0.225872, 0.158856],
[0.086018, 0.230164, 0.162993],
[0.0853746, 0.23445, 0.167181],
[0.0846375, 0.238731, 0.17142],
[0.0838067, 0.243007, 0.17571],
[0.0828824, 0.247277, 0.180052],
[0.081865, 0.251541, 0.184446],
[0.0807547, 0.255798, 0.18889],
[0.0795522, 0.260048, 0.193387],
[0.0782582, 0.264292, 0.197935],
[0.0768736, 0.268528, 0.202535],
[0.0753996, 0.272756, 0.207186],
[0.0738375, 0.276976, 0.211887],
[0.0721891, 0.281188, 0.21664],
[0.0704565, 0.28539, 0.221443],
[0.0686422, 0.289584, 0.226297],
[0.0667492, 0.293768, 0.2312],
[0.064781, 0.297941, 0.236152],
[0.0627421, 0.302105, 0.241153],
[0.0606375, 0.306258, 0.246202],
[0.0584733, 0.310399, 0.251299],
[0.0562566, 0.314529, 0.256442],
[0.0539961, 0.318647, 0.261632],
[0.0517017, 0.322753, 0.266867],
[0.0493854, 0.326847, 0.272146],
[0.0470613, 0.330927, 0.27747],
[0.0447459, 0.334994, 0.282836],
[0.0424585, 0.339047, 0.288243],
[0.0402181, 0.343086, 0.293692],
[0.0380629, 0.34711, 0.29918],
[0.0360779, 0.35112, 0.304707],
[0.034284, 0.355114, 0.310272],
[0.0327026, 0.359093, 0.315873],
[0.0313559, 0.363056, 0.321509],
[0.0302663, 0.367003, 0.327179],
[0.0294571, 0.370933, 0.332881],
[0.0289517, 0.374847, 0.338615],
[0.0287742, 0.378744, 0.344379],
[0.028949, 0.382623, 0.350171],
[0.029501, 0.386485, 0.35599],
[0.0304553, 0.390329, 0.361834],
[0.0318377, 0.394155, 0.367702],
[0.033674, 0.397963, 0.373593],
[0.0359904, 0.401752, 0.379505],
[0.0388134, 0.405523, 0.385436],
[0.0421204, 0.409275, 0.391384],
[0.0457819, 0.413008, 0.397348],
[0.0497746, 0.416722, 0.403327],
[0.054068, 0.420417, 0.409318],
[0.058633, 0.424093, 0.41532],
[0.0634428, 0.427749, 0.421331],
[0.0684728, 0.431387, 0.427349],
[0.0737011, 0.435005, 0.433373],
[0.0791082, 0.438603, 0.4394],
[0.0846768, 0.442183, 0.44543],
[0.0903918, 0.445743, 0.451459],
[0.0962398, 0.449284, 0.457487],
[0.102209, 0.452806, 0.463511],
[0.108289, 0.456309, 0.46953],
[0.11447, 0.459793, 0.475542],
[0.120746, 0.463258, 0.481545],
[0.127107, 0.466705, 0.487537],
[0.133548, 0.470134, 0.493517],
[0.140064, 0.473545, 0.499482],
[0.146648, 0.476937, 0.505431],
[0.153297, 0.480313, 0.511362],
[0.160006, 0.483671, 0.517274],
[0.16677, 0.487012, 0.523164],
[0.173587, 0.490337, 0.529032],
[0.180453, 0.493645, 0.534874],
[0.187365, 0.496938, 0.54069],
[0.194321, 0.500216, 0.546478],
[0.201317, 0.503478, 0.552236],
[0.20835, 0.506726, 0.557963],
[0.215419, 0.50996, 0.563658],
[0.222521, 0.51318, 0.569318],
[0.229655, 0.516388, 0.574942],
[0.236817, 0.519582, 0.580529],
[0.244006, 0.522765, 0.586078],
[0.251221, 0.525937, 0.591586],
[0.258458, 0.529098, 0.597054],
[0.265717, 0.532248, 0.602478],
[0.272996, 0.535389, 0.60786],
[0.280293, 0.538521, 0.613196],
[0.287606, 0.541645, 0.618486],
[0.294934, 0.544761, 0.62373],
[0.302276, 0.54787, 0.628925],
[0.30963, 0.550973, 0.634071],
[0.316994, 0.55407, 0.639168],
[0.324367, 0.557162, 0.644214],
[0.331747, 0.56025, 0.649208],
[0.339135, 0.563334, 0.65415],
[0.346527, 0.566416, 0.659038],
[0.353923, 0.569496, 0.663874],
[0.361321, 0.572574, 0.668655],
[0.368721, 0.575652, 0.673381],
[0.37612, 0.578731, 0.678053],
[0.383519, 0.58181, 0.682669],
[0.390916, 0.584891, 0.687229],
[0.398309, 0.587974, 0.691733],
[0.405698, 0.591061, 0.696181],
[0.413081, 0.594151, 0.700572],
[0.420457, 0.597246, 0.704906],
[0.427827, 0.600347, 0.709185],
[0.435187, 0.603455, 0.713406],
[0.442538, 0.606569, 0.717571],
[0.449879, 0.609691, 0.72168],
[0.457208, 0.612821, 0.725732],
[0.464525, 0.615961, 0.729729],
[0.471829, 0.619111, 0.73367],
[0.479119, 0.622272, 0.737555],
[0.486394, 0.625444, 0.741386],
[0.493653, 0.628628, 0.745162],
[0.500896, 0.631825, 0.748885],
[0.508122, 0.635036, 0.752554],
[0.515329, 0.638261, 0.75617],
[0.522518, 0.641501, 0.759734],
[0.529688, 0.644757, 0.763247],
[0.536837, 0.648029, 0.766709],
[0.543966, 0.651318, 0.770121],
[0.551074, 0.654625, 0.773485],
[0.558159, 0.65795, 0.7768],
[0.565222, 0.661294, 0.780068],
[0.572262, 0.664658, 0.783289],
[0.579278, 0.668042, 0.786466],
[0.586269, 0.671446, 0.789598],
[0.593236, 0.674872, 0.792687],
[0.600178, 0.67832, 0.795734],
[0.607093, 0.68179, 0.79874],
[0.613983, 0.685283, 0.801706],
[0.620846, 0.6888, 0.804634],
[0.627681, 0.69234, 0.807524],
[0.634489, 0.695905, 0.810378],
[0.641269, 0.699496, 0.813197],
[0.648021, 0.703112, 0.815983],
[0.654744, 0.706753, 0.818737],
[0.661439, 0.710422, 0.821459],
[0.668103, 0.714117, 0.824153],
[0.674739, 0.717839, 0.826818],
[0.681344, 0.721589, 0.829456],
[0.687919, 0.725368, 0.83207],
[0.694464, 0.729175, 0.834659],
[0.700977, 0.73301, 0.837226],
[0.70746, 0.736875, 0.839772],
[0.713912, 0.74077, 0.842299],
[0.720333, 0.744695, 0.844808],
[0.726722, 0.74865, 0.847301],
[0.733079, 0.752635, 0.849778],
[0.739405, 0.756652, 0.852243],
[0.745699, 0.760699, 0.854695],
[0.75196, 0.764778, 0.857138],
[0.75819, 0.768889, 0.859571],
[0.764387, 0.773032, 0.861998],
[0.770552, 0.777207, 0.864419],
[0.776685, 0.781414, 0.866836],
[0.782786, 0.785654, 0.86925],
[0.788854, 0.789927, 0.871664],
[0.794889, 0.794233, 0.874078],
[0.800893, 0.798572, 0.876494],
[0.806864, 0.802945, 0.878915],
[0.812803, 0.807351, 0.881341],
[0.818709, 0.811791, 0.883774],
[0.824584, 0.816264, 0.886216],
[0.830426, 0.820772, 0.888668],
[0.836237, 0.825314, 0.891131],
[0.842016, 0.829889, 0.893608],
[0.847763, 0.834499, 0.896101],
[0.853479, 0.839143, 0.898609],
[0.859163, 0.843822, 0.901136],
[0.864817, 0.848535, 0.903683],
[0.870439, 0.853282, 0.906251],
[0.876031, 0.858064, 0.908842],
[0.881593, 0.862881, 0.911458],
[0.887125, 0.867731, 0.9141],
[0.892627, 0.872617, 0.91677],
[0.8981, 0.877536, 0.919469],
[0.903544, 0.88249, 0.922199],
[0.908959, 0.887478, 0.924962],
[0.914347, 0.892501, 0.927759],
[0.919706, 0.897557, 0.930593],
[0.925039, 0.902648, 0.933464],
[0.930345, 0.907772, 0.936375],
[0.935625, 0.91293, 0.939328],
[0.94088, 0.918122, 0.942323],
[0.94611, 0.923346, 0.945364],
[0.951317, 0.928604, 0.948452],
[0.9565, 0.933894, 0.95159],
[0.961662, 0.939217, 0.954779],
[0.966802, 0.944571, 0.958022],
[0.971923, 0.949957, 0.961322],
[0.977026, 0.955373, 0.964683],
[0.982111, 0.960819, 0.968107],
[0.987183, 0.966295, 0.9716],
[0.992242, 0.971797, 0.975167],
[0.997292, 0.977325, 0.978817],
[1., 0.982876, 0.982563],
[1., 0.988442, 0.986431],
[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()
