from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000405063, 0.000332768, 0.000320958],
[0.00119499, 0.000941283, 0.00090058],
[0.00236152, 0.0018053, 0.00171716],
[0.00389363, 0.00290336, 0.00274803],
[0.00578633, 0.00422109, 0.00397776],
[0.00803761, 0.00574787, 0.00539478],
[0.0106472, 0.00747537, 0.0069899],
[0.013616, 0.00939683, 0.00875557],
[0.0169455, 0.0115066, 0.0106854],
[0.020638, 0.0137998, 0.0127739],
[0.0246962, 0.0162724, 0.0150162],
[0.0291229, 0.0189206, 0.0174081],
[0.0339214, 0.0217412, 0.0199457],
[0.0390952, 0.0247314, 0.0226256],
[0.0444589, 0.0278886, 0.0254447],
[0.0497683, 0.0312104, 0.0284001],
[0.0550376, 0.0346947, 0.031489],
[0.060271, 0.0383395, 0.0347092],
[0.0654721, 0.0420948, 0.0380583],
[0.0706441, 0.0457977, 0.0415078],
[0.0757898, 0.0494543, 0.0449095],
[0.0809117, 0.0530675, 0.0482648],
[0.0860121, 0.05664, 0.0515762],
[0.091093, 0.0601739, 0.0548462],
[0.0961562, 0.0636715, 0.0580769],
[0.101204, 0.0671347, 0.0612703],
[0.106236, 0.0705652, 0.0644282],
[0.111256, 0.0739647, 0.0675522],
[0.116264, 0.0773346, 0.070644],
[0.121262, 0.0806763, 0.073705],
[0.12625, 0.0839911, 0.0767363],
[0.13123, 0.0872802, 0.0797393],
[0.136203, 0.0905447, 0.0827151],
[0.141168, 0.0937856, 0.0856648],
[0.146128, 0.0970038, 0.0885893],
[0.151084, 0.1002, 0.0914895],
[0.156035, 0.103376, 0.0943664],
[0.160982, 0.106531, 0.0972207],
[0.165927, 0.109667, 0.100053],
[0.170869, 0.112785, 0.102865],
[0.17581, 0.115884, 0.105656],
[0.18075, 0.118966, 0.108427],
[0.185689, 0.122031, 0.111179],
[0.190628, 0.12508, 0.113913],
[0.195567, 0.128113, 0.116629],
[0.200507, 0.131131, 0.119327],
[0.205449, 0.134135, 0.122008],
[0.210392, 0.137124, 0.124673],
[0.215338, 0.140099, 0.127322],
[0.220286, 0.143061, 0.129955],
[0.225237, 0.146009, 0.132572],
[0.230191, 0.148946, 0.135176],
[0.235148, 0.151869, 0.137764],
[0.24011, 0.154781, 0.140339],
[0.245076, 0.157682, 0.1429],
[0.250046, 0.160571, 0.145447],
[0.255021, 0.163449, 0.147981],
[0.260001, 0.166316, 0.150503],
[0.264987, 0.169173, 0.153012],
[0.269978, 0.17202, 0.155509],
[0.274975, 0.174857, 0.157994],
[0.279979, 0.177684, 0.160467],
[0.284989, 0.180502, 0.162929],
[0.290005, 0.183311, 0.16538],
[0.295028, 0.186111, 0.16782],
[0.300059, 0.188903, 0.170249],
[0.305097, 0.191686, 0.172668],
[0.310142, 0.19446, 0.175077],
[0.315195, 0.197227, 0.177475],
[0.320257, 0.199985, 0.179864],
[0.325326, 0.202736, 0.182243],
[0.330404, 0.20548, 0.184612],
[0.335491, 0.208216, 0.186972],
[0.340586, 0.210945, 0.189323],
[0.34569, 0.213667, 0.191666],
[0.350804, 0.216382, 0.193999],
[0.355926, 0.21909, 0.196324],
[0.361059, 0.221792, 0.19864],
[0.366201, 0.224488, 0.200948],
[0.371353, 0.227177, 0.203248],
[0.376515, 0.22986, 0.205539],
[0.381687, 0.232537, 0.207823],
[0.386869, 0.235208, 0.2101],
[0.392063, 0.237873, 0.212368],
[0.397267, 0.240533, 0.214629],
[0.402481, 0.243187, 0.216883],
[0.407707, 0.245836, 0.219129],
[0.412944, 0.24848, 0.221369],
[0.418193, 0.251119, 0.223601],
[0.423453, 0.253752, 0.225826],
[0.428724, 0.256381, 0.228045],
[0.434008, 0.259004, 0.230257],
[0.439303, 0.261623, 0.232463],
[0.44461, 0.264237, 0.234662],
[0.44993, 0.266847, 0.236854],
[0.455262, 0.269452, 0.239041],
[0.460607, 0.272053, 0.241221],
[0.465964, 0.27465, 0.243395],
[0.471334, 0.277242, 0.245563],
[0.476718, 0.27983, 0.247725],
[0.482114, 0.282415, 0.249882],
[0.487523, 0.284995, 0.252033],
[0.492946, 0.287572, 0.254178],
[0.498383, 0.290144, 0.256317],
[0.503833, 0.292713, 0.258451],
[0.509297, 0.295278, 0.26058],
[0.514775, 0.29784, 0.262703],
[0.520267, 0.300398, 0.264822],
[0.525773, 0.302953, 0.266935],
[0.531293, 0.305505, 0.269043],
[0.536829, 0.308053, 0.271146],
[0.542378, 0.310598, 0.273244],
[0.547943, 0.31314, 0.275337],
[0.553522, 0.315679, 0.277425],
[0.559116, 0.318214, 0.279509],
[0.564726, 0.320747, 0.281588],
[0.57035, 0.323277, 0.283662],
[0.57599, 0.325804, 0.285732],
[0.581646, 0.328328, 0.287797],
[0.587318, 0.330849, 0.289858],
[0.593005, 0.333368, 0.291914],
[0.598708, 0.335884, 0.293967],
[0.604427, 0.338398, 0.296015],
[0.610163, 0.340909, 0.298059],
[0.615915, 0.343418, 0.300098],
[0.621683, 0.345924, 0.302134],
[0.627468, 0.348428, 0.304166],
[0.631798, 0.35197, 0.307537],
[0.634653, 0.356555, 0.312257],
[0.6375, 0.361141, 0.316988],
[0.640339, 0.36573, 0.321727],
[0.643169, 0.370321, 0.326477],
[0.645992, 0.374915, 0.331236],
[0.648807, 0.379511, 0.336004],
[0.651614, 0.384111, 0.340782],
[0.654414, 0.388713, 0.34557],
[0.657208, 0.393319, 0.350368],
[0.659995, 0.397928, 0.355175],
[0.662775, 0.402541, 0.359992],
[0.665549, 0.407158, 0.364818],
[0.668318, 0.411778, 0.369654],
[0.67108, 0.416403, 0.3745],
[0.673838, 0.421032, 0.379355],
[0.67659, 0.425666, 0.38422],
[0.679337, 0.430304, 0.389095],
[0.68208, 0.434946, 0.39398],
[0.684818, 0.439594, 0.398874],
[0.687552, 0.444246, 0.403778],
[0.690282, 0.448904, 0.408692],
[0.693008, 0.453567, 0.413615],
[0.695731, 0.458235, 0.418549],
[0.698451, 0.462909, 0.423492],
[0.701167, 0.467588, 0.428445],
[0.703881, 0.472274, 0.433407],
[0.706593, 0.476965, 0.43838],
[0.709302, 0.481662, 0.443363],
[0.712009, 0.486365, 0.448355],
[0.714715, 0.491075, 0.453358],
[0.717419, 0.495791, 0.45837],
[0.720121, 0.500513, 0.463392],
[0.722823, 0.505242, 0.468424],
[0.725524, 0.509978, 0.473467],
[0.728224, 0.514721, 0.478519],
[0.730924, 0.51947, 0.483581],
[0.733623, 0.524227, 0.488654],
[0.736323, 0.528991, 0.493737],
[0.739024, 0.533762, 0.498829],
[0.741725, 0.538541, 0.503932],
[0.744427, 0.543327, 0.509045],
[0.74713, 0.548121, 0.514169],
[0.749834, 0.552922, 0.519302],
[0.75254, 0.557732, 0.524446],
[0.755248, 0.562549, 0.529601],
[0.757958, 0.567374, 0.534765],
[0.760671, 0.572208, 0.53994],
[0.763386, 0.57705, 0.545126],
[0.766103, 0.5819, 0.550322],
[0.768824, 0.586759, 0.555528],
[0.771549, 0.591626, 0.560746],
[0.774277, 0.596502, 0.565973],
[0.777009, 0.601387, 0.571212],
[0.779744, 0.606281, 0.576461],
[0.782485, 0.611184, 0.58172],
[0.78523, 0.616096, 0.586991],
[0.78798, 0.621017, 0.592272],
[0.790735, 0.625948, 0.597564],
[0.793495, 0.630888, 0.602867],
[0.796261, 0.635837, 0.608181],
[0.799033, 0.640797, 0.613506],
[0.801811, 0.645766, 0.618842],
[0.804596, 0.650745, 0.624189],
[0.807387, 0.655733, 0.629547],
[0.810186, 0.660732, 0.634916],
[0.812991, 0.665741, 0.640296],
[0.815804, 0.670761, 0.645688],
[0.818625, 0.675791, 0.651091],
[0.821454, 0.680831, 0.656506],
[0.824292, 0.685882, 0.661931],
[0.827138, 0.690943, 0.667368],
[0.829993, 0.696016, 0.672817],
[0.832857, 0.701099, 0.678277],
[0.835731, 0.706193, 0.683749],
[0.838615, 0.711299, 0.689233],
[0.841508, 0.716415, 0.694728],
[0.844412, 0.721543, 0.700235],
[0.847327, 0.726683, 0.705753],
[0.850253, 0.731834, 0.711284],
[0.85319, 0.736996, 0.716826],
[0.856139, 0.742171, 0.722381],
[0.8591, 0.747357, 0.727947],
[0.862073, 0.752555, 0.733525],
[0.865059, 0.757765, 0.739116],
[0.868057, 0.762987, 0.744719],
[0.871069, 0.768222, 0.750333],
[0.874094, 0.773468, 0.75596],
[0.877134, 0.778728, 0.761599],
[0.880188, 0.783999, 0.767251],
[0.883256, 0.789284, 0.772915],
[0.886339, 0.794581, 0.778591],
[0.889438, 0.799891, 0.78428],
[0.892553, 0.805213, 0.789981],
[0.895684, 0.810549, 0.795694],
[0.898831, 0.815898, 0.80142],
[0.901996, 0.82126, 0.807159],
[0.905178, 0.826636, 0.81291],
[0.908378, 0.832024, 0.818673],
[0.911596, 0.837426, 0.82445],
[0.914833, 0.842842, 0.830238],
[0.918089, 0.848271, 0.836039],
[0.921365, 0.853714, 0.841853],
[0.924661, 0.85917, 0.847679],
[0.927978, 0.864641, 0.853518],
[0.931317, 0.870125, 0.859369],
[0.934677, 0.875622, 0.865233],
[0.93806, 0.881134, 0.871109],
[0.941467, 0.88666, 0.876997],
[0.944897, 0.892199, 0.882897],
[0.948352, 0.897753, 0.888809],
[0.951833, 0.90332, 0.894733],
[0.95534, 0.908901, 0.900668],
[0.958874, 0.914496, 0.906615],
[0.962437, 0.920105, 0.912573],
[0.96603, 0.925727, 0.918541],
[0.969653, 0.931363, 0.92452],
[0.973309, 0.937012, 0.930509],
[0.976999, 0.942673, 0.936506],
[0.980725, 0.948347, 0.942512],
[0.984489, 0.954033, 0.948526],
[0.988295, 0.95973, 0.954545],
[0.992146, 0.965438, 0.960568],
[0.996048, 0.971154, 0.966592],
[1., 0.976876, 0.972614],
[1., 0.982601, 0.978627],
[1., 0.98832, 0.984617],
[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()
