from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000402937, 0.000328026, 0.000374156],
[0.00119039, 0.000922728, 0.00109479],
[0.00235797, 0.00176137, 0.00214935],
[0.00389901, 0.00282006, 0.00352219],
[0.0058133, 0.00408201, 0.00520299],
[0.00810395, 0.0055342, 0.0071838],
[0.0107761, 0.00716597, 0.00945783],
[0.0138361, 0.00896819, 0.0120188],
[0.0172916, 0.0109329, 0.0148608],
[0.0211505, 0.013053, 0.0179777],
[0.0254217, 0.0153221, 0.0213634],
[0.0301144, 0.0177343, 0.0250116],
[0.035238, 0.0202842, 0.0289157],
[0.0407955, 0.0229669, 0.0330688],
[0.0464447, 0.0257777, 0.0374635],
[0.0520714, 0.0287123, 0.0420461],
[0.05768, 0.0317667, 0.0465621],
[0.0632741, 0.0349371, 0.0509983],
[0.0688569, 0.0382201, 0.0553567],
[0.074431, 0.0415833, 0.0596389],
[0.0799987, 0.0448871, 0.0638462],
[0.0855618, 0.0481358, 0.0679796],
[0.0911221, 0.0513324, 0.0720398],
[0.0966808, 0.0544797, 0.0760274],
[0.102239, 0.0575803, 0.0799428],
[0.107798, 0.0606365, 0.0837863],
[0.113358, 0.0636507, 0.0875579],
[0.11892, 0.0666248, 0.0912579],
[0.124485, 0.0695611, 0.0948863],
[0.130052, 0.0724615, 0.0984428],
[0.135623, 0.0753277, 0.101928],
[0.141196, 0.0781617, 0.10534],
[0.146773, 0.0809652, 0.108681],
[0.152353, 0.0837398, 0.111949],
[0.157936, 0.0864872, 0.115144],
[0.163523, 0.089209, 0.118267],
[0.169112, 0.0919069, 0.121317],
[0.174703, 0.0945822, 0.124294],
[0.180296, 0.0972366, 0.127198],
[0.185891, 0.0998716, 0.130028],
[0.191488, 0.102489, 0.132784],
[0.197085, 0.105089, 0.135467],
[0.202682, 0.107674, 0.138076],
[0.208279, 0.110246, 0.140612],
[0.213876, 0.112805, 0.143073],
[0.21947, 0.115353, 0.145461],
[0.225063, 0.117892, 0.147775],
[0.230653, 0.120423, 0.150016],
[0.236239, 0.122947, 0.152184],
[0.241821, 0.125465, 0.154278],
[0.247398, 0.12798, 0.1563],
[0.252969, 0.130491, 0.158249],
[0.258534, 0.133001, 0.160126],
[0.264092, 0.135511, 0.161931],
[0.269641, 0.138022, 0.163665],
[0.275182, 0.140535, 0.165329],
[0.280712, 0.143052, 0.166922],
[0.286232, 0.145574, 0.168446],
[0.291741, 0.148102, 0.169901],
[0.297237, 0.150638, 0.171289],
[0.30272, 0.153182, 0.172609],
[0.308189, 0.155736, 0.173862],
[0.313643, 0.158301, 0.175051],
[0.319082, 0.160878, 0.176175],
[0.324503, 0.163468, 0.177235],
[0.329907, 0.166073, 0.178234],
[0.335292, 0.168694, 0.179171],
[0.340658, 0.171331, 0.180048],
[0.346004, 0.173987, 0.180866],
[0.351328, 0.176661, 0.181627],
[0.35663, 0.179355, 0.182332],
[0.36191, 0.18207, 0.182983],
[0.367165, 0.184808, 0.18358],
[0.372395, 0.187568, 0.184125],
[0.3776, 0.190352, 0.18462],
[0.382778, 0.193161, 0.185067],
[0.387928, 0.195996, 0.185467],
[0.39305, 0.198857, 0.185821],
[0.398143, 0.201746, 0.186132],
[0.403205, 0.204664, 0.186401],
[0.408237, 0.20761, 0.186631],
[0.413236, 0.210587, 0.186823],
[0.418203, 0.213594, 0.186978],
[0.423136, 0.216632, 0.1871],
[0.428034, 0.219703, 0.18719],
[0.432898, 0.222806, 0.187249],
[0.437725, 0.225943, 0.187281],
[0.442515, 0.229114, 0.187288],
[0.447267, 0.232319, 0.187271],
[0.45198, 0.235559, 0.187233],
[0.456654, 0.238835, 0.187176],
[0.461288, 0.242146, 0.187103],
[0.465881, 0.245494, 0.187016],
[0.470433, 0.248879, 0.186917],
[0.474942, 0.252301, 0.186809],
[0.479407, 0.25576, 0.186695],
[0.483829, 0.259257, 0.186577],
[0.488206, 0.262792, 0.186457],
[0.492538, 0.266365, 0.186339],
[0.496823, 0.269976, 0.186226],
[0.501063, 0.273626, 0.186119],
[0.505254, 0.277315, 0.186022],
[0.509398, 0.281043, 0.185938],
[0.513494, 0.284809, 0.18587],
[0.51754, 0.288614, 0.185821],
[0.521537, 0.292458, 0.185793],
[0.525483, 0.296341, 0.185791],
[0.529379, 0.300262, 0.185816],
[0.533223, 0.304222, 0.185873],
[0.537016, 0.308221, 0.185964],
[0.540756, 0.312257, 0.186093],
[0.544444, 0.316332, 0.186263],
[0.548079, 0.320445, 0.186478],
[0.551661, 0.324595, 0.18674],
[0.555188, 0.328783, 0.187053],
[0.558662, 0.333007, 0.18742],
[0.562081, 0.337268, 0.187846],
[0.565446, 0.341566, 0.188333],
[0.568755, 0.345899, 0.188884],
[0.57201, 0.350268, 0.189504],
[0.575209, 0.354671, 0.190195],
[0.578353, 0.359109, 0.190961],
[0.581442, 0.363582, 0.191806],
[0.584475, 0.368087, 0.192731],
[0.587452, 0.372626, 0.193741],
[0.590374, 0.377197, 0.194839],
[0.593241, 0.3818, 0.196028],
[0.596051, 0.386433, 0.197311],
[0.598807, 0.391098, 0.198691],
[0.601508, 0.395792, 0.20017],
[0.604154, 0.400515, 0.201751],
[0.606745, 0.405267, 0.203438],
[0.609282, 0.410046, 0.205232],
[0.611766, 0.414852, 0.207135],
[0.614196, 0.419685, 0.209151],
[0.616573, 0.424543, 0.21128],
[0.618898, 0.429425, 0.213525],
[0.621171, 0.434332, 0.215888],
[0.623393, 0.439261, 0.218371],
[0.625564, 0.444213, 0.220974],
[0.627686, 0.449185, 0.223698],
[0.62976, 0.454179, 0.226547],
[0.631785, 0.459192, 0.229519],
[0.633764, 0.464223, 0.232616],
[0.635697, 0.469272, 0.235838],
[0.637585, 0.474339, 0.239187],
[0.639429, 0.479421, 0.242662],
[0.641232, 0.484518, 0.246263],
[0.642993, 0.489629, 0.249991],
[0.644715, 0.494753, 0.253845],
[0.646398, 0.49989, 0.257826],
[0.648045, 0.505037, 0.261933],
[0.649657, 0.510195, 0.266165],
[0.651235, 0.515362, 0.270521],
[0.652782, 0.520538, 0.275002],
[0.654299, 0.525721, 0.279606],
[0.655788, 0.53091, 0.284332],
[0.657251, 0.536105, 0.289179],
[0.658691, 0.541304, 0.294146],
[0.660108, 0.546507, 0.299231],
[0.661506, 0.551712, 0.304434],
[0.662887, 0.556919, 0.309752],
[0.664253, 0.562126, 0.315185],
[0.665606, 0.567334, 0.320731],
[0.666949, 0.57254, 0.326387],
[0.668284, 0.577744, 0.332153],
[0.669614, 0.582945, 0.338026],
[0.670942, 0.588142, 0.344004],
[0.672271, 0.593334, 0.350086],
[0.673602, 0.59852, 0.35627],
[0.674939, 0.603701, 0.362552],
[0.676285, 0.608873, 0.368932],
[0.677643, 0.614038, 0.375408],
[0.679016, 0.619193, 0.381975],
[0.680406, 0.624339, 0.388634],
[0.681817, 0.629474, 0.39538],
[0.683251, 0.634598, 0.402212],
[0.684712, 0.639711, 0.409127],
[0.686203, 0.64481, 0.416124],
[0.687727, 0.649896, 0.423198],
[0.689286, 0.654969, 0.430348],
[0.690885, 0.660026, 0.437572],
[0.692525, 0.665069, 0.444866],
[0.694211, 0.670096, 0.452227],
[0.695945, 0.675107, 0.459654],
[0.697729, 0.680101, 0.467144],
[0.699568, 0.685078, 0.474693],
[0.701464, 0.690038, 0.482299],
[0.703419, 0.69498, 0.489959],
[0.705437, 0.699904, 0.49767],
[0.70752, 0.704809, 0.50543],
[0.709671, 0.709695, 0.513236],
[0.711892, 0.714562, 0.521085],
[0.714187, 0.71941, 0.528974],
[0.716556, 0.724239, 0.5369],
[0.719003, 0.729048, 0.54486],
[0.721529, 0.733838, 0.552852],
[0.724138, 0.738608, 0.560872],
[0.72683, 0.743358, 0.568919],
[0.729607, 0.748088, 0.576988],
[0.732472, 0.752799, 0.585078],
[0.735425, 0.757491, 0.593185],
[0.738468, 0.762163, 0.601307],
[0.741603, 0.766817, 0.609441],
[0.744831, 0.771451, 0.617584],
[0.748152, 0.776067, 0.625733],
[0.751567, 0.780664, 0.633887],
[0.755078, 0.785244, 0.642041],
[0.758685, 0.789806, 0.650195],
[0.762387, 0.79435, 0.658344],
[0.766187, 0.798878, 0.666487],
[0.770083, 0.80339, 0.674621],
[0.774075, 0.807886, 0.682744],
[0.778165, 0.812367, 0.690853],
[0.78235, 0.816834, 0.698946],
[0.786632, 0.821286, 0.707021],
[0.791008, 0.825725, 0.715076],
[0.79548, 0.830152, 0.723108],
[0.800046, 0.834567, 0.731115],
[0.804704, 0.83897, 0.739096],
[0.809455, 0.843363, 0.747048],
[0.814297, 0.847747, 0.75497],
[0.819229, 0.852122, 0.762859],
[0.824249, 0.856489, 0.770715],
[0.829356, 0.860849, 0.778534],
[0.834549, 0.865203, 0.786316],
[0.839825, 0.869552, 0.794059],
[0.845184, 0.873897, 0.801762],
[0.850624, 0.878238, 0.809423],
[0.856142, 0.882578, 0.817041],
[0.861737, 0.886916, 0.824615],
[0.867407, 0.891254, 0.832143],
[0.87315, 0.895592, 0.839624],
[0.878963, 0.899933, 0.847058],
[0.884845, 0.904277, 0.854442],
[0.890794, 0.908625, 0.861778],
[0.896806, 0.912978, 0.869062],
[0.90288, 0.917338, 0.876296],
[0.909014, 0.921706, 0.883477],
[0.915205, 0.926083, 0.890606],
[0.92145, 0.93047, 0.897681],
[0.927747, 0.934868, 0.904702],
[0.934092, 0.93928, 0.911669],
[0.940484, 0.943705, 0.918581],
[0.946919, 0.948147, 0.925436],
[0.953394, 0.952606, 0.932236],
[0.959905, 0.957085, 0.938978],
[0.966448, 0.961584, 0.945662],
[0.97302, 0.966107, 0.952286],
[0.979614, 0.970656, 0.95885],
[0.986224, 0.975233, 0.965351],
[0.992842, 0.979845, 0.971784],
[0.999453, 0.984496, 0.978144],
[1., 0.989199, 0.984415],
[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()
