Hi Sean,

Sorry to take so long to get back to you on this. You should be able to accomplish this with the `particle_radius` field. Let me know if that doesn't work. We'll try to be a bit more responsive.

Britton

On Fri, Apr 17, 2020 at 7:58 PM Sean Larkin via yt-users <yt-users@python.org> wrote:
Hello All,

I am trying to calculate the Mvir/Rvir based on the Bryan Norman definition using yt. I currently have a catalog of halos generated by running rockstar on the darkmatter particles of an ART simulation, and am trying to use the same centers to recalculate these values including the stellar and gas contents of each object. From looking into some of the yt processes, I thought that the profile function would be a perfect tool, but it seems like there is a bit of a problem with particle grids vs mesh grids that I am not sure if there is a way around.

My goal was to use the yt.create_profile function to create a radial profile of the different masses using the following script:

import yt
from yt import YTQuantity

largest_halo = consistent.halo_data_sorted[30][0]

ds = yt.load('/Users/user1/documents/GEN6/VELA07_snap/10MpcBox_csf512_a0.400.d')

x = ds.quan(float(largest_halo[17]), 'Mpccm/h')
y = ds.quan(float(largest_halo[18]), 'Mpccm/h')
z = ds.quan(float(largest_halo[19]), 'Mpccm/h')
rvir = ds.quan(float(largest_halo[11]), 'kpccm/h')
center = [x, y, z]

sp = ds.sphere(center, (float(rvir.in_units('kpc'))*2, 'kpc'))

rp = yt.create_profile(sp, 'radius', [('gas', 'density')], n_bins=4, accumulation = True,
                           units = {'radius': 'kpc', 'density': 'Msun/kpc**3'})

rp1 = yt.create_profile(sp, 'radius', [('all', 'particle_mass')], n_bins=4, accumulation = True,
                           units = {'radius': 'kpc'}, weight_field='particle_mass')


This works perfectly for the gas, but I get the following error for the profile calculating the particle masses:

YTIllDefinedProfile:
Cannot create a profile object that mixes particle and mesh fields.

Received the following bin_fields:

   ('index', 'radius'), particle_type = False

Profile fields:

   ('all', 'particle_mass'), particle_type = True

And weight field:

   ('all', 'particle_mass'), particle_type = True

I am wondering if there is another radial-like field/it is possible to create such a field to make this profile properly match the particle_type? If not, are there any other yt functions that would simplify such an Mvir/Rvir calculation. I know it is possible to do this with a ds.sphere script call that varies the size of the region until the proper ratio is found, but I imagine that would not be a super efficient method, and it also might be interesting to see the density profile of each halo object outside of calculating its Mvir/Rvir.

Thank you for your time!
_______________________________________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org