[yt-users] Assertion Error in python2.5 yt

Matthew Turk matthewturk at gmail.com
Wed Sep 24 21:25:41 PDT 2008


Hi there,

The AssertionError is simply a poor error message, and one I have been
meaning to correct, which I will try to do in the morning -- the
assertion happens inside the progress bar code; it is being told, "Set
up a progress bar for zero grids."  What I suspect is happening is
that you are asking for a sphere of 0.1 kpc -- I don't know anything
about your simulation, but the specific errors you are getting lead me
to believe that 0.1 kpc is below the resolution limit for your data --
and YT simply says, "There aren't any cells in here, because it's so
far below the resolution limit!"  (YT selected cells to include by
cell-center, so if you center your sphere at [0.5, 0.5, 0.5] and the
nearest cell-center is > 0.1 kpc away, it will not select that.)

If you could, would you mind supplying the output of:

a.h.print_stats()

and we can see what the resolution limit on your cells is.  If, in
fact, it is above 0.1 kpc, then the code should notify you that your
sphere has selected zero grids meeting your criteria.  If you have
cells near [0.5, 0.5, 0.5] that are below 0.1 kpc in size, it should
be selecting them.  However, I suspect furthermore that -- based on
the output from find_max -- your cells are simply coarser than your
sphere, and you are not selecting anything to supply to the profile to
turn into an average.

That being said, I will improve the error messages first thing in the
morning.  (I am feeling unwell tonight, and do not trust my coding
skills at the moment.)

-Matt


On Wed, Sep 24, 2008 at 7:39 PM, rsoares <dlleuz at xmission.com> wrote:
> Hi,
>
> I don't know why I'm getting "AssertionError" and "KeyError: 'Density'"
> below.
>
> Anyone can explain?
>
> Thanks,
>
> R.Soares
>
>
>>>> import yt.lagos as lagos
> yt.lagos   WARNING    2008-09-24 20:26:36,993 No HDF4 support
>>>> a = lagos.EnzoStaticOutput("RedshiftOutput0004")
>>>> v,c = a.h.find_max("Density")
> yt.lagos   INFO       2008-09-24 20:27:38,292 Skipping serialization!
> yt.lagos   INFO       2008-09-24 20:27:38,292 Caching hierarchy
> information
> yt.lagos   INFO       2008-09-24 20:27:38,299 Gathering a field list
> (this may take a moment.)
> Warning: invalid value encountered in sqrt
> Warning: invalid value encountered in divide
> Warning: invalid value encountered in divide
> Warning: invalid value encountered in sqrt
> yt.lagos   INFO       2008-09-24 20:27:38,799 Max Value is 1.75364e-25
> at 0.2890625000000000 0.2812500000000000 0.4843750000000000 in grid
> Grid_0001 at level 0 [36 35 61]
>>>> print v
> 1.75364112031e-25
>>>> print c
> [ 0.2890625  0.28125    0.484375 ]
>
>>>> sphere = a.h.sphere([0.5,0.5,0.5],0.1/a["kpc"])
>>>> prof =
> lagos.BinnedProfile1D(sphere,16,"Radiuskpc",0.0001,0.1,True,True)
>>>> prof.add_fields(["Density"])
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File
> "/home/robyn/yt-pentiumD/lib/python2.5/site-packages/yt/lagos/Profiles.py", line 105, in add_fields
>    self._lazy_add_fields(fields, weight, accumulation)
>  File
> "/home/robyn/yt-pentiumD/lib/python2.5/site-packages/yt/lagos/Profiles.py", line 64, in _lazy_add_fields
>    pbar = get_pbar('Binning grids', len(self._data_source._grids))
>  File
> "/home/robyn/yt-pentiumD/lib/python2.5/site-packages/yt/funcs.py", line
> 127, in get_pbar
>    maxval=maxval).start()
>  File
> "/home/robyn/yt-pentiumD/lib/python2.5/site-packages/yt/progressbar.py",
> line 213, in __init__
>    assert maxval > 0
> AssertionError
>
>
>>>> print prof["Density"]
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File
> "/home/robyn/yt-pentiumD/lib/python2.5/site-packages/yt/lagos/Profiles.py", line 115, in __getitem__
>    return self._data[key]
> KeyError: 'Density'
>
>
> _______________________________________________
> 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