<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Hi Matt,</span><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Moving this to the correct thread (with additions):</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">The change you suggested solved the problem of</div><div style="font-family:arial,sans-serif;font-size:13px">
ad['DarkMatter', 'particle_mass']</div><div style="font-family:arial,sans-serif;font-size:13px">and</div><div style="font-family:arial,sans-serif;font-size:13px">ad['CenOstriker', 'particle_mass']</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">However, when I do:</div><div style="font-family:arial,sans-serif;font-size:13px">ad['all', 'particle_mass']</div>
<div style="font-family:arial,sans-serif;font-size:13px">I get the following:</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><div>Traceback (most recent call last):</div>
<div>  File "<stdin>", line 1, in <module></div><div>  File "/Users/britton/Documents/work/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py", line 189, in __getitem__</div><div>    self.get_data(f)</div>
<div>  File "/Users/britton/Documents/work/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py", line 535, in get_data</div><div>    particles, self, self._current_chunk)</div><div>  File "/Users/britton/Documents/work/yt/yt-x86_64/src/yt-hg/yt/geometry/geometry_handler.py", line 507, in _read_particle_fields</div>
<div>    fields_to_read)</div><div>  File "/Users/britton/Documents/work/yt/yt-x86_64/src/yt-hg/yt/utilities/io_handler.py", line 176, in _read_particle_selection</div><div>    rv[field_f][my_ind:my_ind + vals.shape[0],...] = vals</div>
<div>ValueError: could not broadcast input array from shape (4851) into shape (4361)</div></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Additionally, if I do:</div>
<div style="font-family:arial,sans-serif;font-size:13px">ad['io', 'particle_mass']</div><div style="font-family:arial,sans-serif;font-size:13px">I get this (which I got before this change as well):</div><div style="font-family:arial,sans-serif;font-size:13px">
<div>Traceback (most recent call last):</div><div>  File "<stdin>", line 1, in <module></div><div>  File "/Users/britton/Documents/work/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py", line 183, in __getitem__</div>
<div>    f = self._determine_fields(key)[0]</div><div>  File "/Users/britton/Documents/work/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py", line 406, in _determine_fields</div><div>    raise YTFieldTypeNotFound(ftype)</div>
<div>yt.utilities.exceptions.YTFieldTypeNotFound: Could not find field 'io'.</div><div><br></div><div>The 'io' issue seems to come from line 848 in enzo/data_structures.py:</div><div><div>            # If this is the case, then we know we should have a DarkMatter</div>
<div>            # particle type, and we don't need the "io" type.</div><div>            self.particle_types = ["DarkMatter"]</div></div><div><br></div><div>Would it be better to switch that to an append and keep the "io" type around for generality?  I don't know if that would actually be a good idea since in reality it is just the dark matter for Enzo-3.0 data.</div>
<div><br></div><div>Britton</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 2, 2013 at 3:41 PM, Matthew Turk <span dir="ltr"><<a href="mailto:matthewturk@gmail.com" target="_blank">matthewturk@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">That looks like a failure to convert correctly.  What goes on during<br>
instantiation is that for each particle type, the function<br>
_setup_particle_type is called on EnzoStaticOutput.  Then the<br>
_setup_particle_fields from enzo/fields.py gets called, which should<br>
set the "particle_mass" function to convert based on Density * cm**3.<br>
(Note that we now -- in _read_particle_fields -- multiply by the<br>
grid.dds.prod, so it doesn't need that anywhere else anymore.)<br>
<br>
Can you check what pf._get_field_info("DarkMatter", "particle_mass")<br>
has for its _convert_function ?  It should be a function called<br>
_convertParticleMass.<br>
<br>
I have to go for a few hours, but I can look at an E3 dataset when I get back.<br>
<br>
-Matt<br>
<div class="HOEnZb"><div class="h5"><br>
On Mon, Dec 2, 2013 at 10:33 AM, Britton Smith <<a href="mailto:brittonsmith@gmail.com">brittonsmith@gmail.com</a>> wrote:<br>
> I am getting this with just "DarkMatter" and "CenOstriker", which are not<br>
> exactly filters (or maybe they are), but the particle types as they are<br>
> stored on disk by Enzo-3.0.<br>
><br>
><br>
> On Mon, Dec 2, 2013 at 3:30 PM, Matthew Turk <<a href="mailto:matthewturk@gmail.com">matthewturk@gmail.com</a>> wrote:<br>
>><br>
>> On Mon, Dec 2, 2013 at 10:29 AM, Britton Smith <<a href="mailto:brittonsmith@gmail.com">brittonsmith@gmail.com</a>><br>
>> wrote:<br>
>> > Hi Matt,<br>
>> ><br>
>> > Thanks, that's very helpful.<br>
>> ><br>
>> > I have an additional question.  When I do:<br>
>> > ad = pf.h.all_data()<br>
>> > ad['particle_mass'] or<br>
>> > ad['all', 'particle_mass']<br>
>> ><br>
>> > I get numbers that are ~1e44, which sounds about right if it's in grams.<br>
>> > However, when I do:<br>
>> > ad['DarkMatter', 'particle_mass']<br>
>> ><br>
>> > I get numbers that are ~1e-5, which I am guessing is the unconverted<br>
>> > particle_mass straight out of the file.  How can get the filtered<br>
>> > particles<br>
>> > in proper units as well?<br>
>> ><br>
>><br>
>> Hm, that looks like a bug to me.  What's your filter look like, so I<br>
>> can reproduce this here?<br>
>><br>
>> > Thanks again,<br>
>> > Britton<br>
>> ><br>
>> ><br>
>> > On Mon, Dec 2, 2013 at 3:21 PM, Matthew Turk <<a href="mailto:matthewturk@gmail.com">matthewturk@gmail.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >> Hey Britton,<br>
>> >><br>
>> >> On Mon, Dec 2, 2013 at 10:15 AM, Britton Smith <<a href="mailto:brittonsmith@gmail.com">brittonsmith@gmail.com</a>><br>
>> >> wrote:<br>
>> >> > Hi all,<br>
>> >> ><br>
>> >> > Can someone point me to an example (docs, notebooks, emails,<br>
>> >> > whatever)<br>
>> >> > of<br>
>> >> > defining a custom particle filter for yt-3.0?  I'm trying to do this<br>
>> >> > and<br>
>> >> > I<br>
>> >> > know I've seen discussion of this before, but I can't find where.<br>
>> >> ><br>
>> >><br>
>> >> Yup.  Here's an example:<br>
>> >><br>
>> >><br>
>> >><br>
>> >> <a href="http://nbviewer.ipython.org/url/hub.yt-project.org/notebooks/534fd19b933e4a3fa002db91f58fb817.ipynb" target="_blank">http://nbviewer.ipython.org/url/hub.yt-project.org/notebooks/534fd19b933e4a3fa002db91f58fb817.ipynb</a><br>

>> >><br>
>> >> Looks like the nbviewer is down though.<br>
>> >><br>
>> >> Sorry I haven't done much documenting of this.  Particle filters and<br>
>> >> particle unions are two really cool things that are currently only in<br>
>> >> example form.  Here's another example of how to define one:<br>
>> >><br>
>> >><br>
>> >><br>
>> >> <a href="https://bitbucket.org/mornkr/agora-analysis-script/src/1200830cd1e8d7dc60f66c8f1dc7c09764ca3276/script-Flagship-DM.py?at=default#cl-33" target="_blank">https://bitbucket.org/mornkr/agora-analysis-script/src/1200830cd1e8d7dc60f66c8f1dc7c09764ca3276/script-Flagship-DM.py?at=default#cl-33</a><br>

>> >><br>
>> >> and you have to add this by name to each pf you open up:<br>
>> >><br>
>> >><br>
>> >><br>
>> >> <a href="https://bitbucket.org/mornkr/agora-analysis-script/src/1200830cd1e8d7dc60f66c8f1dc7c09764ca3276/script-Flagship-DM.py?at=default#cl-57" target="_blank">https://bitbucket.org/mornkr/agora-analysis-script/src/1200830cd1e8d7dc60f66c8f1dc7c09764ca3276/script-Flagship-DM.py?at=default#cl-57</a><br>

>> >><br>
>> >> Note that you have to specify *all* the required filtering fields in<br>
>> >> the constructor for the function.<br>
>> >><br>
>> >> -Matt<br>
>> >><br>
>> >> > Thanks,<br>
>> >> > Britton<br>
>> >> ><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" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</a><br>
>> >> ><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" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</a><br>
>> ><br>
>> ><br>
>> ><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" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</a><br>
>> ><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" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</a><br>
><br>
><br>
><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" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</a><br>
><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" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</a><br>
</div></div></blockquote></div><br></div>