from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000351512, 0.000355153, 0.000307815],
[0.000998297, 0.00102343, 0.000852933],
[0.00192039, 0.00198939, 0.00161133],
[0.00309647, 0.00323584, 0.00255834],
[0.00451245, 0.00475212, 0.00367683],
[0.00615813, 0.00653098, 0.00495373],
[0.00802562, 0.00856721, 0.00637853],
[0.0101086, 0.010857, 0.00794242],
[0.012402, 0.0133973, 0.00963789],
[0.0149014, 0.0161862, 0.0114584],
[0.0176032, 0.0192219, 0.013398],
[0.0205043, 0.0225033, 0.0154515],
[0.0236019, 0.0260296, 0.0176143],
[0.0268938, 0.0298002, 0.0198818],
[0.0303778, 0.0338149, 0.0222503],
[0.0340522, 0.0380736, 0.0247158],
[0.0379155, 0.0425095, 0.0272751],
[0.0419246, 0.0469004, 0.0299247],
[0.0458879, 0.0512487, 0.0326618],
[0.0498041, 0.0555577, 0.0354835],
[0.0536767, 0.0598306, 0.038387],
[0.0575085, 0.06407, 0.0413483],
[0.0613022, 0.0682783, 0.0442556],
[0.06506, 0.0724577, 0.0471149],
[0.068784, 0.0766103, 0.0499285],
[0.0724764, 0.0807379, 0.0526984],
[0.0761388, 0.084842, 0.0554266],
[0.0797728, 0.0889242, 0.0581146],
[0.08338, 0.0929859, 0.0607641],
[0.0869618, 0.0970285, 0.0633766],
[0.0905194, 0.101053, 0.0659533],
[0.094054, 0.105061, 0.0684956],
[0.0975668, 0.109052, 0.0710046],
[0.101059, 0.113029, 0.0734814],
[0.104531, 0.116992, 0.075927],
[0.107984, 0.120942, 0.0783423],
[0.11142, 0.12488, 0.0807282],
[0.114837, 0.128805, 0.0830856],
[0.118239, 0.13272, 0.0854152],
[0.121625, 0.136625, 0.0877178],
[0.124995, 0.14052, 0.089994],
[0.128351, 0.144406, 0.0922445],
[0.131693, 0.148284, 0.0944699],
[0.135022, 0.152154, 0.0966708],
[0.138339, 0.156016, 0.0988477],
[0.141643, 0.159871, 0.101001],
[0.144935, 0.163721, 0.103132],
[0.148216, 0.167564, 0.10524],
[0.151486, 0.171401, 0.107326],
[0.154746, 0.175233, 0.10939],
[0.157996, 0.179061, 0.111434],
[0.161236, 0.182884, 0.113456],
[0.164467, 0.186703, 0.115458],
[0.16769, 0.190518, 0.11744],
[0.170904, 0.19433, 0.119402],
[0.174109, 0.198139, 0.121344],
[0.177307, 0.201945, 0.123268],
[0.180498, 0.205749, 0.125172],
[0.183681, 0.20955, 0.127058],
[0.186858, 0.21335, 0.128926],
[0.190028, 0.217148, 0.130775],
[0.193191, 0.220945, 0.132607],
[0.196349, 0.22474, 0.134421],
[0.1995, 0.228535, 0.136217],
[0.202647, 0.232329, 0.137996],
[0.205787, 0.236123, 0.139759],
[0.208923, 0.239916, 0.141504],
[0.212054, 0.24371, 0.143233],
[0.21518, 0.247504, 0.144945],
[0.218302, 0.251298, 0.146641],
[0.221419, 0.255093, 0.148321],
[0.224533, 0.258889, 0.149985],
[0.227642, 0.262686, 0.151633],
[0.230748, 0.266484, 0.153266],
[0.233851, 0.270284, 0.154883],
[0.23695, 0.274085, 0.156484],
[0.240046, 0.277888, 0.15807],
[0.243139, 0.281693, 0.159641],
[0.24623, 0.2855, 0.161197],
[0.249318, 0.289309, 0.162738],
[0.252403, 0.293121, 0.164264],
[0.255486, 0.296935, 0.165775],
[0.258567, 0.300752, 0.167271],
[0.261646, 0.304572, 0.168753],
[0.264723, 0.308395, 0.17022],
[0.267798, 0.312222, 0.171673],
[0.270872, 0.316051, 0.173111],
[0.273945, 0.319884, 0.174536],
[0.277016, 0.323721, 0.175945],
[0.280086, 0.327562, 0.177341],
[0.283155, 0.331406, 0.178723],
[0.286223, 0.335254, 0.18009],
[0.28929, 0.339107, 0.181443],
[0.292357, 0.342964, 0.182783],
[0.295423, 0.346825, 0.184108],
[0.298489, 0.350691, 0.18542],
[0.301554, 0.354562, 0.186718],
[0.30462, 0.358437, 0.188002],
[0.307685, 0.362317, 0.189272],
[0.31075, 0.366203, 0.190528],
[0.313816, 0.370093, 0.191771],
[0.316881, 0.373989, 0.192999],
[0.319948, 0.37789, 0.194215],
[0.323014, 0.381797, 0.195416],
[0.326081, 0.385709, 0.196604],
[0.329149, 0.389627, 0.197778],
[0.332218, 0.393551, 0.198938],
[0.335288, 0.397481, 0.200085],
[0.338358, 0.401417, 0.201218],
[0.34143, 0.405359, 0.202337],
[0.344503, 0.409307, 0.203443],
[0.347577, 0.413262, 0.204535],
[0.350653, 0.417223, 0.205613],
[0.35373, 0.421191, 0.206678],
[0.356809, 0.425166, 0.207729],
[0.359889, 0.429148, 0.208766],
[0.362971, 0.433136, 0.20979],
[0.366055, 0.437132, 0.210799],
[0.369141, 0.441134, 0.211795],
[0.372229, 0.445144, 0.212777],
[0.37532, 0.449161, 0.213745],
[0.378412, 0.453186, 0.214699],
[0.381507, 0.457218, 0.21564],
[0.384604, 0.461258, 0.216566],
[0.387703, 0.465306, 0.217478],
[0.390805, 0.469361, 0.218376],
[0.39391, 0.473425, 0.21926],
[0.397511, 0.477223, 0.222561],
[0.401614, 0.480751, 0.228282],
[0.405726, 0.484282, 0.233993],
[0.409848, 0.487816, 0.239696],
[0.41398, 0.491353, 0.245393],
[0.418122, 0.494893, 0.251085],
[0.422273, 0.498436, 0.256771],
[0.426435, 0.501982, 0.262454],
[0.430606, 0.505532, 0.268135],
[0.434787, 0.509085, 0.273813],
[0.438978, 0.512643, 0.279489],
[0.443179, 0.516204, 0.285165],
[0.44739, 0.519769, 0.290841],
[0.451611, 0.523338, 0.296517],
[0.455843, 0.526912, 0.302195],
[0.460084, 0.53049, 0.307873],
[0.464336, 0.534073, 0.313554],
[0.468597, 0.53766, 0.319237],
[0.472869, 0.541253, 0.324923],
[0.477152, 0.54485, 0.330611],
[0.481444, 0.548452, 0.336304],
[0.485747, 0.55206, 0.342],
[0.490061, 0.555673, 0.3477],
[0.494385, 0.559292, 0.353404],
[0.498719, 0.562916, 0.359113],
[0.503064, 0.566546, 0.364827],
[0.50742, 0.570182, 0.370546],
[0.511786, 0.573824, 0.376271],
[0.516163, 0.577473, 0.382001],
[0.52055, 0.581127, 0.387737],
[0.524949, 0.584788, 0.393478],
[0.529358, 0.588456, 0.399226],
[0.533778, 0.592131, 0.40498],
[0.538209, 0.595812, 0.410741],
[0.542651, 0.5995, 0.416508],
[0.547103, 0.603196, 0.422283],
[0.551567, 0.606899, 0.428064],
[0.556043, 0.610609, 0.433852],
[0.560529, 0.614327, 0.439647],
[0.565026, 0.618052, 0.44545],
[0.569535, 0.621786, 0.45126],
[0.574055, 0.625527, 0.457077],
[0.578587, 0.629277, 0.462902],
[0.58313, 0.633035, 0.468735],
[0.587684, 0.636801, 0.474576],
[0.59225, 0.640575, 0.480425],
[0.596828, 0.644359, 0.486282],
[0.601417, 0.648151, 0.492147],
[0.606019, 0.651952, 0.49802],
[0.610632, 0.655762, 0.503901],
[0.615256, 0.659582, 0.509791],
[0.619893, 0.663411, 0.515689],
[0.624542, 0.667249, 0.521596],
[0.629202, 0.671097, 0.527512],
[0.633875, 0.674955, 0.533436],
[0.63856, 0.678822, 0.539369],
[0.643258, 0.6827, 0.545311],
[0.647967, 0.686588, 0.551261],
[0.652689, 0.690486, 0.557221],
[0.657424, 0.694395, 0.563189],
[0.662171, 0.698315, 0.569167],
[0.666931, 0.702245, 0.575154],
[0.671703, 0.706187, 0.58115],
[0.676488, 0.710139, 0.587155],
[0.681286, 0.714102, 0.593169],
[0.686096, 0.718077, 0.599193],
[0.69092, 0.722064, 0.605227],
[0.695757, 0.726062, 0.611269],
[0.700606, 0.730072, 0.617322],
[0.705469, 0.734094, 0.623383],
[0.710346, 0.738129, 0.629455],
[0.715235, 0.742175, 0.635536],
[0.720138, 0.746234, 0.641627],
[0.725054, 0.750305, 0.647727],
[0.729984, 0.75439, 0.653837],
[0.734928, 0.758487, 0.659957],
[0.739885, 0.762597, 0.666087],
[0.744856, 0.766721, 0.672227],
[0.749842, 0.770857, 0.678377],
[0.754841, 0.775008, 0.684537],
[0.759854, 0.779172, 0.690706],
[0.764881, 0.78335, 0.696886],
[0.769922, 0.787542, 0.703076],
[0.774978, 0.791748, 0.709276],
[0.780048, 0.795969, 0.715486],
[0.785132, 0.800204, 0.721706],
[0.790231, 0.804454, 0.727936],
[0.795345, 0.808718, 0.734176],
[0.800473, 0.812998, 0.740427],
[0.805617, 0.817293, 0.746688],
[0.810775, 0.821604, 0.752959],
[0.815948, 0.82593, 0.75924],
[0.821136, 0.830271, 0.765531],
[0.826339, 0.834629, 0.771832],
[0.831557, 0.839003, 0.778144],
[0.836791, 0.843393, 0.784465],
[0.84204, 0.8478, 0.790797],
[0.847304, 0.852223, 0.797138],
[0.852584, 0.856663, 0.80349],
[0.85788, 0.861121, 0.809852],
[0.863191, 0.865595, 0.816223],
[0.868518, 0.870087, 0.822605],
[0.873861, 0.874597, 0.828995],
[0.879219, 0.879125, 0.835396],
[0.884594, 0.883671, 0.841806],
[0.889985, 0.888236, 0.848225],
[0.895391, 0.892819, 0.854654],
[0.900814, 0.897421, 0.861091],
[0.906253, 0.902042, 0.867538],
[0.911708, 0.906682, 0.873992],
[0.917179, 0.911342, 0.880455],
[0.922667, 0.916022, 0.886926],
[0.92817, 0.920722, 0.893404],
[0.93369, 0.925443, 0.899889],
[0.939226, 0.930184, 0.906381],
[0.944778, 0.934947, 0.912878],
[0.950346, 0.939731, 0.919381],
[0.95593, 0.944538, 0.925888],
[0.961529, 0.949367, 0.932397],
[0.967144, 0.954218, 0.938909],
[0.972774, 0.959094, 0.94542],
[0.978418, 0.963993, 0.951929],
[0.984076, 0.968918, 0.958433],
[0.989747, 0.973869, 0.964927],
[0.995429, 0.978848, 0.971405],
[1., 0.983857, 0.977857],
[1., 0.988902, 0.984261],
[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()
