from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.00034227, 0.000352189, 0.00037072],
[0.000963799, 0.00101273, 0.00108416],
[0.00184207, 0.00196574, 0.00213027],
[0.00295346, 0.0031936, 0.00349674],
[0.00428183, 0.00468534, 0.00517737],
[0.00581503, 0.00643341, 0.00716899],
[0.00754337, 0.00843235, 0.0094703],
[0.00945882, 0.0106781, 0.0120812],
[0.0115545, 0.0131675, 0.0150024],
[0.0138246, 0.0158983, 0.0182354],
[0.0162637, 0.0188686, 0.0217819],
[0.0188672, 0.0220772, 0.0256443],
[0.0216308, 0.025523, 0.0298251],
[0.0245506, 0.0292053, 0.0343272],
[0.027623, 0.0331238, 0.0391537],
[0.0308449, 0.0372783, 0.0441426],
[0.0342129, 0.0416378, 0.0490833],
[0.0377244, 0.0459717, 0.0539896],
[0.0413549, 0.0502626, 0.0588652],
[0.0449387, 0.0545139, 0.0637132],
[0.0484703, 0.0587287, 0.0685367],
[0.0519526, 0.0629098, 0.0733381],
[0.0553882, 0.0670595, 0.0781197],
[0.0587794, 0.0711801, 0.0828836],
[0.0621284, 0.0752735, 0.0876318],
[0.0654373, 0.0793417, 0.0923659],
[0.0687076, 0.0833863, 0.0970876],
[0.0719411, 0.0874087, 0.101798],
[0.0751394, 0.0914105, 0.106499],
[0.0783036, 0.0953929, 0.111192],
[0.0814352, 0.0993572, 0.115877],
[0.0845353, 0.103304, 0.120556],
[0.087605, 0.107236, 0.125229],
[0.0906453, 0.111152, 0.129899],
[0.0936571, 0.115054, 0.134564],
[0.0966414, 0.118943, 0.139228],
[0.0995989, 0.122819, 0.143889],
[0.10253, 0.126684, 0.148549],
[0.105437, 0.130537, 0.153209],
[0.108318, 0.134381, 0.157869],
[0.111176, 0.138214, 0.16253],
[0.11401, 0.142039, 0.167192],
[0.116822, 0.145855, 0.171856],
[0.119611, 0.149663, 0.176523],
[0.122378, 0.153463, 0.181193],
[0.125125, 0.157257, 0.185867],
[0.12785, 0.161044, 0.190544],
[0.130554, 0.164825, 0.195226],
[0.133239, 0.168601, 0.199912],
[0.135904, 0.172371, 0.204604],
[0.13855, 0.176136, 0.209302],
[0.141176, 0.179898, 0.214006],
[0.143784, 0.183654, 0.218716],
[0.146373, 0.187408, 0.223434],
[0.148945, 0.191158, 0.228158],
[0.151498, 0.194904, 0.23289],
[0.154034, 0.198648, 0.23763],
[0.156552, 0.20239, 0.242378],
[0.159054, 0.206129, 0.247134],
[0.161538, 0.209867, 0.2519],
[0.164005, 0.213603, 0.256674],
[0.166456, 0.217337, 0.261458],
[0.168891, 0.221071, 0.266252],
[0.171309, 0.224803, 0.271055],
[0.173712, 0.228535, 0.275869],
[0.176098, 0.232267, 0.280693],
[0.178469, 0.235998, 0.285529],
[0.180824, 0.23973, 0.290375],
[0.183163, 0.243462, 0.295232],
[0.185488, 0.247194, 0.300101],
[0.187796, 0.250927, 0.304982],
[0.19009, 0.254661, 0.309875],
[0.192369, 0.258396, 0.314779],
[0.194633, 0.262132, 0.319697],
[0.196881, 0.26587, 0.324627],
[0.199115, 0.269609, 0.32957],
[0.201334, 0.27335, 0.334526],
[0.203539, 0.277094, 0.339496],
[0.205728, 0.280839, 0.344479],
[0.207904, 0.284587, 0.349476],
[0.210064, 0.288337, 0.354487],
[0.21221, 0.29209, 0.359513],
[0.214342, 0.295845, 0.364552],
[0.216459, 0.299604, 0.369607],
[0.218562, 0.303365, 0.374676],
[0.22065, 0.30713, 0.37976],
[0.222724, 0.310899, 0.384859],
[0.224784, 0.31467, 0.389974],
[0.226829, 0.318446, 0.395105],
[0.22886, 0.322225, 0.400251],
[0.230877, 0.326009, 0.405413],
[0.232879, 0.329796, 0.410592],
[0.234866, 0.333588, 0.415787],
[0.23684, 0.337384, 0.420998],
[0.238798, 0.341184, 0.426227],
[0.240743, 0.344989, 0.431472],
[0.242673, 0.348799, 0.436734],
[0.244588, 0.352614, 0.442014],
[0.246489, 0.356434, 0.447312],
[0.248375, 0.360259, 0.452627],
[0.250247, 0.364089, 0.45796],
[0.252104, 0.367924, 0.463311],
[0.253946, 0.371765, 0.46868],
[0.255773, 0.375611, 0.474068],
[0.257586, 0.379463, 0.479474],
[0.259383, 0.383321, 0.4849],
[0.261166, 0.387185, 0.490344],
[0.262933, 0.391055, 0.495807],
[0.264685, 0.394931, 0.50129],
[0.266422, 0.398813, 0.506793],
[0.268144, 0.402702, 0.512315],
[0.26985, 0.406597, 0.517857],
[0.271541, 0.410499, 0.523419],
[0.273216, 0.414407, 0.529002],
[0.274876, 0.418322, 0.534605],
[0.276519, 0.422244, 0.540228],
[0.278147, 0.426173, 0.545873],
[0.279759, 0.43011, 0.551538],
[0.281354, 0.434053, 0.557225],
[0.282934, 0.438004, 0.562933],
[0.284496, 0.441962, 0.568663],
[0.286043, 0.445927, 0.574414],
[0.287572, 0.449901, 0.580187],
[0.289085, 0.453882, 0.585983],
[0.290581, 0.45787, 0.591801],
[0.292059, 0.461867, 0.597641],
[0.293521, 0.465872, 0.603504],
[0.297327, 0.469617, 0.607396],
[0.303454, 0.473099, 0.609312],
[0.309533, 0.476587, 0.611244],
[0.315568, 0.480079, 0.613192],
[0.321561, 0.483576, 0.615157],
[0.327515, 0.487078, 0.617137],
[0.333432, 0.490585, 0.619134],
[0.339315, 0.494098, 0.621147],
[0.345165, 0.497616, 0.623175],
[0.350984, 0.50114, 0.625219],
[0.356775, 0.50467, 0.62728],
[0.362539, 0.508206, 0.629355],
[0.368277, 0.511748, 0.631447],
[0.373991, 0.515297, 0.633554],
[0.379682, 0.518852, 0.635678],
[0.385352, 0.522413, 0.637816],
[0.391002, 0.525982, 0.639971],
[0.396633, 0.529557, 0.642141],
[0.402246, 0.533139, 0.644327],
[0.407842, 0.536728, 0.646528],
[0.413423, 0.540325, 0.648745],
[0.418988, 0.543929, 0.650978],
[0.42454, 0.547541, 0.653226],
[0.430078, 0.55116, 0.65549],
[0.435604, 0.554787, 0.657769],
[0.441119, 0.558422, 0.660064],
[0.446622, 0.562065, 0.662375],
[0.452116, 0.565717, 0.664702],
[0.457601, 0.569376, 0.667044],
[0.463076, 0.573044, 0.669402],
[0.468544, 0.576721, 0.671776],
[0.474004, 0.580406, 0.674165],
[0.479457, 0.5841, 0.676571],
[0.484903, 0.587803, 0.678992],
[0.490344, 0.591515, 0.681429],
[0.495779, 0.595237, 0.683882],
[0.50121, 0.598967, 0.686351],
[0.506636, 0.602707, 0.688836],
[0.512059, 0.606457, 0.691337],
[0.517478, 0.610216, 0.693854],
[0.522894, 0.613985, 0.696387],
[0.528307, 0.617764, 0.698937],
[0.533718, 0.621553, 0.701503],
[0.539128, 0.625352, 0.704084],
[0.544535, 0.629161, 0.706683],
[0.549942, 0.632981, 0.709297],
[0.555349, 0.636811, 0.711929],
[0.560755, 0.640652, 0.714576],
[0.566161, 0.644503, 0.717241],
[0.571567, 0.648366, 0.719922],
[0.576974, 0.652239, 0.722619],
[0.582382, 0.656124, 0.725334],
[0.587791, 0.660019, 0.728065],
[0.593202, 0.663926, 0.730813],
[0.598615, 0.667845, 0.733578],
[0.60403, 0.671775, 0.736361],
[0.609447, 0.675717, 0.73916],
[0.614867, 0.67967, 0.741977],
[0.62029, 0.683636, 0.744811],
[0.625717, 0.687614, 0.747663],
[0.631147, 0.691603, 0.750531],
[0.63658, 0.695606, 0.753418],
[0.642018, 0.69962, 0.756322],
[0.64746, 0.703647, 0.759244],
[0.652907, 0.707687, 0.762184],
[0.658358, 0.71174, 0.765142],
[0.663814, 0.715805, 0.768118],
[0.669275, 0.719884, 0.771112],
[0.674742, 0.723976, 0.774124],
[0.680215, 0.728081, 0.777155],
[0.685693, 0.732199, 0.780204],
[0.691177, 0.736331, 0.783272],
[0.696668, 0.740477, 0.786359],
[0.702165, 0.744637, 0.789464],
[0.707669, 0.74881, 0.792588],
[0.713179, 0.752998, 0.795731],
[0.718697, 0.7572, 0.798894],
[0.724222, 0.761416, 0.802076],
[0.729755, 0.765647, 0.805277],
[0.735295, 0.769892, 0.808498],
[0.740842, 0.774152, 0.811738],
[0.746398, 0.778427, 0.814998],
[0.751962, 0.782717, 0.818279],
[0.757534, 0.787022, 0.821579],
[0.763115, 0.791343, 0.8249],
[0.768705, 0.795678, 0.828241],
[0.774303, 0.80003, 0.831602],
[0.779911, 0.804397, 0.834985],
[0.785527, 0.80878, 0.838388],
[0.791153, 0.813179, 0.841812],
[0.796788, 0.817595, 0.845258],
[0.802433, 0.822026, 0.848725],
[0.808088, 0.826474, 0.852213],
[0.813753, 0.830939, 0.855724],
[0.819428, 0.83542, 0.859256],
[0.825113, 0.839919, 0.86281],
[0.830808, 0.844434, 0.866387],
[0.836514, 0.848967, 0.869987],
[0.84223, 0.853517, 0.873609],
[0.847957, 0.858085, 0.877254],
[0.853695, 0.86267, 0.880923],
[0.859443, 0.867274, 0.884615],
[0.865203, 0.871895, 0.888331],
[0.870974, 0.876535, 0.892071],
[0.876756, 0.881193, 0.895835],
[0.882549, 0.88587, 0.899624],
[0.888353, 0.890566, 0.903438],
[0.894169, 0.895281, 0.907277],
[0.899996, 0.900015, 0.911142],
[0.905835, 0.904768, 0.915033],
[0.911684, 0.909541, 0.918951],
[0.917546, 0.914334, 0.922895],
[0.923418, 0.919147, 0.926867],
[0.929302, 0.92398, 0.930867],
[0.935197, 0.928834, 0.934895],
[0.941102, 0.933709, 0.938952],
[0.947019, 0.938605, 0.94304],
[0.952945, 0.943522, 0.947158],
[0.958882, 0.948461, 0.951308],
[0.964828, 0.953422, 0.955491],
[0.970782, 0.958406, 0.959709],
[0.976744, 0.963412, 0.963962],
[0.982713, 0.968443, 0.968254],
[0.988686, 0.973497, 0.972587],
[0.99466, 0.978578, 0.976967],
[1., 0.983685, 0.981399],
[1., 0.988822, 0.9859],
[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()
