[yt-users] ray problem with cell volume

Matthew Turk matthewturk at gmail.com
Thu Apr 28 10:37:05 PDT 2011


Hi Elizabeth,

This should now be fixed in the yt branch tip.  A fix for ortho rays
wasn't apply to non-ortho rays.

-Matt

On Thu, Apr 28, 2011 at 11:33 AM, Elizabeth Tasker <taskere at mcmaster.ca> wrote:
> Hi,
>
> When using the ray feature in yt, we hit problems if we try to plot any
> variable that contains the cell volume. e.g.
>
> def _Momentum(field, data):
>   return (data["Density"]*data["CellVolume"]*sqrt(
>        data["x-velocity"]**2.0
>        + data["y-velocity"]**2.0
>        + data["z-velocity"]**2.0 ))
>
>
>
> ray = pf.h.ray([0.5, 0.5, 0.5], [1.0,1.0,1.0], "Momentum")
>   pylab.plot(ray["RadiusCode"], ray["Momentum"], 'o')
>
>
> Gives:
>
>
>
> IndexError                                Traceback (most recent call last)
> /saw_sfs/work/chris/yt/scripts/iyt in <module>()
> ----> 1                                             2
>                       3                                             4
>                                       5
>
> /saw_sfs/work/chris/yt/yt/data_objects/data_containers.pyc in
> __getitem__(self, key)
>   274             if key not in self.fields:
>        275                 self.fields.append(key)
>          --> 276             self.get_data(key)
>                    277         return self.data[key]
>                         278
>
>
> /saw_sfs/work/chris/yt/yt/data_objects/data_containers.pyc in get_data(self,
> fields, in_grids)
>   445             mylog.info("Getting field %s from %s", field,
> len(self._grids))             446             if field not in
> self.hierarchy.field_list and not in_grids:              --> 447
>     if field not in ("dts", "t") and self._generate_field(field):
> 448                     continue # True means we already assigned it
>                449             self[field] = na.concatenate(
>
> /saw_sfs/work/chris/yt/yt/data_objects/data_containers.pyc in
> _generate_field(self, field)
>   423                 return False
>              424             else:
>                      --> 425                 self[field] =
> self.pf.field_info[field](self)                       426
> return True                                                         427
>     else: # Can't find the field, try as it might
>
> /saw_sfs/work/chris/yt/yt/data_objects/field_info_container.pyc in
> __call__(self, data)
>   292         ii = self.check_available(data)
>            293         original_fields = data.keys() # Copy
>                  --> 294         dd = self._function(self, data)
>                              295         dd *= self._convert_function(data)
>                                       296         for field_name in
> data.keys():
> /saw_sfs/work/chris/yt/scripts/iyt in _Momentum(field, data)
>    14                                                        15 def
> _Momentum(field, data):                        ---> 16     return
> (data["Density"]*data["CellVolume"]*sqrt(
>    17          data["x-velocity"]**2.0
>
>    18          + data["y-velocity"]**2.0
>
>
> /saw_sfs/work/chris/yt/yt/data_objects/data_containers.pyc in
> __getitem__(self, key)
>   274             if key not in self.fields:
>        275                 self.fields.append(key)
>          --> 276             self.get_data(key)
>                    277         return self.data[key]
>                         278
>
>
> /saw_sfs/work/chris/yt/yt/data_objects/data_containers.pyc in get_data(self,
> fields, in_grids)
>   445             mylog.info("Getting field %s from %s", field,
> len(self._grids))             446             if field not in
> self.hierarchy.field_list and not in_grids:              --> 447
>     if field not in ("dts", "t") and self._generate_field(field):
> 448                     continue # True means we already assigned it
>                449             self[field] = na.concatenate(
>
> /saw_sfs/work/chris/yt/yt/data_objects/data_containers.pyc in
> _generate_field(self, field)
>   423                 return False
>              424             else:
>                      --> 425                 self[field] =
> self.pf.field_info[field](self)                       426
> return True
>   427         else: # Can't find the field, try as it might
>
> /saw_sfs/work/chris/yt/yt/data_objects/field_info_container.pyc in
> __call__(self, data)
>   292         ii = self.check_available(data)
>   293         original_fields = data.keys() # Copy
> --> 294         dd = self._function(self, data)
>   295         dd *= self._convert_function(data)
>   296         for field_name in data.keys():
>
> /saw_sfs/work/chris/yt/yt/data_objects/universal_fields.pyc in
> _CellVolume(field, data)
>   392
>   393 def _CellVolume(field, data):
> --> 394     if data['dx'].size == 1:
>   395         try:
>   396             return data['dx']*data['dy']*data['dx']*\
>
> /saw_sfs/work/chris/yt/yt/data_objects/data_containers.pyc in
> __getitem__(self, key)
>   274             if key not in self.fields:
>   275                 self.fields.append(key)
> --> 276             self.get_data(key)
>   277         return self.data[key]
>   278
>
> /saw_sfs/work/chris/yt/yt/data_objects/data_containers.pyc in get_data(self,
> fields, in_grids)
>   449             self[field] = na.concatenate(
>   450                 [self._get_data_from_grid(grid, field)
> --> 451                  for grid in self._grids])
>   452             if not self.data.has_key(field):
>   453                 continue
>
> /saw_sfs/work/chris/yt/yt/data_objects/data_containers.pyc in
> _get_data_from_grid(self, grid, field)
>   558         if field == 'dts': return self._dts[grid.id][mask]
>   559         if field == 't': return self._ts[grid.id][mask]
> --> 560         return grid[field][mask]
>   561
>   562     @cache_mask
>
> IndexError: invalid index to scalar variable.
>
>
>
> Any ideas?
>
> 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