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

Matthew Turk matthewturk at gmail.com
Wed Jul 2 08:39:43 PDT 2014


Hi Dave,

On Wed, Jul 2, 2014 at 10:37 AM, David Collins <dcollins4096 at gmail.com> wrote:
> 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?

An empty object?  Is it None, or does it throw an attribute error?
What type of object is "data" -- a Region object?

>
> 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.
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>



More information about the yt-users mailing list