from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000319509, 0.000357979, 0.000401326],
[0.000877123, 0.00103505, 0.0011988],
[0.00164112, 0.00201817, 0.00239038],
[0.00257879, 0.00329268, 0.00397041],
[0.00366505, 0.00485064, 0.0059381],
[0.00487878, 0.00668764, 0.00829474],
[0.00620129, 0.00880144, 0.0110426],
[0.00761547, 0.0111913, 0.0141843],
[0.00910529, 0.0138577, 0.0177227],
[0.0106556, 0.0168018, 0.0216604],
[0.0122516, 0.0200255, 0.0259999],
[0.0138794, 0.0235313, 0.0307431],
[0.0155249, 0.0273222, 0.0358919],
[0.0171749, 0.0314014, 0.0414236],
[0.018816, 0.0357728, 0.0469779],
[0.0204352, 0.0404403, 0.0524781],
[0.0220197, 0.0451611, 0.057927],
[0.0235568, 0.0498526, 0.0633265],
[0.0250342, 0.0545188, 0.0686784],
[0.0264396, 0.0591632, 0.0739838],
[0.0277609, 0.063789, 0.0792435],
[0.0289862, 0.0683989, 0.0844581],
[0.0301037, 0.0729953, 0.0896278],
[0.0311021, 0.0775804, 0.0947526],
[0.0319701, 0.0821562, 0.0998324],
[0.0326967, 0.0867244, 0.104867],
[0.033271, 0.0912866, 0.109856],
[0.0336827, 0.0958443, 0.114798],
[0.0339216, 0.100399, 0.119693],
[0.0339778, 0.104951, 0.124541],
[0.0338418, 0.109502, 0.12934],
[0.0335044, 0.114053, 0.134089],
[0.0329569, 0.118604, 0.138787],
[0.0321911, 0.123157, 0.143434],
[0.0311988, 0.127711, 0.148028],
[0.0299729, 0.132268, 0.152569],
[0.0285062, 0.136828, 0.157054],
[0.0267924, 0.141391, 0.161482],
[0.0248255, 0.145957, 0.165854],
[0.0226004, 0.150528, 0.170166],
[0.0201122, 0.155102, 0.174419],
[0.0173569, 0.159681, 0.178611],
[0.014331, 0.164264, 0.18274],
[0.0110318, 0.168851, 0.186805],
[0.00745709, 0.173442, 0.190806],
[0.00360558, 0.178037, 0.194741],
[0., 0.182636, 0.198609],
[0., 0.187239, 0.202408],
[0., 0.191846, 0.206138],
[0., 0.196456, 0.209797],
[0., 0.201069, 0.213385],
[0., 0.205685, 0.2169],
[0., 0.210304, 0.220342],
[0., 0.214924, 0.223709],
[0., 0.219546, 0.227001],
[0., 0.224169, 0.230216],
[0., 0.228793, 0.233354],
[0., 0.233417, 0.236415],
[0., 0.238041, 0.239397],
[0., 0.242664, 0.242299],
[0., 0.247285, 0.245122],
[0., 0.251905, 0.247865],
[0., 0.256522, 0.250528],
[0., 0.261135, 0.253109],
[0., 0.265745, 0.255608],
[0., 0.27035, 0.258026],
[0., 0.27495, 0.260363],
[0., 0.279544, 0.262617],
[0., 0.284132, 0.264789],
[0., 0.288713, 0.266879],
[0., 0.293285, 0.268888],
[0., 0.29785, 0.270814],
[0., 0.302404, 0.27266],
[0., 0.306949, 0.274424],
[0., 0.311484, 0.276107],
[0., 0.316007, 0.27771],
[0., 0.320518, 0.279233],
[0., 0.325016, 0.280676],
[0., 0.329501, 0.282042],
[0., 0.333972, 0.283329],
[0., 0.338428, 0.28454],
[0., 0.342869, 0.285674],
[0., 0.347294, 0.286733],
[0., 0.351702, 0.287718],
[0., 0.356093, 0.288631],
[0., 0.360466, 0.289471],
[0., 0.36482, 0.290241],
[0., 0.369156, 0.290941],
[0., 0.373472, 0.291574],
[0., 0.377768, 0.29214],
[0., 0.382043, 0.292641],
[0., 0.386296, 0.293079],
[0., 0.390529, 0.293456],
[0., 0.394738, 0.293772],
[0., 0.398926, 0.29403],
[0., 0.40309, 0.294231],
[0., 0.40723, 0.294378],
[0., 0.411347, 0.294472],
[0., 0.41544, 0.294516],
[0., 0.419508, 0.294511],
[0., 0.42355, 0.29446],
[0., 0.427568, 0.294364],
[0., 0.43156, 0.294226],
[0., 0.435526, 0.294049],
[0., 0.439467, 0.293834],
[0., 0.44338, 0.293583],
[0., 0.447268, 0.293301],
[0., 0.451129, 0.292988],
[0., 0.454963, 0.292647],
[0., 0.45877, 0.292281],
[0., 0.46255, 0.291893],
[0., 0.466304, 0.291485],
[0., 0.47003, 0.29106],
[0., 0.473729, 0.290621],
[0., 0.4774, 0.29017],
[0., 0.481045, 0.28971],
[0., 0.484663, 0.289245],
[0., 0.488254, 0.288777],
[0., 0.491817, 0.288309],
[0., 0.495355, 0.287844],
[0., 0.498865, 0.287386],
[0.0163629, 0.502349, 0.286937],
[0.0465355, 0.505807, 0.2865],
[0.0711686, 0.509238, 0.28608],
[0.0912788, 0.512644, 0.285678],
[0.108849, 0.516025, 0.285298],
[0.124766, 0.51938, 0.284943],
[0.139511, 0.52271, 0.284617],
[0.153381, 0.526015, 0.284324],
[0.166569, 0.529296, 0.284065],
[0.179211, 0.532553, 0.283846],
[0.191405, 0.535786, 0.283668],
[0.203224, 0.538997, 0.283536],
[0.214727, 0.542184, 0.283453],
[0.225956, 0.545349, 0.283422],
[0.236949, 0.548493, 0.283446],
[0.247733, 0.551615, 0.28353],
[0.258332, 0.554716, 0.283677],
[0.268766, 0.557797, 0.283889],
[0.279052, 0.560858, 0.28417],
[0.289203, 0.5639, 0.284525],
[0.299232, 0.566923, 0.284955],
[0.309147, 0.569928, 0.285464],
[0.318959, 0.572916, 0.286055],
[0.328673, 0.575886, 0.286732],
[0.338297, 0.578841, 0.287498],
[0.347837, 0.58178, 0.288356],
[0.357296, 0.584705, 0.289308],
[0.36668, 0.587615, 0.290358],
[0.375991, 0.590512, 0.291509],
[0.385233, 0.593397, 0.292762],
[0.394409, 0.596269, 0.294122],
[0.403522, 0.59913, 0.29559],
[0.412572, 0.601981, 0.29717],
[0.421563, 0.604823, 0.298862],
[0.430495, 0.607656, 0.300671],
[0.43937, 0.61048, 0.302597],
[0.448189, 0.613298, 0.304642],
[0.456953, 0.61611, 0.30681],
[0.465663, 0.618916, 0.309101],
[0.474319, 0.621718, 0.311517],
[0.482922, 0.624516, 0.31406],
[0.491472, 0.627311, 0.31673],
[0.49997, 0.630105, 0.31953],
[0.508415, 0.632898, 0.322461],
[0.516808, 0.635691, 0.325523],
[0.525149, 0.638485, 0.328718],
[0.533438, 0.641281, 0.332045],
[0.541674, 0.64408, 0.335507],
[0.549858, 0.646883, 0.339103],
[0.557989, 0.649691, 0.342833],
[0.566067, 0.652505, 0.346699],
[0.574091, 0.655326, 0.3507],
[0.582062, 0.658155, 0.354837],
[0.589978, 0.660993, 0.359109],
[0.597839, 0.66384, 0.363516],
[0.605646, 0.666699, 0.368058],
[0.613396, 0.66957, 0.372735],
[0.62109, 0.672454, 0.377546],
[0.628727, 0.675352, 0.382491],
[0.636307, 0.678266, 0.387568],
[0.643828, 0.681195, 0.392779],
[0.651291, 0.684142, 0.398121],
[0.658695, 0.687107, 0.403594],
[0.666038, 0.690092, 0.409197],
[0.67332, 0.693097, 0.414929],
[0.680541, 0.696123, 0.420788],
[0.6877, 0.699172, 0.426774],
[0.694796, 0.702244, 0.432886],
[0.701829, 0.705341, 0.439122],
[0.708797, 0.708463, 0.44548],
[0.715701, 0.711612, 0.451959],
[0.722538, 0.714789, 0.458559],
[0.72931, 0.717994, 0.465276],
[0.736015, 0.721229, 0.47211],
[0.742651, 0.724494, 0.479058],
[0.74922, 0.727791, 0.48612],
[0.75572, 0.731121, 0.493292],
[0.76215, 0.734484, 0.500574],
[0.76851, 0.737881, 0.507962],
[0.774799, 0.741314, 0.515455],
[0.781016, 0.744783, 0.523052],
[0.787162, 0.748289, 0.530748],
[0.793235, 0.751833, 0.538543],
[0.799235, 0.755416, 0.546434],
[0.805162, 0.759039, 0.554418],
[0.811014, 0.762702, 0.562493],
[0.816793, 0.766407, 0.570656],
[0.822496, 0.770153, 0.578905],
[0.828125, 0.773943, 0.587237],
[0.833678, 0.777776, 0.595648],
[0.839155, 0.781653, 0.604137],
[0.844557, 0.785575, 0.612701],
[0.849882, 0.789543, 0.621335],
[0.855132, 0.793557, 0.630038],
[0.860305, 0.797617, 0.638806],
[0.865401, 0.801725, 0.647635],
[0.870422, 0.805881, 0.656523],
[0.875367, 0.810085, 0.665466],
[0.880235, 0.814338, 0.674461],
[0.885028, 0.81864, 0.683505],
[0.889745, 0.822991, 0.692593],
[0.894388, 0.827393, 0.701722],
[0.898956, 0.831844, 0.71089],
[0.90345, 0.836347, 0.720091],
[0.90787, 0.8409, 0.729322],
[0.912218, 0.845504, 0.73858],
[0.916494, 0.850159, 0.74786],
[0.920699, 0.854865, 0.757159],
[0.924834, 0.859623, 0.766474],
[0.9289, 0.864431, 0.775799],
[0.932899, 0.869291, 0.78513],
[0.936831, 0.874202, 0.794465],
[0.940699, 0.879165, 0.803799],
[0.944504, 0.884178, 0.813127],
[0.948247, 0.889241, 0.822446],
[0.951931, 0.894355, 0.831751],
[0.955558, 0.899519, 0.841038],
[0.959129, 0.904733, 0.850303],
[0.962649, 0.909995, 0.859541],
[0.966118, 0.915306, 0.868748],
[0.969541, 0.920665, 0.877919],
[0.97292, 0.92607, 0.887049],
[0.97626, 0.931522, 0.896133],
[0.979563, 0.93702, 0.905166],
[0.982836, 0.942561, 0.914142],
[0.986082, 0.948145, 0.923055],
[0.989309, 0.95377, 0.931899],
[0.992523, 0.959435, 0.940664],
[0.995732, 0.965137, 0.949342],
[0.998949, 0.970873, 0.95792],
[1., 0.976639, 0.966381],
[1., 0.982429, 0.974699],
[1., 0.988232, 0.98282],
[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()
