
Hi all,
I'm trying to create two derived fields (one for stellar density, and one for dark matter density) based on https://bitbucket.org/yt_analysis/yt/src/cee2a160c5351c376afea65bea3462792406154e/yt/frontends/enzo/fields.py?at=yt-2.x&fileviewer=file-view-default#fields.py-350 these https://bitbucket.org/yt_analysis/yt/src/cee2a160c5351c376afea65bea3462792406154e/yt/frontends/enzo/fields.py?at=yt-2.x&fileviewer=file-view-default#fields.py-394 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?
Thanks,
Rasmi