from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000452801, 0.000316644, 0.00029709],
[0.00137027, 0.00088162, 0.000818425],
[0.00275481, 0.00167043, 0.00154385],
[0.00460492, 0.00265772, 0.0024534],
[0.00692398, 0.0038255, 0.00353535],
[0.00971753, 0.00515981, 0.00478268],
[0.0129922, 0.00664914, 0.00619142],
[0.016755, 0.00828371, 0.00775988],
[0.0210135, 0.010055, 0.00948807],
[0.0257751, 0.0119554, 0.0113774],
[0.0310473, 0.0139781, 0.0134305],
[0.0368376, 0.0161169, 0.0156511],
[0.0430578, 0.0183662, 0.0180436],
[0.0492643, 0.0207207, 0.0206136],
[0.0554261, 0.0231755, 0.0233673],
[0.0615475, 0.0257263, 0.0263117],
[0.0676322, 0.0283689, 0.0294544],
[0.0736834, 0.0310994, 0.0328039],
[0.0797037, 0.0339141, 0.0363693],
[0.0856951, 0.0368098, 0.0401602],
[0.0916595, 0.0397833, 0.0440299],
[0.0975984, 0.0427527, 0.0479138],
[0.103513, 0.0456595, 0.0518202],
[0.109405, 0.0485146, 0.0557529],
[0.115274, 0.0513205, 0.0597155],
[0.121122, 0.0540797, 0.0637111],
[0.126949, 0.0567946, 0.0677429],
[0.132755, 0.0594674, 0.0718135],
[0.138542, 0.0621, 0.0759257],
[0.144308, 0.0646945, 0.0800819],
[0.150055, 0.0672527, 0.0842844],
[0.155781, 0.0697764, 0.0885354],
[0.161489, 0.0722675, 0.0928368],
[0.167176, 0.0747275, 0.0971907],
[0.172843, 0.0771582, 0.101599],
[0.178491, 0.079561, 0.106062],
[0.184118, 0.0819376, 0.110583],
[0.189724, 0.0842896, 0.115163],
[0.19531, 0.0866183, 0.119803],
[0.200874, 0.0889253, 0.124504],
[0.206417, 0.091212, 0.129268],
[0.211937, 0.09348, 0.134095],
[0.217435, 0.0957305, 0.138986],
[0.22291, 0.0979652, 0.143943],
[0.228361, 0.100185, 0.148966],
[0.233788, 0.102392, 0.154055],
[0.23919, 0.104587, 0.159212],
[0.244567, 0.106772, 0.164437],
[0.249918, 0.108949, 0.16973],
[0.255243, 0.111117, 0.175091],
[0.26054, 0.11328, 0.180521],
[0.265809, 0.115438, 0.18602],
[0.27105, 0.117593, 0.191589],
[0.276261, 0.119746, 0.197226],
[0.281442, 0.121898, 0.202932],
[0.286592, 0.124052, 0.208707],
[0.29171, 0.126209, 0.214551],
[0.296796, 0.128369, 0.220463],
[0.301849, 0.130535, 0.226442],
[0.306868, 0.132708, 0.232489],
[0.311852, 0.13489, 0.238602],
[0.3168, 0.137081, 0.244781],
[0.321712, 0.139284, 0.251025],
[0.326586, 0.141501, 0.257334],
[0.331422, 0.143731, 0.263705],
[0.336219, 0.145978, 0.270139],
[0.340976, 0.148243, 0.276634],
[0.345692, 0.150526, 0.283188],
[0.350366, 0.15283, 0.289801],
[0.354997, 0.155157, 0.296471],
[0.359585, 0.157507, 0.303196],
[0.364128, 0.159883, 0.309975],
[0.368626, 0.162285, 0.316806],
[0.373078, 0.164716, 0.323688],
[0.377482, 0.167176, 0.330618],
[0.381838, 0.169668, 0.337594],
[0.386145, 0.172193, 0.344615],
[0.390402, 0.174752, 0.351679],
[0.394608, 0.177347, 0.358782],
[0.398762, 0.179979, 0.365924],
[0.402864, 0.182649, 0.373101],
[0.406912, 0.18536, 0.380311],
[0.410905, 0.188111, 0.387551],
[0.414844, 0.190906, 0.394819],
[0.418726, 0.193744, 0.402113],
[0.422551, 0.196627, 0.409429],
[0.426319, 0.199557, 0.416765],
[0.430027, 0.202534, 0.424117],
[0.433677, 0.205559, 0.431483],
[0.437266, 0.208635, 0.438861],
[0.440794, 0.21176, 0.446246],
[0.444261, 0.214938, 0.453635],
[0.447665, 0.218168, 0.461027],
[0.451007, 0.221451, 0.468417],
[0.454285, 0.224787, 0.475802],
[0.457498, 0.228179, 0.483179],
[0.460647, 0.231626, 0.490545],
[0.463731, 0.235129, 0.497897],
[0.466749, 0.238688, 0.50523],
[0.4697, 0.242303, 0.512543],
[0.472585, 0.245976, 0.519831],
[0.475403, 0.249706, 0.527092],
[0.478154, 0.253493, 0.534321],
[0.480837, 0.257338, 0.541516],
[0.483453, 0.261241, 0.548674],
[0.486, 0.265201, 0.55579],
[0.48848, 0.269218, 0.562862],
[0.490892, 0.273293, 0.569887],
[0.493236, 0.277424, 0.576862],
[0.495512, 0.281612, 0.583783],
[0.49772, 0.285856, 0.590647],
[0.499861, 0.290155, 0.597451],
[0.501935, 0.294509, 0.604193],
[0.503942, 0.298918, 0.610868],
[0.505883, 0.30338, 0.617476],
[0.507759, 0.307894, 0.624012],
[0.509569, 0.312461, 0.630474],
[0.511315, 0.317078, 0.63686],
[0.512998, 0.321745, 0.643166],
[0.514619, 0.326461, 0.649391],
[0.516177, 0.331225, 0.655533],
[0.517676, 0.336035, 0.661588],
[0.519115, 0.340891, 0.667555],
[0.520496, 0.34579, 0.673431],
[0.52182, 0.350733, 0.679216],
[0.523089, 0.355717, 0.684906],
[0.524305, 0.36074, 0.690501],
[0.525469, 0.365803, 0.695999],
[0.526582, 0.370902, 0.701398],
[0.527648, 0.376037, 0.706697],
[0.528667, 0.381207, 0.711895],
[0.529642, 0.386409, 0.71699],
[0.530575, 0.391641, 0.721983],
[0.531468, 0.396904, 0.726871],
[0.532324, 0.402194, 0.731654],
[0.533145, 0.407511, 0.736332],
[0.533934, 0.412852, 0.740905],
[0.534693, 0.418217, 0.745371],
[0.535425, 0.423603, 0.74973],
[0.536134, 0.429008, 0.753984],
[0.536821, 0.434433, 0.75813],
[0.53749, 0.439874, 0.762171],
[0.538145, 0.44533, 0.766106],
[0.538787, 0.4508, 0.769935],
[0.539422, 0.456282, 0.773659],
[0.540051, 0.461774, 0.777279],
[0.540678, 0.467276, 0.780795],
[0.541307, 0.472785, 0.784209],
[0.541942, 0.4783, 0.787521],
[0.542586, 0.48382, 0.790732],
[0.543242, 0.489344, 0.793844],
[0.543914, 0.494869, 0.796857],
[0.544606, 0.500395, 0.799774],
[0.545322, 0.50592, 0.802595],
[0.546065, 0.511444, 0.805323],
[0.546839, 0.516964, 0.807958],
[0.547648, 0.52248, 0.810503],
[0.548495, 0.52799, 0.812959],
[0.549385, 0.533494, 0.815329],
[0.55032, 0.53899, 0.817614],
[0.551306, 0.544477, 0.819815],
[0.552344, 0.549954, 0.821937],
[0.55344, 0.555421, 0.82398],
[0.554595, 0.560876, 0.825946],
[0.555815, 0.566318, 0.827838],
[0.557101, 0.571748, 0.829659],
[0.558458, 0.577163, 0.83141],
[0.559889, 0.582563, 0.833094],
[0.561396, 0.587947, 0.834713],
[0.562983, 0.593316, 0.83627],
[0.564653, 0.598667, 0.837767],
[0.566408, 0.604001, 0.839208],
[0.56825, 0.609317, 0.840593],
[0.570183, 0.614614, 0.841927],
[0.572209, 0.619893, 0.843211],
[0.57433, 0.625152, 0.844448],
[0.576547, 0.630392, 0.845641],
[0.578863, 0.635611, 0.846792],
[0.58128, 0.64081, 0.847904],
[0.583799, 0.645988, 0.84898],
[0.586421, 0.651145, 0.850022],
[0.589148, 0.656282, 0.851033],
[0.591981, 0.661397, 0.852016],
[0.59492, 0.666491, 0.852972],
[0.597966, 0.671563, 0.853906],
[0.601121, 0.676614, 0.854819],
[0.604384, 0.681643, 0.855713],
[0.607755, 0.68665, 0.856593],
[0.611235, 0.691637, 0.857459],
[0.614824, 0.696601, 0.858315],
[0.618521, 0.701545, 0.859163],
[0.622326, 0.706467, 0.860006],
[0.626239, 0.711369, 0.860846],
[0.630259, 0.716249, 0.861686],
[0.634385, 0.721109, 0.862528],
[0.638616, 0.725948, 0.863374],
[0.642952, 0.730767, 0.864227],
[0.647391, 0.735567, 0.86509],
[0.651933, 0.740347, 0.865964],
[0.656575, 0.745107, 0.866852],
[0.661317, 0.749849, 0.867756],
[0.666157, 0.754572, 0.868678],
[0.671093, 0.759277, 0.869621],
[0.676124, 0.763964, 0.870587],
[0.681249, 0.768634, 0.871577],
[0.686465, 0.773287, 0.872595],
[0.691771, 0.777924, 0.873642],
[0.697165, 0.782545, 0.874719],
[0.702645, 0.78715, 0.87583],
[0.70821, 0.79174, 0.876976],
[0.713856, 0.796316, 0.878159],
[0.719583, 0.800878, 0.879381],
[0.725389, 0.805427, 0.880644],
[0.731271, 0.809963, 0.881949],
[0.737227, 0.814487, 0.883298],
[0.743255, 0.818999, 0.884694],
[0.749354, 0.8235, 0.886137],
[0.755521, 0.827991, 0.88763],
[0.761755, 0.832472, 0.889175],
[0.768053, 0.836944, 0.890771],
[0.774413, 0.841408, 0.892423],
[0.780833, 0.845864, 0.89413],
[0.787311, 0.850312, 0.895894],
[0.793846, 0.854754, 0.897717],
[0.800435, 0.859191, 0.899601],
[0.807076, 0.863622, 0.901546],
[0.813767, 0.868049, 0.903554],
[0.820507, 0.872473, 0.905626],
[0.827293, 0.876893, 0.907764],
[0.834123, 0.881312, 0.909969],
[0.840995, 0.885729, 0.912243],
[0.847908, 0.890146, 0.914585],
[0.85486, 0.894563, 0.916998],
[0.861848, 0.898981, 0.919483],
[0.86887, 0.903401, 0.922041],
[0.875926, 0.907823, 0.924672],
[0.883011, 0.91225, 0.927379],
[0.890126, 0.916681, 0.930162],
[0.897267, 0.921117, 0.933022],
[0.904432, 0.92556, 0.93596],
[0.911619, 0.93001, 0.938978],
[0.918827, 0.934468, 0.942076],
[0.926052, 0.938937, 0.945256],
[0.933292, 0.943416, 0.948518],
[0.940544, 0.947907, 0.951865],
[0.947806, 0.952411, 0.955296],
[0.955073, 0.95693, 0.958815],
[0.962343, 0.961466, 0.962422],
[0.96961, 0.966021, 0.966119],
[0.976869, 0.970597, 0.969909],
[0.984112, 0.975196, 0.973796],
[0.991329, 0.979824, 0.977784],
[0.998502, 0.984487, 0.981881],
[1., 0.989197, 0.986105],
[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()
