[yt-users] Dark matter + yt
Matthew Turk
mjturk at ucsd.edu
Fri Aug 20 14:39:17 PDT 2010
Hi Elizabeth,
> Does yt have trouble if there is no gas but only particles in an output? I'm
> seeing:
>
> In [2]: fn="Gasoline_32static_dmonly_0000"
>
> In [3]: pf = load(fn)
>
> In [4]: pc = PlotCollection(pf)
> yt INFO 2010-08-20 17:32:36,447 Getting the binary hierarchy
> yt INFO 2010-08-20 17:32:36,451 Finished with binary hierarchy
> reading
> ---------------------------------------------------------------------------
> NeedsDataField Traceback (most recent call last)
>
> /1/home/taskere/yt/src/yt-1.7-svn/scripts/iyt in <module>()
> ----> 1
> 2
> 3
> 4
> 5
>
> /1/home/taskere/yt/src/yt-1.7-svn/yt/raven/plot_collection.py in
> __init__(self, pf, center)
> 81 self.pf = pf
> 82 if center == None:
> ---> 83 v,self.c = pf.h.find_max("Density") # @todo: ensure no
> caching
> 84 elif center == "center" or center == "c":
> 85 self.c = (pf["DomainRightEdge"] +
> pf["DomainLeftEdge"])/2.0
>
> /1/home/taskere/yt/src/yt-1.7-svn/yt/lagos/object_finding_mixin.py in
> find_max(self, field, finest_levels)
> 53 if (field, finest_levels) in self._max_locations:
> 54 return self._max_locations[(field, finest_levels)]
> ---> 55 mg, mc, mv, pos = self.find_max_cell_location(field,
> finest_levels)
> 56 self._max_locations[(field, finest_levels)] = (mv, pos)
> 57 return mv, pos
>
> /1/home/taskere/yt/src/yt-1.7-svn/yt/lagos/object_finding_mixin.py in
> find_max_cell_location(self, field, finest_levels)
> 66 len(source._grids), field)
> 67 max_val, maxi, mx, my, mz, mg = \
> ---> 68 source.quantities["MaxLocation"]( field,
> lazy_reader=True)
> 69 max_grid = self.grids[mg]
> 70 mc = na.unravel_index(maxi, max_grid.ActiveDimensions)
>
> /1/home/taskere/yt/src/yt-1.7-svn/yt/lagos/DerivedQuantities.py in
> __call__(self, *args, **kwargs)
> 70 self._data_source.pf.h.io)
> 71 if lazy_reader and not self.force_unlazy:
> ---> 72 return self._call_func_lazy(args, kwargs)
> 73 else:
> 74 return self._call_func_unlazy(args, kwargs)
>
> /1/home/taskere/yt/src/yt-1.7-svn/yt/lagos/DerivedQuantities.py in
> _call_func_lazy(self, args, kwargs)
> 77 self.retvals = [ [] for i in range(self.n_ret)]
> 78 for gi,g in enumerate(self._get_grids()):
> ---> 79 rv = self.func(GridChildMaskWrapper(g,
> self._data_source), *args, **kwargs)
> 80 for i in range(self.n_ret): self.retvals[i].append(rv[i])
> 81 g.clear_data()
>
> /1/home/taskere/yt/src/yt-1.7-svn/yt/lagos/DerivedQuantities.py in
> _MaxLocation(data, field)
> 445 """
> 446 ma, maxi, mx, my, mz, mg = -1e90, -1, -1, -1, -1, -1
> --> 447 if data[field].size > 0:
> 448 maxi = na.argmax(data[field])
> 449 ma = data[field][maxi]
>
> /1/home/taskere/yt/src/yt-1.7-svn/yt/lagos/DerivedQuantities.py in
> __getitem__(self, item)
> 41 return getattr(self.grid, attr)
> 42 def __getitem__(self, item):
> ---> 43 return self.data_source._get_data_from_grid(self.grid, item)
> 44
> 45 class DerivedQuantity(ParallelAnalysisInterface):
>
> /1/home/taskere/yt/src/yt-1.7-svn/yt/lagos/BaseDataTypes.py in
> save_state(self, grid, field)
> 41 old_keys = grid.data.keys()
> 42 grid.field_parameters = self.field_parameters
> ---> 43 tr = func(self, grid, field)
> 44 grid.field_parameters = old_params
> 45 grid.data = dict( [(k, grid.data[k]) for k in old_keys] )
>
> /1/home/taskere/yt/src/yt-1.7-svn/yt/lagos/BaseDataTypes.py in
> _get_data_from_grid(self, grid, field)
> 1681 else:
> 1682 pointI = self._get_point_indices(grid)
> -> 1683 if grid[field].size == 1: # dx, dy, dz, cellvolume
> 1684 t = grid[field] * na.ones(grid.ActiveDimensions,
> dtype='float64')
> 1685 return t[pointI].ravel()
>
> /1/home/taskere/yt/src/yt-1.7-svn/yt/lagos/BaseGridType.py in
> __getitem__(self, key)
> 133 """
> 134 if not self.data.has_key(key):
> --> 135 self.get_data(key)
> 136 return self.data[key]
> 137
>
> /1/home/taskere/yt/src/yt-1.7-svn/yt/lagos/BaseGridType.py in get_data(self,
> field)
> 176 else: raise
> 177 else:
> --> 178 self._generate_field(field)
> 179 return self.data[field]
> 180
>
> /1/home/taskere/yt/src/yt-1.7-svn/yt/lagos/BaseGridType.py in
> _generate_field(self, field)
> 111 # First we check the validator
> 112 try:
> --> 113 self.pf.field_info[field].check_available(self)
> 114 except NeedsGridType, ngt_exception:
> 115 # This is only going to be raised if n_gz > 0
>
> /1/home/taskere/yt/src/yt-1.7-svn/yt/lagos/field_info_container.py in
> check_available(self, data)
> 283 """
> 284 for validator in self.validators:
> --> 285 validator(data)
> 286 # If we don't get an exception, we're good to go
> 287 return True
>
> /1/home/taskere/yt/src/yt-1.7-svn/yt/lagos/field_info_container.py in
> __call__(self, data)
> 381 doesnt_have.append(f)
> 382 if len(doesnt_have) > 0:
> --> 383 raise NeedsDataField(doesnt_have)
> 384 return True
> 385
>
> NeedsDataField: (['Density'])
>
>
> Which looks like it is requiring a density field?
>
> Elizabeth
>
>
Yup, it's trying to center on the most dense point. You can specify a
center with:
pc = PlotCollection(pf, center = [0.5, 0.5, 0.5])
I believe it has correctly guessed the data type, but if you run into
another issue with this try:
pf = EnzoStaticOutput(fn, data_style="enzo_packed_3d")
Best,
Matt
More information about the yt-users
mailing list