from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000336603, 0.000359101, 0.000325893],
[0.000943194, 0.00103815, 0.000918412],
[0.00179624, 0.00202277, 0.00175667],
[0.00287123, 0.00329672, 0.00281868],
[0.00415128, 0.0048502, 0.00408961],
[0.00562357, 0.00667676, 0.00555839],
[0.00727782, 0.00877193, 0.00721629],
[0.00910543, 0.0111326, 0.00905615],
[0.0110991, 0.0137565, 0.011072],
[0.0132523, 0.0166422, 0.0132586],
[0.0155594, 0.0197888, 0.0156115],
[0.0180153, 0.0231957, 0.0181268],
[0.0206153, 0.0268626, 0.0208008],
[0.0233551, 0.0307899, 0.0236305],
[0.0262309, 0.0349776, 0.0266129],
[0.0292388, 0.0394266, 0.0297455],
[0.0323754, 0.0439834, 0.0330258],
[0.0356376, 0.0484865, 0.0364516],
[0.0390223, 0.0529494, 0.0400209],
[0.0424618, 0.0573754, 0.0436034],
[0.0458374, 0.0617675, 0.0471322],
[0.0491611, 0.0661284, 0.0506161],
[0.0524357, 0.0704605, 0.0540576],
[0.0556635, 0.0747659, 0.0574593],
[0.0588467, 0.0790466, 0.060823],
[0.0619873, 0.0833045, 0.064151],
[0.0650871, 0.087541, 0.0674448],
[0.0681478, 0.0917579, 0.0707062],
[0.0711709, 0.0959563, 0.0739366],
[0.0741577, 0.100138, 0.0771375],
[0.0771096, 0.104303, 0.0803101],
[0.0800278, 0.108454, 0.0834557],
[0.0829133, 0.112591, 0.0865752],
[0.0857672, 0.116715, 0.0896699],
[0.0885904, 0.120827, 0.0927406],
[0.0913839, 0.124928, 0.0957883],
[0.0941484, 0.129018, 0.0988137],
[0.0968847, 0.133099, 0.101818],
[0.0995936, 0.137171, 0.104801],
[0.102276, 0.141235, 0.107765],
[0.104932, 0.145292, 0.110709],
[0.107562, 0.149341, 0.113634],
[0.110168, 0.153384, 0.116542],
[0.112749, 0.157421, 0.119432],
[0.115306, 0.161452, 0.122305],
[0.117839, 0.165479, 0.125162],
[0.12035, 0.169501, 0.128003],
[0.122837, 0.173519, 0.130828],
[0.125303, 0.177534, 0.133638],
[0.127747, 0.181545, 0.136434],
[0.130169, 0.185554, 0.139215],
[0.13257, 0.18956, 0.141983],
[0.13495, 0.193564, 0.144737],
[0.13731, 0.197566, 0.147478],
[0.139649, 0.201567, 0.150206],
[0.141968, 0.205567, 0.152922],
[0.144267, 0.209566, 0.155626],
[0.146547, 0.213564, 0.158318],
[0.148807, 0.217563, 0.160998],
[0.151049, 0.221561, 0.163667],
[0.153271, 0.22556, 0.166325],
[0.155474, 0.22956, 0.168973],
[0.157659, 0.23356, 0.17161],
[0.159825, 0.237562, 0.174236],
[0.161973, 0.241565, 0.176853],
[0.164103, 0.245569, 0.179459],
[0.166214, 0.249576, 0.182057],
[0.168308, 0.253584, 0.184644],
[0.170384, 0.257595, 0.187223],
[0.172442, 0.261608, 0.189792],
[0.174483, 0.265624, 0.192353],
[0.176506, 0.269643, 0.194905],
[0.178511, 0.273664, 0.197449],
[0.1805, 0.27769, 0.199984],
[0.18247, 0.281718, 0.202511],
[0.184424, 0.28575, 0.205031],
[0.18636, 0.289786, 0.207542],
[0.18828, 0.293827, 0.210046],
[0.190182, 0.297871, 0.212542],
[0.192066, 0.301919, 0.215031],
[0.193934, 0.305973, 0.217513],
[0.195785, 0.31003, 0.219987],
[0.197619, 0.314093, 0.222455],
[0.199435, 0.318161, 0.224916],
[0.201235, 0.322233, 0.22737],
[0.203018, 0.326311, 0.229817],
[0.204783, 0.330395, 0.232258],
[0.206532, 0.334484, 0.234693],
[0.208263, 0.338579, 0.237121],
[0.209977, 0.34268, 0.239543],
[0.211674, 0.346787, 0.24196],
[0.213354, 0.3509, 0.24437],
[0.215017, 0.355019, 0.246774],
[0.216662, 0.359145, 0.249173],
[0.21829, 0.363277, 0.251566],
[0.219901, 0.367416, 0.253953],
[0.221494, 0.371562, 0.256335],
[0.22307, 0.375715, 0.258712],
[0.224628, 0.379875, 0.261083],
[0.226168, 0.384043, 0.263449],
[0.227691, 0.388217, 0.26581],
[0.229196, 0.392399, 0.268166],
[0.230683, 0.396589, 0.270517],
[0.232151, 0.400787, 0.272864],
[0.233602, 0.404992, 0.275205],
[0.235035, 0.409206, 0.277542],
[0.236449, 0.413427, 0.279874],
[0.237844, 0.417657, 0.282201],
[0.239221, 0.421895, 0.284524],
[0.24058, 0.426142, 0.286842],
[0.241919, 0.430397, 0.289157],
[0.24324, 0.434661, 0.291466],
[0.244541, 0.438933, 0.293772],
[0.245823, 0.443215, 0.296073],
[0.247085, 0.447506, 0.298371],
[0.248328, 0.451806, 0.300664],
[0.249551, 0.456115, 0.302953],
[0.250754, 0.460433, 0.305238],
[0.251937, 0.464762, 0.30752],
[0.2531, 0.469099, 0.309797],
[0.254241, 0.473447, 0.312071],
[0.255363, 0.477804, 0.314341],
[0.256463, 0.482171, 0.316608],
[0.257542, 0.486549, 0.318871],
[0.2586, 0.490936, 0.32113],
[0.259636, 0.495334, 0.323386],
[0.26065, 0.499743, 0.325638],
[0.264433, 0.503578, 0.329101],
[0.270954, 0.506836, 0.333779],
[0.277415, 0.510096, 0.338462],
[0.283821, 0.51336, 0.34315],
[0.290175, 0.516628, 0.347843],
[0.296482, 0.519899, 0.352541],
[0.302744, 0.523175, 0.357245],
[0.308964, 0.526454, 0.361953],
[0.315145, 0.529738, 0.366668],
[0.32129, 0.533026, 0.371387],
[0.327401, 0.536318, 0.376113],
[0.33348, 0.539615, 0.380844],
[0.33953, 0.542917, 0.385581],
[0.345551, 0.546224, 0.390324],
[0.351546, 0.549536, 0.395073],
[0.357516, 0.552853, 0.399828],
[0.363463, 0.556176, 0.40459],
[0.369388, 0.559505, 0.409357],
[0.375293, 0.562839, 0.414132],
[0.381179, 0.566179, 0.418913],
[0.387047, 0.569525, 0.4237],
[0.392898, 0.572877, 0.428494],
[0.398734, 0.576235, 0.433295],
[0.404554, 0.5796, 0.438103],
[0.410361, 0.582972, 0.442918],
[0.416155, 0.58635, 0.44774],
[0.421937, 0.589735, 0.452569],
[0.427708, 0.593128, 0.457405],
[0.433468, 0.596527, 0.462249],
[0.439218, 0.599934, 0.4671],
[0.444959, 0.603348, 0.471958],
[0.450692, 0.60677, 0.476824],
[0.456417, 0.610199, 0.481698],
[0.462135, 0.613637, 0.486579],
[0.467847, 0.617083, 0.491468],
[0.473552, 0.620536, 0.496365],
[0.479252, 0.623998, 0.50127],
[0.484947, 0.627469, 0.506183],
[0.490638, 0.630948, 0.511104],
[0.496324, 0.634436, 0.516033],
[0.502007, 0.637933, 0.520971],
[0.507687, 0.641439, 0.525917],
[0.513364, 0.644954, 0.530871],
[0.51904, 0.648478, 0.535834],
[0.524713, 0.652012, 0.540806],
[0.530385, 0.655555, 0.545786],
[0.536055, 0.659108, 0.550775],
[0.541725, 0.662671, 0.555772],
[0.547395, 0.666244, 0.560779],
[0.553065, 0.669828, 0.565795],
[0.558734, 0.673421, 0.570819],
[0.564405, 0.677025, 0.575853],
[0.570076, 0.68064, 0.580896],
[0.575749, 0.684265, 0.585948],
[0.581423, 0.687901, 0.59101],
[0.587099, 0.691548, 0.596081],
[0.592778, 0.695207, 0.601162],
[0.598458, 0.698877, 0.606253],
[0.604141, 0.702558, 0.611353],
[0.609827, 0.706251, 0.616463],
[0.615517, 0.709955, 0.621583],
[0.621209, 0.713672, 0.626712],
[0.626906, 0.7174, 0.631852],
[0.632606, 0.721141, 0.637002],
[0.63831, 0.724894, 0.642162],
[0.644019, 0.728659, 0.647332],
[0.649732, 0.732437, 0.652513],
[0.65545, 0.736228, 0.657704],
[0.661173, 0.740032, 0.662906],
[0.666901, 0.743849, 0.668118],
[0.672634, 0.747679, 0.673341],
[0.678373, 0.751523, 0.678575],
[0.684118, 0.75538, 0.68382],
[0.689869, 0.759251, 0.689076],
[0.695626, 0.763136, 0.694342],
[0.70139, 0.767034, 0.69962],
[0.70716, 0.770947, 0.704909],
[0.712937, 0.774875, 0.710209],
[0.71872, 0.778816, 0.715521],
[0.724511, 0.782773, 0.720844],
[0.730309, 0.786744, 0.726178],
[0.736114, 0.79073, 0.731524],
[0.741927, 0.794732, 0.736882],
[0.747748, 0.798748, 0.742252],
[0.753577, 0.802781, 0.747633],
[0.759413, 0.806829, 0.753026],
[0.765258, 0.810892, 0.758432],
[0.771112, 0.814972, 0.763849],
[0.776973, 0.819068, 0.769278],
[0.782844, 0.82318, 0.77472],
[0.788723, 0.827309, 0.780174],
[0.79461, 0.831455, 0.78564],
[0.800507, 0.835617, 0.791119],
[0.806413, 0.839797, 0.796611],
[0.812329, 0.843994, 0.802114],
[0.818253, 0.848208, 0.807631],
[0.824187, 0.85244, 0.81316],
[0.830131, 0.85669, 0.818702],
[0.836084, 0.860958, 0.824257],
[0.842047, 0.865245, 0.829824],
[0.84802, 0.86955, 0.835405],
[0.854003, 0.873873, 0.840998],
[0.859996, 0.878216, 0.846604],
[0.865998, 0.882578, 0.852224],
[0.872011, 0.886959, 0.857856],
[0.878034, 0.89136, 0.863501],
[0.884067, 0.895781, 0.86916],
[0.890109, 0.900223, 0.874831],
[0.896162, 0.904684, 0.880515],
[0.902225, 0.909167, 0.886213],
[0.908298, 0.91367, 0.891923],
[0.914381, 0.918196, 0.897646],
[0.920473, 0.922742, 0.903381],
[0.926575, 0.927311, 0.909129],
[0.932685, 0.931902, 0.91489],
[0.938805, 0.936517, 0.920662],
[0.944934, 0.941154, 0.926447],
[0.951071, 0.945816, 0.932243],
[0.957215, 0.950502, 0.93805],
[0.963365, 0.955213, 0.943867],
[0.969522, 0.95995, 0.949694],
[0.975683, 0.964714, 0.95553],
[0.981846, 0.969506, 0.961372],
[0.988009, 0.974327, 0.96722],
[0.994169, 0.97918, 0.973071],
[1., 0.984069, 0.978918],
[1., 0.989, 0.984752],
[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()
