[Yt-svn] yt-commit r631 - in trunk/yt: lagos raven

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Fri Jun 27 12:44:24 PDT 2008


Author: mturk
Date: Fri Jun 27 12:44:23 2008
New Revision: 631
URL: http://yt.spacepope.org/changeset/631

Log:
Added an _antialias property to VMPlot objects, to control whether or not the
plotting layer attempts to antialias.  Useful for things like IDs, or fields
that aren't defined everywhere.



Modified:
   trunk/yt/lagos/DerivedFields.py
   trunk/yt/raven/PlotTypes.py
   trunk/yt/raven/_MPL.c

Modified: trunk/yt/lagos/DerivedFields.py
==============================================================================
--- trunk/yt/lagos/DerivedFields.py	(original)
+++ trunk/yt/lagos/DerivedFields.py	Fri Jun 27 12:44:23 2008
@@ -381,6 +381,11 @@
                       ValidateSpatial(0)],
           not_in_all = True)
 
+add_field("Dark_Matter_Density", function=lambda a,b: None,
+          validators=[ValidateDataField("Dark_Matter_Density"),
+                      ValidateSpatial(0)],
+          not_in_all = True)
+
 def _ParticleMass(field, data):
     particles = data["particle_mass"].astype('float64') * \
                 just_one(data["CellVolumeCode"].ravel())

Modified: trunk/yt/raven/PlotTypes.py
==============================================================================
--- trunk/yt/raven/PlotTypes.py	(original)
+++ trunk/yt/raven/PlotTypes.py	Fri Jun 27 12:44:23 2008
@@ -194,6 +194,7 @@
         if self.colorbar != None: self.colorbar.set_label(str(label))
 
 class VMPlot(RavenPlot):
+    _antialias = True
     def __init__(self, data, field, figure = None, axes = None,
                  use_colorbar = True, size=None):
         fields = ['X', 'Y', field, 'X width', 'Y width']
@@ -260,13 +261,14 @@
         self.pix = (width,height)
         # 'px' == pixel x, or x in the plane of the slice
         # 'x' == actual x
+        aa = int(self._antialias)
         buff = _MPL.Pixelize(self.data['px'],
                             self.data['py'],
                             self.data['pdx'],
                             self.data['pdy'],
                             self[self.axis_names["Z"]],
                             int(width), int(width),
-                        (x0, x1, y0, y1),).transpose()
+                            (x0, x1, y0, y1),aa).transpose()
         return buff
 
     def _redraw_image(self, *args):

Modified: trunk/yt/raven/_MPL.c
==============================================================================
--- trunk/yt/raven/_MPL.c	(original)
+++ trunk/yt/raven/_MPL.c	Fri Jun 27 12:44:23 2008
@@ -53,11 +53,12 @@
 
   PyObject *xp, *yp, *dxp, *dyp, *dp;
   unsigned int rows, cols;
+  int antialias = 1;
   double x_min, x_max, y_min, y_max;
 
-    if (!PyArg_ParseTuple(args, "OOOOOII(dddd)",
+    if (!PyArg_ParseTuple(args, "OOOOOII(dddd)|i",
         &xp, &yp, &dxp, &dyp, &dp, &cols, &rows,
-        &x_min, &x_max, &y_min, &y_max))
+        &x_min, &x_max, &y_min, &y_max, &antialias))
         return PyErr_Format(_pixelizeError, "Pixelize: Invalid Parameters.");
 
   double width = x_max - x_min;
@@ -146,7 +147,8 @@
         rxpx = px_dx * (j+1) + x_min;
         overlap1 = ((min(rxpx, xs[p]+dxs[p]) - max(lxpx, (xs[p]-dxs[p])))/px_dx);
         if (overlap1 < 0.0 || overlap2 < 0.0) continue;
-        gridded[j*cols+i] += (ds[p]*overlap1)*(overlap2);
+        if (antialias == 1) gridded[j*cols+i] += (ds[p]*overlap1)*overlap2;
+        else gridded[j*cols+i] = ds[p];
       }
     }
   }



More information about the yt-svn mailing list