[Yt-svn] yt-commit r523 - in trunk/yt: lagos raven reason
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Tue Jun 3 11:15:17 PDT 2008
Author: mturk
Date: Tue Jun 3 11:15:07 2008
New Revision: 523
URL: http://yt.spacepope.org/changeset/523
Log:
Added support for overlaying velocities on top of cutting planes in reason.
Modified:
trunk/yt/lagos/BaseDataTypes.py
trunk/yt/lagos/DerivedFields.py
trunk/yt/raven/Callbacks.py
trunk/yt/reason/Notebook.py
Modified: trunk/yt/lagos/BaseDataTypes.py
==============================================================================
--- trunk/yt/lagos/BaseDataTypes.py (original)
+++ trunk/yt/lagos/BaseDataTypes.py Tue Jun 3 11:15:07 2008
@@ -606,6 +606,9 @@
self._y_vec /= na.sqrt(na.dot(self._y_vec, self._y_vec))
self._rot_mat = na.array([self._x_vec,self._y_vec,self._norm_vec])
self._inv_mat = na.linalg.pinv(self._rot_mat)
+ self.set_field_parameter('cp_x_vec',self._x_vec)
+ self.set_field_parameter('cp_y_vec',self._y_vec)
+ self.set_field_parameter('cp_z_vec',self._norm_vec)
self._refresh_data()
def _get_list_of_grids(self):
Modified: trunk/yt/lagos/DerivedFields.py
==============================================================================
--- trunk/yt/lagos/DerivedFields.py (original)
+++ trunk/yt/lagos/DerivedFields.py Tue Jun 3 11:15:07 2008
@@ -785,6 +785,31 @@
validators=[ValidateParameter("center"),
ValidateParameter("bulk_velocity")])
+def _CuttingPlaneVelocityX(field, data):
+ x_vec, y_vec, z_vec = [data.get_field_parameter("cp_%s_vec" % (ax))
+ for ax in 'xyz']
+ bulk_velocity = data.get_field_parameter("bulk_velocity")
+ if bulk_velocity == None:
+ bulk_velocity = na.zeros(3)
+ v_vec = na.array([data["%s-velocity" % ax] for ax in 'xyz']) \
+ - bulk_velocity[...,na.newaxis]
+ return na.dot(x_vec, v_vec)
+add_field("CuttingPlaneVelocityX",
+ validators=[ValidateParameter("cp_%s_vec" % ax)
+ for ax in 'xyz'], units=r"\rm{km}/\rm{s}")
+def _CuttingPlaneVelocityY(field, data):
+ x_vec, y_vec, z_vec = [data.get_field_parameter("cp_%s_vec" % (ax))
+ for ax in 'xyz']
+ bulk_velocity = data.get_field_parameter("bulk_velocity")
+ if bulk_velocity == None:
+ bulk_velocity = na.zeros(3)
+ v_vec = na.array([data["%s-velocity" % ax] for ax in 'xyz']) \
+ - bulk_velocity[...,na.newaxis]
+ return na.dot(y_vec, v_vec)
+add_field("CuttingPlaneVelocityY",
+ validators=[ValidateParameter("cp_%s_vec" % ax)
+ for ax in 'xyz'], units=r"\rm{km}/\rm{s}")
+
def _MeanMolecularWeight(field,data):
return (data["Density"] / (mh *data["NumberDensity"]))
add_field("MeanMolecularWeight",function=_MeanMolecularWeight,units=r"")
Modified: trunk/yt/raven/Callbacks.py
==============================================================================
--- trunk/yt/raven/Callbacks.py (original)
+++ trunk/yt/raven/Callbacks.py Tue Jun 3 11:15:07 2008
@@ -44,24 +44,24 @@
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
plot._axes.hold(True)
- numPoints_x = plot.image._A.shape[0] / self.factor
- numPoints_y = plot.image._A.shape[1] / self.factor
+ nx = plot.image._A.shape[0] / self.factor
+ ny = plot.image._A.shape[1] / self.factor
pixX = _MPL.Pixelize(plot.data['px'],
plot.data['py'],
plot.data['pdx'],
plot.data['pdy'],
plot.data[self.field_x],
- int(numPoints_x), int(numPoints_y),
+ int(nx), int(ny),
(x0, x1, y0, y1),).transpose()
pixY = _MPL.Pixelize(plot.data['px'],
plot.data['py'],
plot.data['pdx'],
plot.data['pdy'],
plot.data[self.field_y],
- int(numPoints_x), int(numPoints_y),
+ int(nx), int(ny),
(x0, x1, y0, y1),).transpose()
- X = na.mgrid[0:plot.image._A.shape[0]-1:numPoints_x*1j]# + 0.5*factor
- Y = na.mgrid[0:plot.image._A.shape[1]-1:numPoints_y*1j]# + 0.5*factor
+ X = na.mgrid[0:plot.image._A.shape[0]-1:nx*1j]# + 0.5*factor
+ Y = na.mgrid[0:plot.image._A.shape[1]-1:ny*1j]# + 0.5*factor
plot._axes.quiver(X,Y, pixX, -pixY)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
@@ -255,3 +255,42 @@
plot._axes.hold(True)
plot._axes.plot(self.x, self.y, **self.plot_args)
plot._axes.hold(False)
+
+class CuttingQuiverCallback(PlotCallback):
+ def __init__(self, field_x, field_y, factor):
+ PlotCallback.__init__(self)
+ self.field_x = field_x
+ self.field_y = field_y
+ self.factor = factor
+
+ def __call__(self, plot):
+ x0, x1 = plot.xlim
+ y0, y1 = plot.ylim
+ xx0, xx1 = plot._axes.get_xlim()
+ yy0, yy1 = plot._axes.get_ylim()
+ plot._axes.hold(True)
+ nx = plot.image._A.shape[0] / self.factor
+ ny = plot.image._A.shape[1] / self.factor
+ indices = na.argsort(plot.data['dx'])[::-1]
+ pixX = _MPL.CPixelize( plot.data['x'], plot.data['y'], plot.data['z'],
+ plot.data['px'], plot.data['py'],
+ plot.data['pdx'], plot.data['pdy'], plot.data['pdz'],
+ plot.data.center, plot.data._inv_mat, indices,
+ plot.data[self.field_x],
+ int(nx), int(ny),
+ (x0, x1, y0, y1),)
+ pixY = _MPL.CPixelize( plot.data['x'], plot.data['y'], plot.data['z'],
+ plot.data['px'], plot.data['py'],
+ plot.data['pdx'], plot.data['pdy'], plot.data['pdz'],
+ plot.data.center, plot.data._inv_mat, indices,
+ plot.data[self.field_y],
+ int(nx), int(ny),
+ (x0, x1, y0, y1),)
+ X = na.mgrid[0:plot.image._A.shape[0]-1:nx*1j]# + 0.5*factor
+ Y = na.mgrid[0:plot.image._A.shape[1]-1:ny*1j]# + 0.5*factor
+ plot._axes.quiver(X,Y, pixX, -pixY)
+ plot._axes.set_xlim(xx0,xx1)
+ plot._axes.set_ylim(yy0,yy1)
+ plot._axes.hold(False)
+
+
Modified: trunk/yt/reason/Notebook.py
==============================================================================
--- trunk/yt/reason/Notebook.py (original)
+++ trunk/yt/reason/Notebook.py Tue Jun 3 11:15:07 2008
@@ -472,7 +472,7 @@
xv = "%s-velocity" % (lagos.axis_names[lagos.x_dict[self.axis]])
yv = "%s-velocity" % (lagos.axis_names[lagos.y_dict[self.axis]])
self._velocities_cbid = \
- self.plot.add_callback(raven.QuiverCallback(xv,yv,self.axis,20))
+ self.plot.add_callback(raven.QuiverCallback(xv,yv,20))
self.UpdateCanvas()
_particles_cbid = None
@@ -708,9 +708,19 @@
self.center_on_max.Enable(False)
self.center_here.Enable(False)
self.grid_boundaries.Enable(False)
- self.velocities.Enable(False)
self.particles.Enable(False)
+ def show_velocities(self, event):
+ if self._velocities_cbid is not None:
+ self.plot.remove_callback(self._velocities_cbid)
+ self._velocities_cbid = None
+ else:
+ xv = "CuttingPlaneVelocityX"
+ yv = "CuttingPlaneVelocityY"
+ self._velocities_cbid = \
+ self.plot.add_callback(raven.CuttingQuiverCallback(xv,yv,16))
+ self.UpdateCanvas()
+
class ProfilePlotPage(PlotPage):
def __init__(self, parent, status_bar, data_object, argdict, mw=None,
CreationID = -1):
More information about the yt-svn
mailing list