From a76a8e2ed27853c0b120ed29005c6c5e2309d733 Mon Sep 17 00:00:00 2001
From: Eva Schiffer <evas@ssec.wisc.edu>
Date: Wed, 6 Oct 2021 16:37:18 -0500
Subject: [PATCH] less eye searing colormaps for the gui

---
 pyglance/glance/gui_constants.py     | 10 ----------
 pyglance/glance/gui_figuremanager.py | 21 +++++++++++++--------
 pyglance/glance/gui_model.py         |  3 ++-
 3 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/pyglance/glance/gui_constants.py b/pyglance/glance/gui_constants.py
index 26dfa9d..e106516 100644
--- a/pyglance/glance/gui_constants.py
+++ b/pyglance/glance/gui_constants.py
@@ -81,16 +81,6 @@ GREEN_VAR_NAME   = "green"
 BLUE_VAR_NAME    = "blue"
 ALPHA_VAR_NAME   = "alpha"
 
-# colormaps that are available in the GUI
-# TODO, this needs to be upkept when the list of colormaps in the figure manager changes
-CM_RAINBOW       = "Rainbow"
-CM_RAINBOW_REV   = "Rainbow, Reverse"
-CM_RAINBOW_DESAT = "Rainbow, Desaturated"
-CM_GRAY          = "Grayscale"
-CM_GRAY_REV      = "Grayscale, Reverse"
-CM_SPECTRAL      = "Rainbow2"
-COLORMAP_NAMES   = [CM_RAINBOW, CM_RAINBOW_REV, CM_RAINBOW_DESAT, CM_GRAY, CM_GRAY_REV, CM_SPECTRAL]
-
 NO_DATA_MESSAGE   = "Requested data was not available or did not exist."
 UNKNOWN_DATA_FORM = "An ununsupported plot format was requested. Aborting attempt to plot data."
 
diff --git a/pyglance/glance/gui_figuremanager.py b/pyglance/glance/gui_figuremanager.py
index 23f0f6b..f4114f7 100644
--- a/pyglance/glance/gui_figuremanager.py
+++ b/pyglance/glance/gui_figuremanager.py
@@ -33,16 +33,21 @@ temp_dict = {'blue': [(0.0, 0.58333333333333326, 0.58333333333333326), (0.11, 0.
 DESAT_MAP = matplotlib.colors.LinearSegmentedColormap('colormap', temp_dict, 1024)
 
 # colormaps that are available in the GUI
-# if this changes the list of colormap names in the constants module needs to be kept up
-temp_spectral = cm.spectral if hasattr(cm, 'spectral') else cm.Spectral  # newer matplotlib changed the name of this color map
+temp_spectral  = cm.spectral   if hasattr(cm, 'spectral')   else cm.Spectral  # newer matplotlib changed the name of this color map
+temp_rspectral = cm.spectral_r if hasattr(cm, 'spectral_r') else cm.Spectral_r
 AVAILABLE_COLORMAPS = {
-                       CM_RAINBOW:       cm.jet,
-                       CM_RAINBOW_REV:   cm.jet_r,
-                       CM_RAINBOW_DESAT: DESAT_MAP,
-                       CM_GRAY:          cm.bone,
-                       CM_GRAY_REV:      cm.bone_r,
-                       CM_SPECTRAL:      temp_spectral,
+                            "Viridis":                     cm.viridis,
+                            "Cividis":                     cm.cividis,
+                            "Plasma":                      cm.plasma,
+                            "Ocean":                       cm.ocean,
+                            "Spectral Rainbow":            temp_spectral,
+                            "Spectral Rainbow, Reverse":   temp_rspectral,
+                            "Grayscale":                   cm.bone,
+                            "Grayscale, Reverse":          cm.bone_r,
+
                        }
+# note: we expect other modules to reference the COLORMAP_NAMES
+COLORMAP_NAMES      = list(AVAILABLE_COLORMAPS.keys())
 
 # whether or not the plot can be drawn on a map
 CAN_BE_MAPPED = {
diff --git a/pyglance/glance/gui_model.py b/pyglance/glance/gui_model.py
index 7afbc28..8146e60 100644
--- a/pyglance/glance/gui_model.py
+++ b/pyglance/glance/gui_model.py
@@ -13,7 +13,8 @@ from   os import path
 
 import glance.data as dataobjects
 import glance.io   as io
-from   glance.gui_constants import *
+from   glance.gui_constants     import *
+from   glance.gui_figuremanager import COLORMAP_NAMES
 
 LOG = logging.getLogger(__name__)
 
-- 
GitLab