[yt-users] Callbacks, plot.data.center

David Collins dcollins4096 at gmail.com
Wed Jul 2 08:37:29 PDT 2014


Hi, everyone--


I"m trying to run a callback on a projected sphere, and I'm running into a
missing piece of data.

I'm doing the following:

>>> sph = pf.h.sphere( c, w)
>>> proj = pf.h.proj(1,'Density',source = sph)
>>> pw=proj.to_pw( center= c, width=2)

this works fine, and reproduces the plot I want.  I have this callback that
accesses "plot.data.center", but that seems to be an empty object.  This
callback is based on the ParticlesCallback, so it's accessing a sub region
in the following manner below.  So the plot object doesn't seem to be
getting the center information any more. Is there a way to access this
information now?

Thanks!

d.

A snap from the relevant callback, the line that chokes is the access to
data.center, and pdb says that the structure is None.

    def __call__(self, plot):
        data = plot.data
        # we construct a recantangular prism
        x0, x1 = plot.xlim
        y0, y1 = plot.ylim
        xx0, xx1 = plot._axes.get_xlim()
        yy0, yy1 = plot._axes.get_ylim()
        reg = self._get_region((x0,x1), (y0,y1), plot.data.axis, data)

    def _get_region(self, xlim, ylim, axis, data):
        LE, RE = [None]*3, [None]*3
        xax = x_dict[axis]
        yax = y_dict[axis]
        zax = axis
        LE[xax], RE[xax] = xlim
        LE[yax], RE[yax] = ylim
        LE[zax] = data.center[zax] - self.width*0.5
        RE[zax] = data.center[zax] + self.width*0.5
        if self.region is not None \
            and np.all(self.region.left_edge <= LE) \
            and np.all(self.region.right_edge >= RE):
            return self.region
        self.region = data.pf.h.periodic_region(
            data.center, LE, RE)
        return self.region

-- 
-- Sent from a computer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20140702/8d4bd253/attachment.htm>


More information about the yt-users mailing list