[Yt-svn] yt-commit r780 - in trunk/yt: . fido raven

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Tue Sep 16 13:11:08 PDT 2008


Author: mturk
Date: Tue Sep 16 13:11:07 2008
New Revision: 780
URL: http://yt.spacepope.org/changeset/780

Log:
OutputWatcher now returns basenames in a sorted fashion.

Added new delaunay triangulation-based natural neighbor interpolated slice.  I
don't like it, or the way it looks.  But it's not terrible.

Made sure that colormaps generated inside YT get added to the base matplotlib
colormap list.  This requires a tiny bit of monkey patching.

...that being said, we can now set default colormaps.

~/.yt/config

section: [raven]
key: colormap

So now you can do:

[raven]
colormap: bds_highcontrast

and get that as your default colormap.



Modified:
   trunk/yt/config.py
   trunk/yt/fido/OutputWatcher.py
   trunk/yt/raven/ColorMaps.py
   trunk/yt/raven/PlotCollection.py
   trunk/yt/raven/PlotTypes.py
   trunk/yt/raven/__init__.py

Modified: trunk/yt/config.py
==============================================================================
--- trunk/yt/config.py	(original)
+++ trunk/yt/config.py	Tue Sep 16 13:11:07 2008
@@ -68,7 +68,8 @@
     "raven":{
         'ImagePath':".",
         'ImageSkel': '%(bn)s_%(width)010i_%(unit)s',
-        'backend': 'MPL'
+        'backend': 'MPL',
+        'colormap': 'jet',
         }
     }
 

Modified: trunk/yt/fido/OutputWatcher.py
==============================================================================
--- trunk/yt/fido/OutputWatcher.py	(original)
+++ trunk/yt/fido/OutputWatcher.py	Tue Sep 16 13:11:07 2008
@@ -46,7 +46,7 @@
         wb = ytcfg.getfloat("fido","WaitBetween")
         while not self.check_for_stop():
             nn = self.check_for_output()
-            for bn in nn:
+            for bn in sorted(nn):
                 new_name = bury_output(bn, new_prefix=self.new_prefix)
                 self.handle_output(new_name)
             if run_once: break

Modified: trunk/yt/raven/ColorMaps.py
==============================================================================
--- trunk/yt/raven/ColorMaps.py	(original)
+++ trunk/yt/raven/ColorMaps.py	Tue Sep 16 13:11:07 2008
@@ -24,12 +24,16 @@
 
 from yt.raven import *
 import matplotlib.colors as cc
+import matplotlib.cm as mcm
 
 raven_colormaps = {}
 
 def add_cmap(name, cdict):
     raven_colormaps[name] = \
         cc.LinearSegmentedColormap(name,cdict,256)
+    mcm.datad[name] = cdict
+    mcm.__dict__[name] = cdict
+    
 
 # The format is as follows:
 #   First number is the number at which we are defining a color breakpoint

Modified: trunk/yt/raven/PlotCollection.py
==============================================================================
--- trunk/yt/raven/PlotCollection.py	(original)
+++ trunk/yt/raven/PlotCollection.py	Tue Sep 16 13:11:07 2008
@@ -150,7 +150,13 @@
         self.plots.append(plot)
         return plot
 
-    def add_slice(self, field, axis, coord=None, center=None,
+    def add_slice(self, *args, **kwargs):
+        return self.__add_slice(PlotTypes.SlicePlot, *args, **kwargs)
+
+    def add_slice_interpolated(self, *args, **kwargs):
+        return self.__add_slice(PlotTypes.SlicePlotNaturalNeighbor, *args, **kwargs)
+
+    def __add_slice(self, ptype, field, axis, coord=None, center=None,
                  use_colorbar=True, figure = None, axes = None, fig_size=None,
                  periodic = False):
         """
@@ -166,7 +172,7 @@
         if coord == None:
             coord = center[axis]
         slice = self.pf.hierarchy.slice(axis, coord, field, center)
-        p = self._add_plot(PlotTypes.SlicePlot(slice, field, use_colorbar=use_colorbar,
+        p = self._add_plot(ptype(slice, field, use_colorbar=use_colorbar,
                          axes=axes, figure=figure,
                          size=fig_size, periodic=periodic))
         mylog.info("Added slice of %s at %s = %s with 'center' = %s", field,
@@ -368,6 +374,7 @@
 
 class PlotCollectionInteractive(PlotCollection):
     add_slice = wrap_pylab_newplot(PlotCollection.add_slice)
+    add_slice_interpolated = wrap_pylab_newplot(PlotCollection.add_slice_interpolated)
     add_cutting_plane = wrap_pylab_newplot(PlotCollection.add_cutting_plane)
     add_projection = wrap_pylab_newplot(PlotCollection.add_projection)
     add_profile_object = wrap_pylab_newplot(PlotCollection.add_profile_object)

Modified: trunk/yt/raven/PlotTypes.py
==============================================================================
--- trunk/yt/raven/PlotTypes.py	(original)
+++ trunk/yt/raven/PlotTypes.py	Tue Sep 16 13:11:07 2008
@@ -397,6 +397,8 @@
     def selfSetup(self):
         pass
 
+    
+
 class SlicePlot(VMPlot):
     _type_name = "Slice"
 
@@ -411,6 +413,36 @@
         data_label += r"$"
         if self.colorbar != None: self.colorbar.set_label(str(data_label))
 
+class SlicePlotNaturalNeighbor(SlicePlot):
+    
+    def _get_buff(self, width=None):
+        import delaunay as de
+        x0, x1 = self.xlim
+        y0, y1 = self.ylim
+        if width is None:
+            l, b, width, height = _get_bounds(self._axes.bbox)
+        else:
+            height = width
+        self.pix = (width,height)
+        numPoints_x = int(width)
+        numPoints_y = int(width)
+        dx = numPoints_x / (x1-x0)
+        dy = numPoints_y / (y1-y0)
+        xlim = na.logical_and(self.data["px"]+2.0*self.data['pdx'] >= x0,
+                              self.data["px"]-2.0*self.data['pdx'] <= x1)
+        ylim = na.logical_and(self.data["py"]+2.0*self.data['pdy'] >= y0,
+                              self.data["py"]-2.0*self.data['pdy'] <= y1)
+        wI = na.where(na.logical_and(xlim,ylim))
+        xi, yi = na.mgrid[0:numPoints_x, 0:numPoints_y]
+        x = (self.data["px"][wI]-x0)*dx
+        y = (self.data["py"][wI]-y0)*dy
+        z = self.data[self.axis_names["Z"]][wI]
+        if self.log_field: z=na.log10(z)
+        buff = de.Triangulation(x,y).nn_interpolator(z)(xi,yi)
+        buff = buff.clip(z.min(), z.max())
+        if self.log_field: buff = 10**buff
+        return buff.transpose()
+
 class ProjectionPlot(VMPlot):
 
     _type_name = "Projection"

Modified: trunk/yt/raven/__init__.py
==============================================================================
--- trunk/yt/raven/__init__.py	(original)
+++ trunk/yt/raven/__init__.py	Tue Sep 16 13:11:07 2008
@@ -63,6 +63,10 @@
 from Callbacks import *
 
 color_maps = matplotlib.cm.cmapnames + raven_colormaps.keys()
+default_cmap = ytcfg.get("raven", "colormap")
+if default_cmap != "jet":
+    mylog.info("Setting default colormap to %s", default_cmap)
+    matplotlib.rc('image', cmap=default_cmap)
 
 from PlotCollection import *
 try:



More information about the yt-svn mailing list