from matplotlib.colors import LinearSegmentedColormap
from numpy import nan, inf
cm_data = [[0.0000208612, 0.0000200049, 0.0000198463],
[0.000301962, 0.000367317, 0.000377812],
[0.000812973, 0.00106962, 0.00110854],
[0.00149832, 0.00209602, 0.00218056],
[0.00232303, 0.0034337, 0.00357897],
[0.00326047, 0.00507622, 0.00529404],
[0.00428851, 0.00702047, 0.00731824],
[0.0053879, 0.00926532, 0.00964509],
[0.00654141, 0.011811, 0.0122686],
[0.00773326, 0.0146586, 0.0151828],
[0.00894885, 0.0178101, 0.0183817],
[0.0101745, 0.0212678, 0.0218592],
[0.0113974, 0.0250345, 0.0256087],
[0.0126054, 0.0291135, 0.0296234],
[0.013787, 0.033508, 0.0338961],
[0.0149312, 0.0382218, 0.0384191],
[0.0160276, 0.0431575, 0.0430871],
[0.0170664, 0.0480565, 0.0476673],
[0.0180382, 0.052924, 0.0521661],
[0.0189343, 0.0577633, 0.056585],
[0.0197462, 0.0625776, 0.0609255],
[0.0204663, 0.0673695, 0.0651886],
[0.0210871, 0.0721412, 0.0693751],
[0.021602, 0.0768946, 0.0734853],
[0.0220047, 0.0816317, 0.0775196],
[0.0222896, 0.0863538, 0.0814782],
[0.0224515, 0.0910622, 0.0853609],
[0.0224859, 0.0957581, 0.0891679],
[0.0223889, 0.100443, 0.0928987],
[0.0221573, 0.105116, 0.0965531],
[0.0217882, 0.10978, 0.100131],
[0.0212798, 0.114434, 0.103631],
[0.0206305, 0.11908, 0.107054],
[0.0198398, 0.123717, 0.110399],
[0.0189076, 0.128345, 0.113665],
[0.0178346, 0.132966, 0.116852],
[0.0166222, 0.137579, 0.11996],
[0.0152728, 0.142185, 0.122987],
[0.0137891, 0.146782, 0.125934],
[0.0121749, 0.151372, 0.128799],
[0.0104346, 0.155954, 0.131583],
[0.00857354, 0.160529, 0.134285],
[0.00659775, 0.165095, 0.136904],
[0.0045141, 0.169653, 0.139439],
[0.00233025, 0.174202, 0.141892],
[0.0000547074, 0.178743, 0.144261],
[0., 0.183274, 0.146545],
[0., 0.187796, 0.148745],
[0., 0.192308, 0.150861],
[0., 0.19681, 0.152892],
[0., 0.201301, 0.154838],
[0., 0.205781, 0.156698],
[0., 0.210249, 0.158474],
[0., 0.214705, 0.160164],
[0., 0.219148, 0.161769],
[0., 0.223579, 0.163289],
[0., 0.227995, 0.164725],
[0., 0.232398, 0.166076],
[0., 0.236786, 0.167342],
[0., 0.241158, 0.168524],
[0., 0.245515, 0.169623],
[0., 0.249855, 0.170638],
[0., 0.254179, 0.171571],
[0., 0.258485, 0.172421],
[0., 0.262773, 0.17319],
[0., 0.267043, 0.173877],
[0., 0.271293, 0.174485],
[0., 0.275524, 0.175013],
[0., 0.279735, 0.175463],
[0., 0.283925, 0.175834],
[0., 0.288094, 0.176129],
[0., 0.292241, 0.176349],
[0., 0.296366, 0.176493],
[0., 0.300469, 0.176564],
[0., 0.304548, 0.176562],
[0., 0.308604, 0.17649],
[0., 0.312636, 0.176347],
[0., 0.316643, 0.176136],
[0., 0.320626, 0.175857],
[0., 0.324584, 0.175513],
[0., 0.328516, 0.175105],
[0., 0.332422, 0.174634],
[0.000379352, 0.336302, 0.174102],
[0.00833238, 0.340155, 0.173511],
[0.0170626, 0.343981, 0.172861],
[0.0265998, 0.34778, 0.172157],
[0.0369738, 0.351552, 0.171398],
[0.0476953, 0.355296, 0.170587],
[0.0577663, 0.359013, 0.169726],
[0.0673584, 0.362701, 0.168817],
[0.0765994, 0.366361, 0.167862],
[0.0855752, 0.369993, 0.166863],
[0.0943461, 0.373597, 0.165823],
[0.102956, 0.377171, 0.164744],
[0.111438, 0.380718, 0.163628],
[0.119818, 0.384235, 0.162477],
[0.128115, 0.387724, 0.161295],
[0.136344, 0.391184, 0.160084],
[0.144519, 0.394615, 0.158847],
[0.152649, 0.398017, 0.157586],
[0.160743, 0.401391, 0.156305],
[0.168807, 0.404736, 0.155006],
[0.176847, 0.408053, 0.153694],
[0.184867, 0.411342, 0.15237],
[0.192871, 0.414602, 0.15104],
[0.200862, 0.417834, 0.149705],
[0.208843, 0.421039, 0.148371],
[0.216816, 0.424216, 0.147041],
[0.224783, 0.427366, 0.145718],
[0.232744, 0.430488, 0.144408],
[0.2407, 0.433584, 0.143114],
[0.248654, 0.436653, 0.141841],
[0.256605, 0.439697, 0.140594],
[0.264553, 0.442714, 0.139378],
[0.272499, 0.445706, 0.138198],
[0.280443, 0.448674, 0.137059],
[0.288385, 0.451616, 0.135967],
[0.296324, 0.454535, 0.134927],
[0.304262, 0.45743, 0.133945],
[0.312196, 0.460302, 0.133027],
[0.320127, 0.463152, 0.132179],
[0.328054, 0.465979, 0.131408],
[0.335976, 0.468785, 0.130719],
[0.343894, 0.471571, 0.13012],
[0.351806, 0.474336, 0.129615],
[0.359712, 0.477081, 0.129213],
[0.367611, 0.479808, 0.12892],
[0.375502, 0.482516, 0.128741],
[0.383384, 0.485207, 0.128683],
[0.391257, 0.48788, 0.128753],
[0.399119, 0.490538, 0.128956],
[0.40697, 0.493181, 0.129297],
[0.414809, 0.495809, 0.129783],
[0.422634, 0.498423, 0.130418],
[0.430445, 0.501024, 0.131207],
[0.438241, 0.503613, 0.132154],
[0.446021, 0.506192, 0.133263],
[0.453784, 0.508759, 0.134537],
[0.461528, 0.511318, 0.13598],
[0.469252, 0.513868, 0.137594],
[0.476957, 0.51641, 0.13938],
[0.484639, 0.518946, 0.14134],
[0.492299, 0.521476, 0.143476],
[0.499935, 0.524002, 0.145787],
[0.507546, 0.526524, 0.148274],
[0.515131, 0.529043, 0.150936],
[0.522689, 0.531561, 0.153773],
[0.530218, 0.534079, 0.156783],
[0.537718, 0.536597, 0.159967],
[0.545187, 0.539117, 0.163321],
[0.552624, 0.541639, 0.166844],
[0.560028, 0.544166, 0.170534],
[0.567397, 0.546697, 0.17439],
[0.574731, 0.549235, 0.178408],
[0.582029, 0.55178, 0.182587],
[0.589288, 0.554334, 0.186925],
[0.596508, 0.556897, 0.191418],
[0.603688, 0.559472, 0.196065],
[0.610826, 0.562058, 0.200862],
[0.617921, 0.564657, 0.205809],
[0.624973, 0.567271, 0.210901],
[0.631979, 0.5699, 0.216137],
[0.638938, 0.572547, 0.221515],
[0.64585, 0.575211, 0.227032],
[0.652713, 0.577894, 0.232685],
[0.659526, 0.580598, 0.238474],
[0.666288, 0.583323, 0.244395],
[0.672997, 0.586071, 0.250446],
[0.679652, 0.588844, 0.256626],
[0.686253, 0.591641, 0.262932],
[0.692798, 0.594464, 0.269363],
[0.699285, 0.597316, 0.275915],
[0.705714, 0.600195, 0.282588],
[0.712084, 0.603105, 0.289379],
[0.718393, 0.606046, 0.296287],
[0.72464, 0.609018, 0.303308],
[0.730825, 0.612024, 0.310443],
[0.736945, 0.615064, 0.317687],
[0.743001, 0.61814, 0.32504],
[0.748991, 0.621252, 0.332499],
[0.754914, 0.624402, 0.340063],
[0.76077, 0.62759, 0.347729],
[0.766556, 0.630817, 0.355494],
[0.772272, 0.634085, 0.363358],
[0.777918, 0.637394, 0.371318],
[0.783493, 0.640746, 0.379371],
[0.788994, 0.644141, 0.387515],
[0.794423, 0.647579, 0.395747],
[0.799778, 0.651063, 0.404067],
[0.805058, 0.654593, 0.412469],
[0.810263, 0.658169, 0.420954],
[0.815392, 0.661792, 0.429516],
[0.820444, 0.665463, 0.438155],
[0.82542, 0.669183, 0.446867],
[0.830317, 0.672952, 0.455649],
[0.835137, 0.676771, 0.464498],
[0.839878, 0.68064, 0.473412],
[0.84454, 0.68456, 0.482388],
[0.849123, 0.688531, 0.491421],
[0.853627, 0.692554, 0.50051],
[0.858052, 0.69663, 0.50965],
[0.862397, 0.700758, 0.518839],
[0.866662, 0.704939, 0.528074],
[0.870848, 0.709173, 0.53735],
[0.874954, 0.71346, 0.546664],
[0.878982, 0.717801, 0.556014],
[0.88293, 0.722196, 0.565394],
[0.886799, 0.726644, 0.574802],
[0.89059, 0.731146, 0.584235],
[0.894304, 0.735703, 0.593687],
[0.89794, 0.740313, 0.603156],
[0.901499, 0.744977, 0.612638],
[0.904983, 0.749694, 0.62213],
[0.908392, 0.754465, 0.631626],
[0.911727, 0.759289, 0.641125],
[0.914989, 0.764167, 0.650621],
[0.918179, 0.769097, 0.660112],
[0.921298, 0.774079, 0.669593],
[0.924348, 0.779113, 0.67906],
[0.92733, 0.784199, 0.688511],
[0.930245, 0.789336, 0.697941],
[0.933096, 0.794524, 0.707347],
[0.935883, 0.799761, 0.716725],
[0.938609, 0.805048, 0.726071],
[0.941276, 0.810384, 0.735382],
[0.943886, 0.815767, 0.744655],
[0.94644, 0.821198, 0.753886],
[0.948942, 0.826675, 0.763072],
[0.951393, 0.832199, 0.772209],
[0.953797, 0.837767, 0.781295],
[0.956155, 0.843378, 0.790326],
[0.95847, 0.849033, 0.7993],
[0.960746, 0.85473, 0.808213],
[0.962986, 0.860468, 0.817063],
[0.965192, 0.866246, 0.825846],
[0.967369, 0.872063, 0.83456],
[0.969519, 0.877918, 0.843204],
[0.971645, 0.883809, 0.851773],
[0.973753, 0.889735, 0.860266],
[0.975846, 0.895695, 0.86868],
[0.977928, 0.901688, 0.877014],
[0.980003, 0.907712, 0.885265],
[0.982077, 0.913766, 0.893431],
[0.984154, 0.919847, 0.90151],
[0.986239, 0.925955, 0.9095],
[0.988339, 0.932088, 0.917399],
[0.990459, 0.938244, 0.925205],
[0.992607, 0.944419, 0.932916],
[0.99479, 0.950613, 0.940529],
[0.997017, 0.956821, 0.948042],
[0.9993, 0.963042, 0.95545],
[1., 0.969269, 0.96275],
[1., 0.975497, 0.969934],
[1., 0.981716, 0.97699],
[1., 0.987908, 0.983892],
[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()
