gui_default error with many of the GeoCAT sample programs
mbranson opened this issue · comments
Here's the error I'm getting trying to run NCL_panel_5.py, but it happens with many of the other scripts in the Panels subdir. And I did do a conda update yesterday.
/Users/mark/geocat/GeoCAT-examples/Gallery/Panels> python NCL_panel_5.py
/Users/mark/opt/anaconda3/envs/geocat/lib/python3.10/site-packages/geocat/viz/cmaps.py:9: DeprecationWarning: geocat.viz.cmaps is deprecated, use cmaps instead
warnings.warn("geocat.viz.cmaps is deprecated, use cmaps instead",
Traceback (most recent call last):
File "/Users/mark/geocat/GeoCAT-examples/Gallery/Panels/NCL_panel_5.py", line 137, in
plot_labelled_filled_contours(ds.V, ax=ax[1], label='b)')
File "/Users/mark/geocat/GeoCAT-examples/Gallery/Panels/NCL_panel_5.py", line 52, in plot_labelled_filled_contours
newcmp = gv.truncate_colormap(cmaps.gui_default, minval=0.03, maxval=0.9)
File "/Users/mark/opt/anaconda3/envs/geocat/lib/python3.10/site-packages/cmaps/cmaps.py", line 5328, in gui_default
matplotlib.cm.register_cmap(name=cname, cmap=cmap)
File "/Users/mark/opt/anaconda3/envs/geocat/lib/python3.10/site-packages/matplotlib/_api/deprecation.py", line 200, in wrapper
return func(*args, **kwargs)
File "/Users/mark/opt/anaconda3/envs/geocat/lib/python3.10/site-packages/matplotlib/cm.py", line 274, in register_cmap
_colormaps.register(cmap, name=name, force=override_builtin)
File "/Users/mark/opt/anaconda3/envs/geocat/lib/python3.10/site-packages/matplotlib/cm.py", line 143, in register
raise ValueError(
ValueError: A colormap named "gui_default" is already registered.
Looking into it.
Working on a fix now.
Ok there were a few approaches to fixing this. And the one I picked was to add override_builtin=True
on line 550 of geocat-viz.util.py for the cm.register_cmap
call.
This should prevent the ValueError on the duplicate name for the cmap registry, but it may cause a bug if the truncated maps stack as they get used.
Where would I find geocat-viz.util.py? It doesn't seem to show up anywhere on my machine (Mac desktop).
It looks like you're running into this issue hhuangwx/cmaps#6 and/or the related one here NCAR/geocat-viz#112. We're working on fixes in GeoCAT-viz right now, but rolling back to an older version of matplotlib (<v3.5) should also address the issue for the time being. A matplotlib version <v3.6 should work as well in most cases.
Sorry for the delayed response.
This should be addressed with the new cmaps release and NCAR/geocat-viz#125.