[yt-users] error in setting width of slices

Matthew Turk matthewturk at gmail.com
Thu Dec 15 04:58:54 PST 2011


Hi Elizabeth,

This isn't really a yt error.  yt will also accept a set of extrema,
which should prevent this error from coming up.

-Matt

On Thu, Dec 15, 2011 at 1:54 AM, Elizabeth Tasker
<tasker at astro1.sci.hokudai.ac.jp> wrote:
> Hi,
>
> Sometimes when I try and set the width of an image, yt throws an error
> and stops:
>
>
> /home/tasker/yt-test/scripts/iyt in <module>()
>    609     if (ncloudcells_final > 0):
>    610        p.modify["contour"]("Clouds", ncont=1, factor=1)
> --> 611     p.set_width(400, 'pc')
>    612     pc.save("%s_lowresgridpot_core%d" % (fn, c))
>    613
>
> /home/tasker/yt-test/yt/visualization/plot_types.pyc in
> set_width(self, width, unit)
>    438             unit = self.data.pf[str(unit)]
>    439         self.width = width / unit
> --> 440         self._refresh_display_width()
>    441
>    442     def _refresh_display_width(self, width=None):
>
> /home/tasker/yt-test/yt/visualization/plot_types.pyc in
> _refresh_display_width(self, width)
>    456         self.set_xlim(max(l_edge_x,self.xmin), min(r_edge_x,self.xmax))
>    457         self.set_ylim(max(l_edge_y,self.ymin), min(r_edge_y,self.ymax))
> --> 458         self._redraw_image()
>    459
>    460     def autoscale(self):
>
> /home/tasker/yt-test/yt/visualization/plot_types.pyc in
> _redraw_image(self, *args)
>    403             self.norm.autoscale(na.array((newmin,newmax),
> dtype='float64'))
>    404         self._reset_image_parameters()
> --> 405         self._run_callbacks()
>    406
>    407     def _reset_image_parameters(self):
>
> /home/tasker/yt-test/yt/visualization/plot_types.pyc in _run_callbacks(self)
>    256         self._axes.texts = []
>    257         for cb in self._callbacks:
> --> 258             cb(self)
>    259
>    260     def set_label(self, label):
>
> /home/tasker/yt-test/yt/visualization/plot_modifications.pyc in
> __call__(self, plot)
>    238         print z.min(), z.max(), na.nanmin(z), na.nanmax(z)
>    239         print zi.min(), zi.max(), na.nanmin(zi), na.nanmax(zi)
> --> 240         plot._axes.contour(xi,yi,zi,self.ncont, **self.plot_args)
>    241         plot._axes.set_xlim(xx0,xx1)
>    242         plot._axes.set_ylim(yy0,yy1)
>
> /home/tasker/yt/lib/python2.7/site-packages/matplotlib/axes.pyc in
> contour(self, *args, **kwargs)
>   7314         if not self._hold: self.cla()
>   7315         kwargs['filled'] = False
> -> 7316         return mcontour.QuadContourSet(self, *args, **kwargs)
>   7317     contour.__doc__ = mcontour.QuadContourSet.contour_doc
>   7318
>
> /home/tasker/yt/lib/python2.7/site-packages/matplotlib/contour.pyc in
> __init__(self, ax, *args, **kwargs)
>   1104         are described in QuadContourSet.contour_doc.
>   1105         """
> -> 1106         ContourSet.__init__(self, ax, *args, **kwargs)
>   1107
>   1108     def _process_args(self, *args, **kwargs):
>
> /home/tasker/yt/lib/python2.7/site-packages/matplotlib/contour.pyc in
> __init__(self, ax, *args, **kwargs)
>    699
>    700         self._process_args(*args, **kwargs)
> --> 701         self._process_levels()
>    702
>    703         if self.colors is not None:
>
> /home/tasker/yt/lib/python2.7/site-packages/matplotlib/contour.pyc in
> _process_levels(self)
>    910             self._levels.append(max(self.levels[-1],self.zmax) + 1)
>    911         self._levels = np.asarray(self._levels)
> --> 912         self.vmin = np.amin(self.levels)  # alternative would
> be self.layers
>    913         self.vmax = np.amax(self.levels)
>    914         if self.extend in ('both', 'min'):
>
> /home/tasker/yt/lib/python2.7/site-packages/numpy/core/fromnumeric.pyc
> in amin(a, axis, out)
>   1893     except AttributeError:
>   1894         return _wrapit(a, 'min', axis, out)
> -> 1895     return amin(axis, out)
>   1896
>   1897
>
> ValueError: zero-size array to minimum.reduce without identity
> WARNING: Failure executing file: <findcloudsbypotential_lowresgrid.py>
>
>
>
>
> I think this happens when the contour modification is zero :
> p.modify["contour"]("Clouds", ncont=1, factor=1)
>
>
> Is there a way of telling it just not to plot the contour if there are
> no cells in the current slice that have a value and thereby avoid the
> crash?
>
> Elizabeth
> _______________________________________________
> 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