
from matplotlib.colors import ListedColormap
from numpy import nan, inf

# Used to reconstruct the colormap in pycam02ucs.cm.viscm
parameters = {'xp': [16.121891585344997, 33.901145962549492, 5.5873058066040926, -14.703203914141397, -17.875928056390336, -5.3288735306278738],
              'yp': [-2.5423728813559308, -13.425925925925895, -42.422027290448327, -35.333333333333314, -8.83264462809916, -2.1686159844054487],
              'min_Jp': 15.0,
              'max_Jp': 95.0}

cm_data = [[ 0.21298394, 0.05589169, 0.14220951],
           [ 0.21780744, 0.0570005 , 0.14665582],
           [ 0.22261214, 0.05808842, 0.15115908],
           [ 0.22739756, 0.05915624, 0.15572185],
           [ 0.23216536, 0.06020099, 0.16034977],
           [ 0.23691745, 0.06121879, 0.1650498 ],
           [ 0.24164654, 0.06222163, 0.169816  ],
           [ 0.24635153, 0.06321115, 0.17465056],
           [ 0.25103114, 0.06418929, 0.1795555 ],
           [ 0.25568737, 0.06515168, 0.1845388 ],
           [ 0.26031556, 0.06610638, 0.18959733],
           [ 0.26491272, 0.06705861, 0.19473015],
           [ 0.26947709, 0.0680114 , 0.19993831],
           [ 0.27400681, 0.06896804, 0.20522255],
           [ 0.27849993, 0.06993211, 0.21058327],
           [ 0.28295501, 0.07090603, 0.21602205],
           [ 0.28737014, 0.0718934 , 0.22153921],
           [ 0.29174204, 0.07290112, 0.22713094],
           [ 0.29606871, 0.07393344, 0.23279613],
           [ 0.30034822, 0.07499465, 0.23853326],
           [ 0.30457867, 0.07608911, 0.24434046],
           [ 0.30875826, 0.07722111, 0.25021549],
           [ 0.31288529, 0.0783949 , 0.25615575],
           [ 0.3169582 , 0.07961456, 0.26215837],
           [ 0.32097556, 0.08088399, 0.26822019],
           [ 0.32493609, 0.08220684, 0.27433782],
           [ 0.3288387 , 0.08358647, 0.28050768],
           [ 0.33268245, 0.08502593, 0.28672608],
           [ 0.33646657, 0.08652789, 0.2929892 ],
           [ 0.34019047, 0.08809468, 0.29929318],
           [ 0.34385372, 0.08972821, 0.30563417],
           [ 0.34745604, 0.09143006, 0.31200825],
           [ 0.35099729, 0.0932014 , 0.31841152],
           [ 0.35447749, 0.09504303, 0.32484029],
           [ 0.35789677, 0.09695535, 0.33129096],
           [ 0.36125536, 0.09893846, 0.33776007],
           [ 0.36455362, 0.10099212, 0.34424427],
           [ 0.36779195, 0.10311585, 0.35074041],
           [ 0.37097085, 0.10530889, 0.35724546],
           [ 0.37409088, 0.10757029, 0.36375657],
           [ 0.37715263, 0.10989888, 0.37027108],
           [ 0.38015674, 0.11229336, 0.37678646],
           [ 0.38310387, 0.11475229, 0.38330035],
           [ 0.38599472, 0.11727411, 0.38981058],
           [ 0.38882999, 0.1198572 , 0.3963151 ],
           [ 0.39161037, 0.12249987, 0.402812  ],
           [ 0.3943366 , 0.12520039, 0.40929955],
           [ 0.39700936, 0.12795703, 0.41577611],
           [ 0.39962936, 0.13076802, 0.42224018],
           [ 0.40219729, 0.13363161, 0.42869038],
           [ 0.40471394, 0.13654614, 0.43512488],
           [ 0.40717995, 0.13950986, 0.44154258],
           [ 0.4095959 , 0.14252107, 0.44794287],
           [ 0.41196239, 0.14557814, 0.45432475],
           [ 0.41428002, 0.1486795 , 0.4606873 ],
           [ 0.41654936, 0.15182361, 0.46702967],
           [ 0.41877098, 0.15500903, 0.47335108],
           [ 0.4209454 , 0.15823432, 0.4796508 ],
           [ 0.42307313, 0.16149814, 0.48592814],
           [ 0.42515465, 0.16479918, 0.49218247],
           [ 0.42719043, 0.1681362 , 0.49841321],
           [ 0.42918111, 0.17150798, 0.50461925],
           [ 0.431127  , 0.17491341, 0.5108004 ],
           [ 0.43302838, 0.17835141, 0.5169565 ],
           [ 0.43488561, 0.18182099, 0.52308708],
           [ 0.43669905, 0.18532117, 0.5291917 ],
           [ 0.43846903, 0.18885105, 0.53526994],
           [ 0.44019583, 0.19240976, 0.54132138],
           [ 0.44187976, 0.19599648, 0.54734563],
           [ 0.44352106, 0.19961045, 0.5533423 ],
           [ 0.44512012, 0.2032509 , 0.55931077],
           [ 0.44667705, 0.20691717, 0.56525088],
           [ 0.44819199, 0.21060865, 0.57116243],
           [ 0.44966511, 0.21432473, 0.57704502],
           [ 0.45109659, 0.21806485, 0.58289828],
           [ 0.45248658, 0.22182847, 0.58872183],
           [ 0.45383521, 0.2256151 , 0.59451528],
           [ 0.45514261, 0.22942427, 0.60027826],
           [ 0.45640887, 0.23325554, 0.60601037],
           [ 0.45763398, 0.23710854, 0.61171135],
           [ 0.45881803, 0.24098289, 0.61738074],
           [ 0.4599611 , 0.24487823, 0.62301809],
           [ 0.46106323, 0.24879421, 0.62862296],
           [ 0.46212445, 0.25273054, 0.63419487],
           [ 0.46314479, 0.25668693, 0.63973335],
           [ 0.46412426, 0.2606631 , 0.6452379 ],
           [ 0.46506286, 0.2646588 , 0.650708  ],
           [ 0.46596031, 0.26867393, 0.65614343],
           [ 0.46681665, 0.27270825, 0.66154354],
           [ 0.467632  , 0.27676148, 0.66690758],
           [ 0.46840632, 0.28083345, 0.67223496],
           [ 0.46913959, 0.28492398, 0.67752502],
           [ 0.46983176, 0.28903289, 0.68277713],
           [ 0.47048281, 0.29316004, 0.68799058],
           [ 0.4710927 , 0.29730529, 0.69316468],
           [ 0.47166137, 0.30146848, 0.69829868],
           [ 0.47218867, 0.30564956, 0.70339194],
           [ 0.47267406, 0.30984863, 0.70844403],
           [ 0.47311806, 0.3140653 , 0.71345366],
           [ 0.47352067, 0.31829946, 0.71841996],
           [ 0.47388188, 0.322551  , 0.72334205],
           [ 0.47420168, 0.32681981, 0.728219  ],
           [ 0.47448009, 0.33110575, 0.73304987],
           [ 0.47471715, 0.33540873, 0.73783366],
           [ 0.4749129 , 0.33972863, 0.74256938],
           [ 0.47506742, 0.34406531, 0.74725597],
           [ 0.4751808 , 0.34841867, 0.75189235],
           [ 0.47525316, 0.35278857, 0.75647742],
           [ 0.47528466, 0.35717487, 0.76101004],
           [ 0.47527514, 0.36157758, 0.76548918],
           [ 0.47522479, 0.36599656, 0.76991363],
           [ 0.47513427, 0.37043147, 0.77428199],
           [ 0.47500393, 0.37488213, 0.77859297],
           [ 0.47483412, 0.37934834, 0.7828453 ],
           [ 0.4746253 , 0.38382989, 0.78703766],
           [ 0.47437795, 0.38832654, 0.7911687 ],
           [ 0.47409263, 0.39283807, 0.79523708],
           [ 0.47376999, 0.39736419, 0.79924139],
           [ 0.47341074, 0.40190463, 0.80318024],
           [ 0.47301567, 0.40645908, 0.80705223],
           [ 0.47258566, 0.41102721, 0.81085591],
           [ 0.47212171, 0.41560865, 0.81458986],
           [ 0.4716249 , 0.42020304, 0.81825263],