[yt-users] ZeroDivisionError accessing field from ray in spherical 1D FLASH data
Luke Zoltan Kelley
lkelley at cfa.harvard.edu
Mon Jun 23 11:38:03 PDT 2014
In [173]: pf.domain_left_edge
Out[173]: array([ 0., 0., 0.])
In [174]: pf.domain_right_edge
Out[174]: array([ 4.00000000e+11, 3.14159265e+00, 1.74532925e-02])
On Jun 23, 2014, at 2:35 PM, Matthew Turk <matthewturk at gmail.com> wrote:
> Hi Luke,
>
> Not sure if the dimensionality is a problem or not. But it's saying
> it doesn't find any grids intersecting with the ray, which is
> confusing. What's the output of "pf.domain_left_edge" and
> "pf.domain_right_edge"?
>
> On Mon, Jun 23, 2014 at 1:27 PM, Luke Zoltan Kelley
> <lkelley at cfa.harvard.edu> wrote:
>> Thanks for working with me on this Matt, but I got a new one for you:
>>
>> In [164]: print pf.domain_width
>> [ 4.00000000e+11 3.14159265e+00 1.74532925e-02]
>>
>> In [165]: ray = pf.h.ortho_ray(0, (3.14*0.5, 1.75e-2*0.5))
>> yt : [INFO ] 2014-06-23 14:22:26,386 Getting field x from 0
>> ERROR: ValueError: need at least one array to concatenate [yt.data_objects.data_containers]
>> astropy: [ERROR ] 2014-06-23 14:22:26,386 ValueError: need at least one array to concatenate
>> ---------------------------------------------------------------------------
>> ValueError Traceback (most recent call last)
>> <ipython-input-165-9633905f901e> in <module>()
>> ----> 1 ray = pf.h.ortho_ray(0, (3.14*0.5, 1.75e-2*0.5))
>>
>> /Users/lzkelley/Applications/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc in __init__(self, axis, coords, fields, pf, **kwargs)
>> 578 self.px, self.py = coords
>> 579 self.sort_by = axis_names[self.axis]
>> --> 580 self._refresh_data()
>> 581
>> 582 @property
>>
>> /Users/lzkelley/Applications/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc in _refresh_data(self)
>> 304 """
>> 305 self.clear_data()
>> --> 306 self.get_data()
>> 307
>> 308 def keys(self):
>>
>> /Users/lzkelley/Applications/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc in get_data(self, fields, in_grids)
>> 523 self[field] = np.concatenate(
>> 524 [self._get_data_from_grid(grid, field)
>> --> 525 for grid in self._grids])
>> 526 if not self.field_data.has_key(field):
>> 527 continue
>>
>> ValueError: need at least one array to concatenate
>>
>> could this be something about the data being 1D?
>>
>> Actually, I have no idea if this means anything, but when I ask for the dimensionality:
>>
>> In [172]: pf.dimensionality
>> Out[172]: 2
>>
>> In [171]: pf.domain_dimensions
>> Out[171]: array([ 8, 16, 1])
>>
>> But my FLASH log confirms the dimensionality is 1...
>>
>>
>> On Jun 23, 2014, at 2:19 PM, Matthew Turk <matthewturk at gmail.com> wrote:
>>
>>> Hi Luke,
>>>
>>> Nah, not a bad influence. Try putting it at the cell center instead
>>> of the cell edge. :) (0.0, 0.0) will be the very corner of the
>>> domain, so it's skimming along the surface of a cell.
>>>
>>> On Mon, Jun 23, 2014 at 1:16 PM, Luke Zoltan Kelley
>>> <lkelley at cfa.harvard.edu> wrote:
>>>> Thanks Matt, but now I'm having new problems with 'ortho_ray', following
>>>> (http://yt-project.org/doc/visualizing/manual_plotting.html), I tried
>>>>
>>>>> ray = pf.h.ortho_ray(0, (0.0,0.0))
>>>>
>>>> which then gave me
>>>>
>>>> yt : [INFO ] 2014-06-23 14:15:52,664 Getting field x from 8
>>>> ERROR: ValueError: cannot convert float NaN to integer
>>>> [yt.data_objects.data_containers]
>>>> astropy: [ERROR ] 2014-06-23 14:15:52,664 ValueError: cannot convert
>>>> float NaN to integer
>>>> ---------------------------------------------------------------------------
>>>> ValueError Traceback (most recent call last)
>>>> <ipython-input-157-318ebcfbdb94> in <module>()
>>>> ----> 1 ray = pf.h.ortho_ray(0, (0.0,0.0))
>>>>
>>>> /Users/lzkelley/Applications/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>>>> in __init__(self, axis, coords, fields, pf, **kwargs)
>>>> 578 self.px, self.py = coords
>>>> 579 self.sort_by = axis_names[self.axis]
>>>> --> 580 self._refresh_data()
>>>> 581
>>>> 582 @property
>>>>
>>>> /Users/lzkelley/Applications/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>>>> in _refresh_data(self)
>>>> 304 """
>>>> 305 self.clear_data()
>>>> --> 306 self.get_data()
>>>> 307
>>>> 308 def keys(self):
>>>>
>>>>
>>>> /Users/lzkelley/Applications/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>>>> in get_data(self, fields, in_grids)
>>>> 523 self[field] = np.concatenate(
>>>> 524 [self._get_data_from_grid(grid, field)
>>>> --> 525 for grid in self._grids])
>>>> 526 if not self.field_data.has_key(field):
>>>> 527 continue
>>>>
>>>> /Users/lzkelley/Applications/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>>>> in save_state(self, grid, field, *args, **kwargs)
>>>> 79 old_keys = grid.field_data.keys()
>>>> 80 grid.field_parameters = self.field_parameters
>>>> ---> 81 tr = func(self, grid, field, *args, **kwargs)
>>>> 82 grid.field_parameters = old_params
>>>> 83 grid.field_data = YTFieldData( [(k, grid.field_data[k]) for
>>>> k in old_keys] )
>>>>
>>>> /Users/lzkelley/Applications/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>>>> in _get_data_from_grid(self, grid, field)
>>>> 599 gdx = just_one(grid[self.px_dx])
>>>> 600 gdy = just_one(grid[self.py_dx])
>>>> --> 601 x_coord = int((self.px - grid.LeftEdge[self.px_ax])/gdx)
>>>> 602 y_coord = int((self.py - grid.LeftEdge[self.py_ax])/gdy)
>>>> 603 sl = [None,None,None]
>>>>
>>>> ValueError: cannot convert float NaN to integer
>>>>
>>>>
>>>> Without doing anything wrong, perhaps I'm just a bad influence.
>>>>
>>>> Luke
>>>>
>>>>
>>>>
>>>>
>>>> On Jun 23, 2014, at 2:05 PM, Matthew Turk <matthewturk at gmail.com> wrote:
>>>>
>>>> Hi Luke,
>>>>
>>>> You didn't do anything wrong. :) yt should be able to accept rays
>>>> through "ray" that are orthogonal to the axes, but it can't because of
>>>> some sloppiness. You have two options -- either use "ortho_ray"
>>>> instead of "ray", which will make it orthogonal (and probably be a bit
>>>> faster) or add jitter to the tune of 1e-12 to your 0.0 entries.
>>>>
>>>> -Matt
>>>>
>>>> On Mon, Jun 23, 2014 at 11:44 AM, Luke Zoltan Kelley
>>>> <lkelley at cfa.harvard.edu> wrote:
>>>>
>>>> Hello yt-users,
>>>>
>>>> Just starting using YT, please forgive simple problems.
>>>>
>>>> I have 1D spherical FLASH data which I'm trying to plot. I thought I should
>>>> use a 'ray', so I created one as such and try to access the data but I'm
>>>> getting a ZeroDivision Error:
>>>>
>>>> from yt.mods import *
>>>> pf = load('starwind_hdf5_plt_cnt_0000')
>>>> In [141]: ray = pf.h.ray([0.0,0.0,0.0],[1.0e11,0.0,0.0], fields=["Density"])
>>>> In [142]: ray['Density']
>>>>
>>>> yt : [INFO ] 2014-06-23 12:40:51,841 Getting field t from 138
>>>> ERROR: ZeroDivisionError: float division [IPython.core.interactiveshell]
>>>> astropy: [ERROR ] 2014-06-23 12:40:51,846 ZeroDivisionError: float
>>>> division
>>>> ---------------------------------------------------------------------------
>>>> ZeroDivisionError Traceback (most recent call last)
>>>> <ipython-input-142-c8a80a171d35> in <module>()
>>>> ----> 1 ray['Density']
>>>>
>>>> /Users/lzkelley/Applications/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>>>> in __getitem__(self, key)
>>>> 316 if key not in self.fields:
>>>> 317 self.fields.append(key)
>>>> --> 318 self.get_data(key)
>>>> 319 return self.field_data[key]
>>>> 320
>>>>
>>>> /Users/lzkelley/Applications/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>>>> in get_data(self, fields, in_grids)
>>>> 523 self[field] = np.concatenate(
>>>> 524 [self._get_data_from_grid(grid, field)
>>>> --> 525 for grid in self._grids])
>>>> 526 if not self.field_data.has_key(field):
>>>> 527 continue
>>>>
>>>> /Users/lzkelley/Applications/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>>>> in save_state(self, grid, field, *args, **kwargs)
>>>> 79 old_keys = grid.field_data.keys()
>>>> 80 grid.field_parameters = self.field_parameters
>>>> ---> 81 tr = func(self, grid, field, *args, **kwargs)
>>>> 82 grid.field_parameters = old_params
>>>> 83 grid.field_data = YTFieldData( [(k, grid.field_data[k]) for k
>>>> in old_keys] )
>>>>
>>>> /Users/lzkelley/Applications/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>>>> in _get_data_from_grid(self, grid, field)
>>>> 689 @restore_grid_state
>>>> 690 def _get_data_from_grid(self, grid, field):
>>>> --> 691 mask = np.logical_and(self._get_cut_mask(grid),
>>>> 692 grid.child_mask)
>>>> 693 if field == 'dts': return self._dts[grid.id][mask]
>>>>
>>>> /Users/lzkelley/Applications/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>>>> in check_cache(self, grid)
>>>> 109 elif grid.id not in self._cut_masks or \
>>>> 110 hasattr(self, "_boolean_touched"):
>>>> --> 111 cm = func(self, grid)
>>>> 112 self._cut_masks[grid.id] = cm
>>>> 113 return self._cut_masks[grid.id]
>>>>
>>>> /Users/lzkelley/Applications/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>>>> in _get_cut_mask(self, grid)
>>>> 704 ts = np.zeros(grid.ActiveDimensions, dtype='float64')
>>>> 705 VoxelTraversal(mask, ts, dts, grid.LeftEdge, grid.RightEdge,
>>>> --> 706 grid.dds, self.center, self.vec)
>>>> 707 self._dts[grid.id] = np.abs(dts)
>>>> 708 self._ts[grid.id] = np.abs(ts)
>>>>
>>>> /Users/lzkelley/Applications/yt/yt-x86_64/src/yt-hg/yt/utilities/lib/RayIntegrators.so
>>>> in yt.utilities.lib.RayIntegrators.VoxelTraversal
>>>> (yt/utilities/lib/RayIntegrators.c:3408)()
>>>>
>>>> ZeroDivisionError: float division
>>>>
>>>>
>>>> yt instinfo
>>>> Version = 2.6.1
>>>> Changeset = c7bae05dd4ef
>>>>
>>>>
>>>> Any ideas what I'm doing wrong?
>>>> Thanks!
>>>> Luke
>>>>
>>>> _______________________________________________
>>>> yt-users mailing list
>>>> yt-users at lists.spacepope.org
>>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>>>
>>>> _______________________________________________
>>>> yt-users mailing list
>>>> yt-users at lists.spacepope.org
>>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> yt-users mailing list
>>>> yt-users at lists.spacepope.org
>>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>>>
>>> _______________________________________________
>>> yt-users mailing list
>>> yt-users at lists.spacepope.org
>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
> _______________________________________________
> 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