On Fri, May 20, 2016 at 1:36 PM, Rasmi Elasmar <re2300@columbia.edu> wrote:
Hi all,

I'm trying to create two derived fields (one for stellar density, and one for dark matter density) based on these from yt2. I'm running yt 3.2.3, and the star_density and dm_density fields seem to have been removed. So far, the yt2 code has transferred fine, with minimal changes:
  • amrutils.CICDeposit_3() -> amrutils.CICDeposit.CICDeposit_3()
  • np.float64(data['dx']) -> np.float64(np.ravel(data['dx'])[0]
    • (data['dx'] appears to be a multidimensional array of all the same values of dx, so I'm just taking the first one -- is there a better way to do this?)
Besides those two quirks, the code runs (I'm able to add a field using ds.add_field), but I get an error when I try to access the data using ds.all_data()['star_density'] (it seems now is when the field is actually computed).

I get the following error:
<ipython-input-5-1af8fbcb718a> in _spdensity(field, data)
      1 def _spdensity(field, data):
----> 2     blank = np.zeros(data.ActiveDimensions, dtype='float64')
      3     if data['particle_position_x'].size == 0: return blank
      4     filter = data['creation_time'] > 0.0
      5     if not filter.any(): return blank
AttributeError: 'YTRegion' object has no attribute 'ActiveDimensions'

All the examples of ActiveDimensions that I saw in the docs and source accessed ActiveDimensions as a property of some grid (i.e. g.ActiveDimensions). Is there a simple way to access that from the data/YTRegion object that I'm missing? I can access ds.index.grids and take the first grid there, but ActiveDimensions differs across the grids (And when I try to do this from within _spdensity, data doesn't have an index.grids object, just fake_index (which can't access the grids)). Is there something I'm missing?



Hi Rasmi,

Rather than directly porting your scripts from yt-2, which will be a bit painful, it would be much easier to use built-in features of yt-3 to accomplish this. In particular, you want to use particle filters and deposited fields.

Here is a worked example where I construct "star" and "dark matter" particle filters for an Enzo dataset, then plot the deposited density of these two particle types.


Here's some more documentation on particle filters and deposited particle fields:


Hope that's helpful,


yt-dev mailing list