Hello all,
I am wanting to use pynbody to go through each DM particle in a halo and find the nearest 32 gas particles to use sph to get the weighted average of gas density, temperature, and other properties, weighting it by the gas particle's distance from the DM particle. Reading through the pynbody files, it seems like this is totally accomplishable especially when reading people's posts such as
"Using Pynbody KDTree",
#PR601, and other similar posts.
However, when I am calling functions such as sph.rho(), kdtree.all_nn(), sph.smooth(), and others I cannot get it to only search for the nearest 32 gas particles at each dark matter particle's position, but rather it simply searches for the nearest 32 particles to each dm particle (which most of the time is exclusively dm particles from how many there are). I've thought about playing with families to essentially create a dummy family with the dm particle's position and then essentially get rid of the dark matter particles entirely (just to try and filter them out of the search), but have been unsuccessful in this.
Also a lot of the time when I'm playing with functions such as pynbody.sph.kdmain.nn_next() it gives a segmentation fault error.
Further when playing with sph.smooth() and kdtree.all_nn() it will give me a smoothing length (which I am assuming is the radius containing the 32 nearest particles). However, when I create a filtering sphere of that smoothing radius at the same particle it contains far fewer than 32 particles and the spheres don't all contain the same number of particles. kdtree.all_nn() displays the smoothing length and then gives the distance to the n nearest particles, but most of the distances are above the smoothing length. Further when I created a sphere over the max distance listed in kdtree.all_nn() for a particle, the sphere contained more particles than the n nearest neighbors it was told to find. Any advice on what this smoothing number actually is would be helpful as well as general information about the array given by kdtree.all_nn().
If anyone has any advice or suggestions on how to best find the nearest 32 gas neighbors, it would be greatly appreciated.
Thank you very much,
Nolan McPhaul