<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 20, 2016 at 1:36 PM, Rasmi Elasmar <span dir="ltr"><<a href="mailto:re2300@columbia.edu" target="_blank">re2300@columbia.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>I'm trying to create two derived fields (one for stellar density, and one for dark matter density) based <a href="https://bitbucket.org/yt_analysis/yt/src/cee2a160c5351c376afea65bea3462792406154e/yt/frontends/enzo/fields.py?at=yt-2.x&fileviewer=file-view-default#fields.py-350" target="_blank">on</a> <a href="https://bitbucket.org/yt_analysis/yt/src/cee2a160c5351c376afea65bea3462792406154e/yt/frontends/enzo/fields.py?at=yt-2.x&fileviewer=file-view-default#fields.py-394" target="_blank">these</a> 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:</div><ul><li>amrutils.CICDeposit_3() -> amrutils.CICDeposit.CICDeposit_3()<br></li><li>np.float64(data['dx']) -> np.float64(np.ravel(data['dx'])[0]</li><ul><li>(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?)</li></ul></ul><div>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).</div><div><br></div><div>I get the following error:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span><ipython-input-5-1af8fbcb718a></span><span> in </span><span>_spdensity</span><span>(field, data)<br></span><span>      1</span><span> </span><span>def</span><span> _spdensity</span><span>(</span><span>field</span><span>,</span><span> data</span><span>):<br></span><span>----> 2</span><span>     </span><span>blank </span><span>=</span><span> np</span><span>.</span><span>zeros</span><span>(</span><span>data</span><span>.</span><span>ActiveDimensions</span><span>,</span><span> dtype</span><span>=</span><span>'float64'</span><span>)<br></span><span>      3</span><span>     </span><span>if</span><span> data</span><span>[</span><span>'particle_position_x'</span><span>].</span><span>size </span><span>==</span><span> </span><span>0</span><span>:</span><span> </span><span>return</span><span> blank<br></span><span>      4</span><span>     filter </span><span>=</span><span> data</span><span>[</span><span>'creation_time'</span><span>]</span><span> </span><span>></span><span> </span><span>0.0<br></span><span>      5</span><span>     </span><span>if</span><span> </span><span>not</span><span> filter</span><span>.</span><span>any</span><span>():</span><span> </span><span>return</span><span> blank</span><br><span>AttributeError</span><span>: 'YTRegion' object has no attribute 'ActiveDimensions'</span></blockquote>













<p><span></span></p>
<div>













<p><span></span></p>
</div><div><br></div><div>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?</div><div><br></div><div><br></div><div>Thanks,</div><div><br></div><div>Rasmi</div></div></blockquote><div><br></div><div>Hi Rasmi,</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div><a href="https://gist.github.com/b13bd7a545dda6819972eaaaf81e83f8">https://gist.github.com/b13bd7a545dda6819972eaaaf81e83f8</a><br></div><div><br></div><div>Here's some more documentation on particle filters and deposited particle fields:</div><div><br></div><div><a href="http://yt-project.org/docs/dev/analyzing/filtering.html#filtering-particle-fields">http://yt-project.org/docs/dev/analyzing/filtering.html#filtering-particle-fields</a><br></div><div><a href="http://yt-project.org/docs/dev/analyzing/fields.html#deposited-particle-fields">http://yt-project.org/docs/dev/analyzing/fields.html#deposited-particle-fields</a><br></div><div><br></div><div>Hope that's helpful,</div><div><br></div><div>Nathan</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>_______________________________________________<br>
yt-dev mailing list<br>
<a href="mailto:yt-dev@lists.spacepope.org">yt-dev@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</a><br>
<br></blockquote></div><br></div></div>