question about spheres
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
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
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
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
Hi Stephanie, It may be the case that there's some implicit particle selection going on. I don't think the sphere *center* will jump to the center of a cell, though. Can you try setting up a particle union that includes all the particle types you want, and selecting on that? On Tue, Mar 2, 2021 at 4:54 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
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
_______________________________________________ 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
Yes, okay, I have gotten around my Enzo problem and am back to my yt problem. So I have this nice little loop that reads in my particle position, creates a sphere, and lists me out the particle ids of everything in that sphere. #######Step 1, read in my file of particle ids and positons######### starfile = np.loadtxt(namefile+'_'+loop[i]+'_starinfo_allparts.txt') pid = starfile[:,1] px = starfile[:,4] py = starfile[:,5] pz = starfile[:,6] ######Step 2, read in my simulation output##### ds = yt.load("/mnt/ceph/users/rsmith/RPSsfbb6lM10qfcdw/DD"+loop[i]+"/"+namefile+loop[i]) ########Step 3, use the particle positions to make a sphere, and list all the particle ids in that sphere#### j = 0 while j < len(pid): print(pid[j]) sp = ds.sphere([px[j]/25.,py[j]/25.,pz[j]/25.],(6.0,'pc')) print(sp["particle_index"]) print(sp["particle_mass"]) ##############Step 4, check out my print statements: 7.0 [ 2. 4. 7. 1.] dimensionless [ 1.98741722e+34 1.98761869e+34 1.98803606e+34 1.98713590e+34] g 1.0 [ 2. 1. 5.] dimensionless [ 1.98741722e+34 1.98713590e+34 1.98795665e+34] g Look up there! the sphere around particle 7.0 includes particle 1.0, but the sphere around particle 1.0 does not include particle 7.0! My brute force calculation finds the particles to be 4.85 pc apart, and my minimum cell size is 1.5 pc. Not sure about the cells at this position (although my guess is that they are fully resolved to that level). Any guidance is much appreciated! I can brute force this, but it is probably worth figuring out if this is a yt bug or feature. Thanks as always, Stephanie -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY stonnes@gmail.com On Wed, Mar 3, 2021 at 6:42 AM Matthew Turk <matthewturk@gmail.com> wrote:
Hi Stephanie,
It may be the case that there's some implicit particle selection going on. I don't think the sphere *center* will jump to the center of a cell, though.
Can you try setting up a particle union that includes all the particle types you want, and selecting on that?
On Tue, Mar 2, 2021 at 4:54 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
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
_______________________________________________ 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
participants (2)
-
Matthew Turk
-
Stephanie Tonnesen