Aright, so I have not done anything about the sphere problem--is the sphere center shifting to a cell center? issue.

But I redid my particle selection without the star particle filter and was able to find all the particles.  I think I missed this last time, but I just followed the cookbook and did this:

def Stars(pfilter,data):
    filter = data[(pfilter.filtered_type,"particle_type")] == 2
    return filter

yt.add_particle_filter("stars",function=Stars, filtered_type='all',requires=["particle_type"])

before this:
    ds.add_particle_filter('stars')
    ad = ds.all_data()
   
    mass = ad[("stars","particle_mass")].in_units('Msun')
    age = ad[("stars","age")].in_units('Myr')
    ct = ad[("stars","creation_time")].in_units('Myr')
    velz = ad[("stars","particle_velocity_z")].in_units('cm/s')
    velx = ad[("stars","particle_velocity_x")].in_units('cm/s')
    vely = ad[("stars","particle_velocity_y")].in_units('cm/s')
    pid = ad[("stars","particle_index")]
    px = ad[("stars","particle_position_x")].in_units('kpc')
    pz = ad[("stars","particle_position_z")].in_units('kpc')
    py = ad[("stars","particle_position_y")].in_units('kpc')

so this time instead of "stars" I just put "all" and this allowed me to find the missing particles.  Which is very strange and perhaps not a yt problem but actually an Enzo thing.  

So the only outstanding yt question then is why some particles within the sphere as I brute-force calculate it are not caught when using ds.sphere with the center defined as a particle position.  

Thanks,
Stephanie


--
Dr. Stephanie Tonnesen
Associate Research Scientist
CCA, Flatiron Institute
New York, NY

stonnes@gmail.com


On Fri, Feb 26, 2021 at 11:46 AM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Okay, looking into this a bit more has led to two I think unrelated problems.  One problem, which has to do with the sphere selection:  

When I loop through my particles, the sphere centered on particle_index "3"  only finds particle "3".  However, the sphere centered on particle "8" includes particle "3".  Also, my brute-force method finds that "8" is within 6 pc of "3".  

Second, my particle identification method has a problem:

So I read in a file and then do this:

    ds.add_particle_filter('stars')
    ad = ds.all_data()
   
    mass = ad[("stars","particle_mass")].in_units('Msun')
    age = ad[("stars","age")].in_units('Myr')
    ct = ad[("stars","creation_time")].in_units('Myr')
    velz = ad[("stars","particle_velocity_z")].in_units('cm/s')
    velx = ad[("stars","particle_velocity_x")].in_units('cm/s')
    vely = ad[("stars","particle_velocity_y")].in_units('cm/s')
    pid = ad[("stars","particle_index")]
    px = ad[("stars","particle_position_x")].in_units('kpc')
    pz = ad[("stars","particle_position_z")].in_units('kpc')
    py = ad[("stars","particle_position_y")].in_units('kpc')

Then I save all this info to play around with later.  NOW things get weird.  When I search around the particles identified above using their positions and ds.sphere, I find particles that NEVER were identified!  (I do not have DM particles in this simulation).  Any thoughts on this problem, too?

Thanks in advance,
Stephanie


--
Dr. Stephanie Tonnesen
Associate Research Scientist
CCA, Flatiron Institute
New York, NY

stonnes@gmail.com


On Fri, Feb 26, 2021 at 9:41 AM Matthew Turk <matthewturk@gmail.com> wrote:
Hi Stephanie,

Hmm, this is curious.  My first inclination is to suggest comparing the particle_index or particle_ones fields rather than mass, to make sure we're looking at precisely the same information.  If that's not the culprit, then we should investigate if the *grids* are being passed over by sphere selection or if the particles themselves are.

On Thu, Feb 25, 2021 at 3:00 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Hi yt-users,

I have a question about spheres, because I am having a problem that I don't really know how to solve.  Basically, I have clusters of stars, and I want to know how many stars are within 6 pc of each star.  So, what I have done is taken a sphere at each star position with a radius of 6 pc, and then performed 

sp.quantities.total_quantity(["particle_mass"])

Now I wanted to double-check this number by brute-force, so I calculated the distance between all the particles and then summed the masses of all the particles that were less than 6 pc.  

I am not getting the same values--they are close, but not the same (they seem to mostly scatter up or down by a factor of 2).  

So...to the question!!  Because I am measuring particles in a grid code (Enzo) is there any sort of shifting to the grid position instead of using the particle positions here? Because stars are pretty packed I could imagine that this could cause the differences I am seeing.

I am not sure that the problem is not something silly I am doing, but wanted to check this possibility as well.

Thanks!
Stephanie

--
Dr. Stephanie Tonnesen
Associate Research Scientist
CCA, Flatiron Institute
New York, NY

stonnes@gmail.com
_______________________________________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org
https://mail.python.org/mailman3/lists/yt-users.python.org/
Member address: matthewturk@gmail.com
_______________________________________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org
https://mail.python.org/mailman3/lists/yt-users.python.org/
Member address: stonnes@gmail.com