[yt-dev] Question about the tree structure in yt 2.x

hyschive at ntu.edu.tw hyschive at ntu.edu.tw
Sun Feb 23 06:21:55 PST 2014


Dear Matthew,

Thanks for the suggestion! I'll follow it and try to solve the problem.

Sincerely,
Hsi-Yu



引述 Matthew Turk <matthewturk at gmail.com>:

> Hi Hsi-Yu,
>
> Sorry for the delay in replying.
>
> On Friday, February 21, 2014, <hyschive at ntu.edu.tw> wrote:
>
>> Dear all,
>>
>> I'm a new user of yt and is trying to use it for analyzing our octree AMR
>> data, which is similar to FLASH. We are stilling testing yt version 2.x,
>> and currently we are able to create a slice image together with the
>> underlying AMR grid distribution WITHOUT providing any parent-children
>> relation between each grid. However, after we further set up the
>> parent-children relation, the plot (e.g., the SlicePlot command) failed
>> with the following error messages:
>>
>> ===============Error Message=======================
>> =========================
>>
>> ValueError                                Traceback (most recent call last)
>>
>> <ipython-input-3-e98bfe3813b1> in <module>()
>>
>> ----> 1 p=SlicePlot(pf,2,"Density",center=(0.501,0.501,0.501))
>>
>>
>>
>> /work1/ftd/yt-x86_64/src/yt-hg/yt/visualization/plot_window.pyc in
>> __init__(self, pf, axis, fields, center, width, origin)
>>
>>     805         slc = pf.h.slice(axis, center[axis], fields=fields)
>>
>>     806         print slc,bounds,origin
>>
>> --> 807         PWViewerMPL.__init__(self, slc, bounds, origin=origin)
>>
>>     808
>>
>>     809 class ProjectionPlot(PWViewerMPL):
>>
>>
>>
>> /work1/ftd/yt-x86_64/src/yt-hg/yt/visualization/plot_window.pyc in
>> __init__(self, *args, **kwargs)
>>
>>     446                 self._field_transform[field] = linear_transform
>>
>>     447
>>
>> --> 448         if setup: self._setup_plots()
>>
>>     449
>>
>>     450     @invalidate_plot
>>
>>
>>
>> /work1/ftd/yt-x86_64/src/yt-hg/yt/visualization/plot_window.pyc in
>> _setup_plots(self)
>>
>>     617             print self.plots[f].image,self.plots[f].cax
>>
>>     618             self.plots[f].cb = self.plots[f].figure.colorbar(
>>
>> --> 619                 self.plots[f].image, cax = self.plots[f].cax)
>>
>>     620
>>
>>     621             if self.oblique == False:
>>
>>
>>
>> /work1/ftd/yt-x86_64/lib/python2.7/site-packages/matplotlib/figure.pyc in
>> colorbar(self, mappable, cax, ax, **kw)
>>
>>    1194                 cax, kw = cbar.make_axes(ax, **kw)
>>
>>    1195         cax.hold(True)
>>
>> -> 1196         cb = cbar.Colorbar(cax, mappable, **kw)
>>
>>    1197
>>
>>    1198         def on_changed(m):
>>
>>
>>
>> /work1/ftd/yt-x86_64/lib/python2.7/site-packages/matplotlib/colorbar.pyc
>> in __init__(self, ax, mappable, **kw)
>>
>>     741                 kw['alpha'] = mappable.get_alpha()
>>
>>     742
>>
>> --> 743             ColorbarBase.__init__(self, ax, **kw)
>>
>>     744
>>
>>     745
>>
>>
>>
>> /work1/ftd/yt-x86_64/lib/python2.7/site-packages/matplotlib/colorbar.pyc
>> in __init__(self, ax, cmap, norm, alpha, values, boundaries, orientation,
>> extend, spacing, ticks, format, drawedges, filled)
>>
>>     256         # The rest is in a method so we can recalculate when clim
>> changes.
>>
>>     257         self.config_axis()
>>
>> --> 258         self.draw_all()
>>
>>     259
>>
>>    260     def _patch_ax(self):
>>
>>
>>
>> /work1/ftd/yt-x86_64/lib/python2.7/site-packages/matplotlib/colorbar.pyc
>> in draw_all(self)
>>
>>     270         and do all the drawing.
>>
>>     271         '''
>>
>> --> 272         self._process_values()
>>
>>     273         self._find_range()
>>
>>     274         X, Y = self._mesh()
>>
>>
>>
>> /work1/ftd/yt-x86_64/lib/python2.7/site-packages/matplotlib/colorbar.pyc
>> in _process_values(self, b)
>>
>>     568                 self.norm.vmin = 0
>>
>>     569                 self.norm.vmax = 1
>>
>> --> 570             b = self.norm.inverse(self._uniform_y(self.cmap.N+1))
>>
>>     571             if self.extend in ('both', 'min'):
>>
>>     572                 b[0] = b[0] - 1
>>
>>
>>
>> /work1/ftd/yt-x86_64/lib/python2.7/site-packages/matplotlib/colors.pyc in
>> inverse(self, value)
>>
>>     946         if cbook.iterable(value):
>>
>>     947             val = ma.asarray(value)
>>
>> --> 948             return vmin * ma.power((vmax/vmin), val)
>>
>>     949         else:
>>
>>     950             return vmin * pow((vmax/vmin), value)
>>
>>
>>
>> /work1/ftd/yt-x86_64/lib/python2.7/site-packages/numpy/ma/core.pyc in
>> __mul__(self, other)
>>
>>    3640     def __mul__(self, other):
>>
>>    3641         "Multiply other by self, and return a new masked array."
>>
>> -> 3642         return multiply(self, other)
>>
>>   3643     #
>>
>>    3644     def __rmul__(self, other):
>>
>>
>>
>> /work1/ftd/yt-x86_64/lib/python2.7/site-packages/numpy/ma/core.pyc in
>> __call__(self, a, b, *args, **kwargs)
>>
>>     934         # Case 1. : scalar
>>
>>     935         if not result.ndim:
>>
>> --> 936             if m:
>>
>>     937                 return masked
>>
>>     938             return result
>>
>>
>>
>> ValueError: The truth value of an array with more than one element is
>> ambiguous. Use a.any() or a.all()
>>
>> ==========End of Error Message=======================
>> ===========================
>>
>>
>> So, my questions are as follows.
>> 1. What is the necessary information for constructing the tree structure
>> in yt?Currently the SlicePlot command failed only after we set up the
>> "Parent" and "Children" variables for each grid in the function
>> "_populate_grid_objects".
>>
>
> Typically the information is necessary just to check the masking of grid
> objects; Parent is considerably less important for this than Children.
>
> There is a diagnostic that can be run to examine the volume:
>
> vol = 0.0
> dv = pf.domain_width.prod(dtype="float64")
> for g in pf.h.grids:
>     vol += g.dds.prod(dtype="float64") * g.child_mask.sum()
> print np.abs(vol - dv)/dv
>
> What it looks like is happening, based on the error message, is that
> somehow the total values in a slice are being set to the same thing
> everywhere.  This diagnostic -- which should produce a value of 0.0 --
> should help track that down.
>
>
>>
>> 2. Does the SlicePlot command need to know the parent-children relation of
>> each grid? If no, why it will fail after we set up the relation?
>>
>
> It only needs to know the children of a grid, so that it can mask out
> overlapping regions.
>
>
>>
>> 3. Will yt automatically construct the "neighbor" information for nearby
>> grids at the same AMR refinement level? If no, how does it handle the
>> operations requiring spatial derivative (e.g., curl and divergence)?
>>
>
> It will do so, yup.
>
>
>>
>> Any suggestion will be welcome, and thanks for the help in advance :)
>>
>
> I suspect something might be going wrong with the way the children pointers
> are set up.  Can you show how you're constructing them?  It's possible that
> there is an off-by-one or something that is creeping in.
>
> -Matt
>
>
>>
>> Sincerely,
>> Hsi-Yu
>>
>>
>>
>>
>>
>> _______________________________________________
>> yt-dev mailing list
>> yt-dev at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
>>
>





More information about the yt-dev mailing list