<div dir="ltr">Hi Josh,<div><br></div><div>I agree with Matt.  I don't see any reason to sort.  I'm not terribly familiar with this area of the code, but please give a shot at fixing this and issue a PR if it works.  This area of the code will eventually get redesigned, but I'm not sure when, so let's at least get this working right for now.</div>
<div><br></div><div>Britton</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 9, 2014 at 4:06 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">Hi Josh,<br>
<div><div class="h5"><br>
On Tue, Apr 8, 2014 at 7:17 PM, Josh Moloney<br>
<<a href="mailto:Joshua.Moloney@colorado.edu">Joshua.Moloney@colorado.edu</a>> wrote:<br>
> Recently I've been working with the HOP halo finder in yt 3.0. In particular<br>
> I've been looking at star particles from Enzo simulations in halos of<br>
> different sizes. I've been running into strange results with particle fields<br>
> that are stored in the halo hdf5 files vs particle fields that have to be<br>
> retrieved from the original simulation data. In particular, if I create a<br>
> mask for star particles from a field saved to disk (creation_time prior to<br>
> 3.0 or ParticleMassMsun now) then I get the correct values for other fields<br>
> when I use this mask if they were also saved to disk (so particle positions<br>
> or velocities) but not for fields that were retrieved from the simulation<br>
> (such as dynamical time). Similarly, if I identify stars by creation_time in<br>
> 3.0 (when it isn't saved in the hdf5 file) then I get the correct<br>
> dynamical_times, but incorrect particle masses.<br>
> I think I've identified the source of this problem. When the<br>
> "particle_index" field is read from the halo hdf5 files, it is then sorted<br>
> into ascending order. In particular, in __getitem__ in the LoadedHalo class<br>
> there is the following (this is line ~867 in halo_objects in the 3.0<br>
> experimental branch):<br>
><br>
> field_data = self._get_particle_data(<a href="http://self.id" target="_blank">self.id</a>, self.fnames, self.size, key)<br>
> if field_data is not None:<br>
>     if key == 'particle_index':<br>
>          field_data = field_data[field_data.argsort()]<br>
><br>
> These sorted particle indices are then used when retrieving fields from the<br>
> simulation data, so the fields end up being sorted in a different order than<br>
> the ones that are retrieved directly from the halo hdf5 files. As a result,<br>
> masks created from one set of fields don't work properly on the other set.<br>
> I think that I can fix this, but before I do I want to make sure I'm not<br>
> going to be breaking anything else in the process. Does anyone know why the<br>
> particle_index field was being sorted? If so, do you happen to know whether<br>
> it would make more sense to sort the other particle fields from disk or<br>
> leave particle_index unsorted? Thanks in advance for any help.<br>
<br>
</div></div>My inclination is that we should fix the behavior -- which I believe<br>
means not sorting the particles.  That being said, I am not familiar<br>
with where this gets used, so perhaps Britton or someone else can<br>
chime in?  I believe Britton has envisioned a teardown of the existing<br>
functionality.<br>
<br>
-Matt<br>
<br>
>        - Josh<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>
</blockquote></div><br></div>