[Yt-svn] yt-commit r1567 - branches/yt-1.5/yt/raven trunk/yt/raven
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Wed Jan 6 12:45:34 PST 2010
Author: mturk
Date: Wed Jan 6 12:45:30 2010
New Revision: 1567
URL: http://yt.enzotools.org/changeset/1567
Log:
Fixing ParticlePlot in 1.5 and trunk, as well as adding documentation.
Modified:
branches/yt-1.5/yt/raven/Callbacks.py
branches/yt-1.5/yt/raven/PlotCollection.py
branches/yt-1.5/yt/raven/PlotTypes.py
trunk/yt/raven/Callbacks.py
trunk/yt/raven/PlotCollection.py
trunk/yt/raven/PlotTypes.py
Modified: branches/yt-1.5/yt/raven/Callbacks.py
==============================================================================
--- branches/yt-1.5/yt/raven/Callbacks.py (original)
+++ branches/yt-1.5/yt/raven/Callbacks.py Wed Jan 6 12:45:30 2010
@@ -47,8 +47,8 @@
x0, x1 = plot.xlim
y0, y1 = plot.ylim
l, b, width, height = _get_bounds(plot._axes.bbox)
- dx = plot.image._A.shape[0] / (x1-x0)
- dy = plot.image._A.shape[1] / (y1-y0)
+ dx = width / (x1-x0)
+ dy = height / (y1-y0)
return ((coord[0] - int(offset)*x0)*dx,
(coord[1] - int(offset)*y0)*dy)
Modified: branches/yt-1.5/yt/raven/PlotCollection.py
==============================================================================
--- branches/yt-1.5/yt/raven/PlotCollection.py (original)
+++ branches/yt-1.5/yt/raven/PlotCollection.py Wed Jan 6 12:45:30 2010
@@ -214,11 +214,18 @@
def add_particles(self, axis, width, p_size=1.0, col='k', stride=1.0,
data_source=None, figure=None, axes=None):
+ """
+ Create a particle plot, where particle positions have been projected
+ along *axis* from a slab of *width* (in code units). *p_size* is the
+ point size, *col* is color, *stride* is the stride of concatenated
+ particle lists to plot.
+ """
LE = self.pf["DomainLeftEdge"].copy()
RE = self.pf["DomainRightEdge"].copy()
LE[axis] = self.c[axis] - width/2.0
RE[axis] = self.c[axis] + width/2.0
if data_source is None: data_source = self.pf.h.region(self.c, LE, RE)
+ data_source.axis = axis
p = self._add_plot(PlotTypes.ParticlePlot(data_source, axis,
width, p_size, col, stride, figure,
axes))
Modified: branches/yt-1.5/yt/raven/PlotTypes.py
==============================================================================
--- branches/yt-1.5/yt/raven/PlotTypes.py (original)
+++ branches/yt-1.5/yt/raven/PlotTypes.py Wed Jan 6 12:45:30 2010
@@ -578,14 +578,15 @@
_type_name = "ParticlePlot"
def __init__(self, data, axis, width, p_size=1.0, col='k', stride=1.0,
figure = None, axes = None):
- RavenPlot.__init__(self, data, [], figure, axes)
+ kwargs = {}
+ if figure is None: kwargs['size'] = (8,8)
+ RavenPlot.__init__(self, data, [], figure, axes, **kwargs)
self._figure.subplots_adjust(hspace=0, wspace=0, bottom=0.0,
top=1.0, left=0.0, right=1.0)
self.axis = axis
self.setup_domain_edges(axis)
self.axis_names['Z'] = col
- from Callbacks import ParticleCallback
- self.add_callback(ParticleCallback(axis, width, p_size, col, stride))
+ self.modify["nparticles"](width, p_size, col, stride)
self.set_width(1,'unitary')
def _redraw_image(self, *args):
@@ -593,12 +594,6 @@
self._reset_image_parameters()
self._run_callbacks()
- def set_xlim(self, xmin, xmax):
- self.xlim = (xmin,xmax)
-
- def set_ylim(self, ymin, ymax):
- self.ylim = (ymin,ymax)
-
def _generate_prefix(self, prefix):
self.prefix = "_".join([prefix, self._type_name, \
lagos.axis_names[self.axis], self.axis_names['Z']])
@@ -610,7 +605,7 @@
self["Unit"] = str(unit)
self["Width"] = float(width)
if isinstance(unit, types.StringTypes):
- unit = self.data.hierarchy[str(unit)]
+ unit = self.data.pf[str(unit)]
self.width = width / unit
self._refresh_display_width()
@@ -637,6 +632,9 @@
self._axes.set_yticks(())
self._axes.set_ylabel("")
self._axes.set_xlabel("")
+ l, b, width, height = _get_bounds(self._axes.bbox)
+ self._axes.set_xlim(0, width)
+ self._axes.set_ylim(0, height)
class ProfilePlot(RavenPlot):
_x_label = None
Modified: trunk/yt/raven/Callbacks.py
==============================================================================
--- trunk/yt/raven/Callbacks.py (original)
+++ trunk/yt/raven/Callbacks.py Wed Jan 6 12:45:30 2010
@@ -47,8 +47,8 @@
x0, x1 = plot.xlim
y0, y1 = plot.ylim
l, b, width, height = _get_bounds(plot._axes.bbox)
- dx = plot.image._A.shape[0] / (x1-x0)
- dy = plot.image._A.shape[1] / (y1-y0)
+ dx = width / (x1-x0)
+ dy = height / (y1-y0)
return ((coord[0] - int(offset)*x0)*dx,
(coord[1] - int(offset)*y0)*dy)
Modified: trunk/yt/raven/PlotCollection.py
==============================================================================
--- trunk/yt/raven/PlotCollection.py (original)
+++ trunk/yt/raven/PlotCollection.py Wed Jan 6 12:45:30 2010
@@ -214,11 +214,18 @@
def add_particles(self, axis, width, p_size=1.0, col='k', stride=1.0,
data_source=None, figure=None, axes=None):
+ """
+ Create a particle plot, where particle positions have been projected
+ along *axis* from a slab of *width* (in code units). *p_size* is the
+ point size, *col* is color, *stride* is the stride of concatenated
+ particle lists to plot.
+ """
LE = self.pf["DomainLeftEdge"].copy()
RE = self.pf["DomainRightEdge"].copy()
LE[axis] = self.c[axis] - width/2.0
RE[axis] = self.c[axis] + width/2.0
if data_source is None: data_source = self.pf.h.region(self.c, LE, RE)
+ data_source.axis = axis
p = self._add_plot(PlotTypes.ParticlePlot(data_source, axis,
width, p_size, col, stride, figure,
axes))
Modified: trunk/yt/raven/PlotTypes.py
==============================================================================
--- trunk/yt/raven/PlotTypes.py (original)
+++ trunk/yt/raven/PlotTypes.py Wed Jan 6 12:45:30 2010
@@ -588,14 +588,15 @@
_type_name = "ParticlePlot"
def __init__(self, data, axis, width, p_size=1.0, col='k', stride=1.0,
figure = None, axes = None):
- RavenPlot.__init__(self, data, [], figure, axes)
+ kwargs = {}
+ if figure is None: kwargs['size'] = (8,8)
+ RavenPlot.__init__(self, data, [], figure, axes, **kwargs)
self._figure.subplots_adjust(hspace=0, wspace=0, bottom=0.0,
top=1.0, left=0.0, right=1.0)
self.axis = axis
self.setup_domain_edges(axis)
self.axis_names['Z'] = col
- from Callbacks import ParticleCallback
- self.add_callback(ParticleCallback(axis, width, p_size, col, stride))
+ self.modify["particles"](width, p_size, col, stride)
self.set_width(1,'unitary')
def _redraw_image(self, *args):
@@ -603,12 +604,6 @@
self._reset_image_parameters()
self._run_callbacks()
- def set_xlim(self, xmin, xmax):
- self.xlim = (xmin,xmax)
-
- def set_ylim(self, ymin, ymax):
- self.ylim = (ymin,ymax)
-
def _generate_prefix(self, prefix):
self.prefix = "_".join([prefix, self._type_name, \
lagos.axis_names[self.axis], self.axis_names['Z']])
@@ -620,7 +615,7 @@
self["Unit"] = str(unit)
self["Width"] = float(width)
if isinstance(unit, types.StringTypes):
- unit = self.data.hierarchy[str(unit)]
+ unit = self.data.pf[str(unit)]
self.width = width / unit
self._refresh_display_width()
@@ -647,6 +642,9 @@
self._axes.set_yticks(())
self._axes.set_ylabel("")
self._axes.set_xlabel("")
+ l, b, width, height = _get_bounds(self._axes.bbox)
+ self._axes.set_xlim(0, width)
+ self._axes.set_ylim(0, height)
class ProfilePlot(RavenPlot):
_x_label = None
More information about the yt-svn
mailing list