[yt-users] TotalMass for ORION data

Mark Krumholz krumholz at ucolick.org
Mon May 6 16:49:31 PDT 2013


Hi All,

I just updated to the latest version of yt, hoping that this would be fixed, but it seems not to be: the "TotalMass" function is broken for Orion data, and, from what I can tell, for any data set that doesn't contain dark matter particles. Here's what I get when I try to use it:

In [1]: pf=load('data.0030.3d.hdf5')
yt : [WARNING  ] 2013-05-06 16:43:36,339 Setting 1.0 in code units to be 1.0 cm
yt : [WARNING  ] 2013-05-06 16:43:36,339 No time units.  Setting 1.0 = 1 second.
yt : [INFO     ] 2013-05-06 16:43:36,340 Parameters: current_time              = 6.78585436617e+13
yt : [INFO     ] 2013-05-06 16:43:36,340 Parameters: domain_dimensions         = [256 256 256]
yt : [INFO     ] 2013-05-06 16:43:36,341 Parameters: domain_left_edge          = [ -1.68000000e+18  -1.68000000e+18  -1.68000000e+18]
yt : [INFO     ] 2013-05-06 16:43:36,341 Parameters: domain_right_edge         = [  1.68000000e+18   1.68000000e+18   1.68000000e+18]

In [2]: dd=pf.h.all_data()
^[[Ayt : [INFO     ] 2013-05-06 16:43:53,804 Adding unknown field gravitational-potential to list of fields

In [3]: dd.quantities["TotalMass"]() 
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/home3/mkrumhol/yt-x86_64/src/yt-hg/scripts/iyt in <module>()
----> 1 dd.quantities["TotalMass"]()

/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.pyc in __call__(self, *args, **kwargs)
     90                           self._data_source.pf.h.io)
     91         if lazy_reader and not self.force_unlazy:
---> 92             return self._call_func_lazy(args, kwargs)
     93         else:
     94             return self._call_func_unlazy(args, kwargs)

/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.pyc in _call_func_lazy(self, args, kwargs)
     97         self.retvals = [ [] for i in range(self.n_ret)]
     98         for gi,g in enumerate(self._get_grids()):
---> 99             rv = self.func(GridChildMaskWrapper(g, self._data_source), *args, **kwargs)
    100             if not iterable(rv): rv = (rv,)
    101             for i in range(self.n_ret): self.retvals[i].append(rv[i])

/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.pyc in _TotalMass(data)
    152     """
    153     baryon_mass = data["CellMassMsun"].sum()
--> 154     particle_mass = data["ParticleMassMsun"].sum()
    155     return [baryon_mass + particle_mass]
    156 def _combTotalMass(data, total_mass):

/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.pyc in __getitem__(self, item)
     58     def __getitem__(self, item):
     59         if item not in self.local_cache:
---> 60             data = self.data_source._get_data_from_grid(self.grid, item)
     61             self.local_cache[item] = data
     62         return self.local_cache[item]

/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc in save_state(self, grid, field, *args, **kwargs)
     93         old_keys = grid.field_data.keys()
     94         grid.field_parameters = self.field_parameters
---> 95         tr = func(self, grid, field, *args, **kwargs)
     96         grid.field_parameters = old_params
     97         grid.field_data = YTFieldData( [(k, grid.field_data[k]) for k in old_keys] )

/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc in _get_data_from_grid(self, grid, field)
   2643             return np.array([f[i,:][pointI] for i in range(3)])
   2644         else:
-> 2645             tr = grid[field]
   2646             if tr.size == 1: # dx, dy, dz, cellvolume
   2647                 tr = tr * np.ones(grid.ActiveDimensions, dtype='float64')

/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in __getitem__(self, key)
    155         """
    156         if key not in self.field_data:
--> 157             self.get_data(key)
    158         return self.field_data[key]
    159 

/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in get_data(self, field, convert)
    198                     else: raise
    199             else:
--> 200                 self._generate_field(field)
    201         return self.field_data[field]
    202 

/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in _generate_field(self, field)
    145                 self[field] = self.pf.field_info[field](self)
    146         else: # Can't find the field, try as it might
--> 147             raise exceptions.KeyError(field)
    148 
    149     def has_key(self, key):

KeyError: 'ParticleMassMsun'

This isn't a huge deal, because I can use "TotalQuantity" on "Density" as a workaround, but I thought I would report it.

--
Mark Krumholz
krumholz at ucolick.org







More information about the yt-users mailing list