[Yt-svn] yt-commit r469 - in trunk/yt: raven reason

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Tue May 13 18:10:49 PDT 2008


Author: mturk
Date: Tue May 13 18:10:48 2008
New Revision: 469
URL: http://yt.spacepope.org/changeset/469

Log:
Added new colormap from Britton, as well as the ability to add them yourself.
Keep in mind that they might not show up in reason if you add them *on the
fly*.  I'm working on a plugin for new colormaps on a user-by-user basis.  I
will also be importing the Kamae colormap.



Added:
   trunk/yt/raven/ColorMaps.py
Modified:
   trunk/yt/raven/__init__.py
   trunk/yt/reason/Notebook.py
   trunk/yt/reason/__init__.py

Added: trunk/yt/raven/ColorMaps.py
==============================================================================
--- (empty file)
+++ trunk/yt/raven/ColorMaps.py	Tue May 13 18:10:48 2008
@@ -0,0 +1,59 @@
+"""
+ at author: Britton Smith, Matthew Turk
+ at organization: UC Boulder, KIPAC
+ at contact: brittonsmith at gmail.com, mturk at slac.stanford.edu
+ at license:
+  Copyright (C) 2008 Britton Smith, Matthew Turk  All Rights Reserved.
+
+  This file is part of yt.
+
+  yt is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+"""
+
+import matplotlib.colors as cc
+
+raven_colormaps = {}
+
+def add_cmap(name, cdict):
+    raven_colormaps[name] = \
+        cc.LinearSegmentedColormap(name,cdict,256)
+
+# The format is as follows:
+#   First number is the number at which we are defining a color breakpoint
+#   Second number is the (0..1) number to interpolate to when coming *from below*
+#   Third number is the (0..1) number to interpolate to when coming *from above*
+
+# Next up is boilerplate -- the name, the colormap dict we just made, and the
+# number of segments we want.  This is probably fine as is.
+
+cdict = {'red':   ((0.0, 80/256., 80/256.),
+                   (0.2, 0.0, 0.0),
+                   (0.4, 0.0, 0.0),
+                   (0.6, 256/256., 256/256.),
+                   (0.8, 200/256., 200/256.),
+                   (1.0, 230/256., 230/256.)),
+         'green': ((0.0, 0/256., 0/256.),
+                   (0.2, 0/256., 0/256.),
+                   (0.4, 130/256., 130/256.),
+                   (0.6, 256/256., 256/256.),
+                   (0.8, 100/256., 100/256.),
+                   (1.0, 0.0, 0.0)),
+         'blue':  ((0.0, 80/256., 80/256.),
+                   (0.2, 220/256., 220/256.),
+                   (0.4, 0.0, 0.0),
+                   (0.6, 20/256., 20/256.),
+                   (0.8, 0/256., 0/256.),
+                   (1.0, 0.0, 0.0))}
+
+add_cmap('bds_highcontrast', cdict)

Modified: trunk/yt/raven/__init__.py
==============================================================================
--- trunk/yt/raven/__init__.py	(original)
+++ trunk/yt/raven/__init__.py	Tue May 13 18:10:48 2008
@@ -46,12 +46,12 @@
 
 vm_axis_names = {0:'x', 1:'y', 2:'z', 3:'dx', 4:'dy'}
 
-raven_colormaps = {}
+from ColorMaps import raven_colormaps, add_cmap
 
 import PlotTypes
 import PlotTypes as be
 
-color_maps = PlotTypes.matplotlib.cm.cmapnames
+color_maps = PlotTypes.matplotlib.cm.cmapnames + raven_colormaps.keys()
 
 from PlotCollection import *
 from PlotConfig import *

Modified: trunk/yt/reason/Notebook.py
==============================================================================
--- trunk/yt/reason/Notebook.py	(original)
+++ trunk/yt/reason/Notebook.py	Tue May 13 18:10:48 2008
@@ -270,8 +270,7 @@
         self.cmapmenu = wx.Menu()
         self.editprops = wx.Menu()
         self.popupmenu.AppendMenu(-1, "Color Map", self.cmapmenu)
-        cmapnames = be.matplotlib.cm.cmapnames
-        cmapnames.sort()
+        cmapnames = sorted(color_maps)
         for cmap in cmapnames:
             item = self.cmapmenu.AppendRadioItem(-1, cmap)
             self.Bind(wx.EVT_MENU, self.OnColorMapChoice, item)

Modified: trunk/yt/reason/__init__.py
==============================================================================
--- trunk/yt/reason/__init__.py	(original)
+++ trunk/yt/reason/__init__.py	Tue May 13 18:10:48 2008
@@ -39,7 +39,7 @@
 import os, types, Toolbars
 
 #import yt.raven.backends.MPL as be
-from yt.raven import be
+from yt.raven import be, color_maps
 from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
 from matplotlib.backends.backend_agg import FigureCanvasAgg
 import wx, wx.py, wx.aui



More information about the yt-svn mailing list