return data["particle_mass"] <= 1.01 * min_dm_mass add_particle_filter("max_res_dark_matter", function=MaxResDarkMatter, \ filtered_type='dark_matter', requires=["particle_mass"]) ds.add_particle_filter('max_res_dark_matter') # If desired, we can see the total number of DM and High-res DM particles #if yt.is_root(): # print("Simulation has %d DM particles." % # ad['dark_matter','particle_type'].shape) # print("Simulation has %d Highest Res DM particles." % # ad['max_res_dark_matter', 'particle_type'].shape) # Run the halo catalog on the dataset only on the highest resolution dark matter # particles hc = HaloCatalog(data_ds=ds, finder_method='rockstar', \ finder_kwargs={'dm_only':True, 'particle_type':'max_res_dark_matter'}) hc.create() # Or alternatively, just run the RockstarHaloFinder and later import the # output file as necessary. You can skip this step if you've already run it # once, but be careful since subsequent halo finds will overwrite this data. #rhf = RockstarHaloFinder(ds, particle_type="max_res_dark_matter") #rhf.run() # Load the halo list from a rockstar output for this dataset # Create a projection with the halos overplot on top #halos = yt.load('rockstar_halos/halos_0.0.bin') #hc = HaloCatalog(halos_ds=halos) #hc.load() # Regardless of your method of creating the halo catalog, use it to overplot the # halos on a projection.
# and apply it to dataset def MaxResDarkMatter(pfilter, data): return data["particle_mass"] <= 1.01 * min_dm_mass add_particle_filter("max_res_dark_matter", function=MaxResDarkMatter, \ filtered_type='dark_matter', requires=["particle_mass"]) ds.add_particle_filter('max_res_dark_matter') # If desired, we can see the total number of DM and High-res DM particles #if yt.is_root(): # print "Simulation has %d DM particles." % ad['dark_matter','particle_type'].shape # print "Simulation has %d Highest Res DM particles." % ad['max_res_dark_matter', 'particle_type'].shape # Run the halo catalog on the dataset only on the highest resolution dark matter # particles hc = HaloCatalog(data_ds=ds, finder_method='rockstar', \ finder_kwargs={'dm_only':True, 'particle_type':'max_res_dark_matter'}) hc.create() # Or alternatively, just run the RockstarHaloFinder and later import the # output file as necessary. You can skip this step if you've already run it # once, but be careful since subsequent halo finds will overwrite this data. #rhf = RockstarHaloFinder(ds, particle_type="max_res_dark_matter") #rhf.run() # Load the halo list from a rockstar output for this dataset # Create a projection with the halos overplot on top #halos = yt.load('rockstar_halos/halos_0.0.bin') #hc = HaloCatalog(halos_ds=halos) #hc.load() # Regardless of your method of creating the halo catalog, use it to overplot the # halos on a projection.
import yt from yt.analysis_modules.halo_analysis.halo_catalog import HaloCatalog # Load the dataset ds = yt.load("Enzo_64/RD0006/RedshiftOutput0006") # Load the halo list from a rockstar output for this dataset halos = yt.load('rockstar_halos/halos_0.0.bin') # Create the halo catalog from this halo list hc = HaloCatalog(halos_ds=halos) hc.load() # Create a projection with the halos overplot on top p = yt.ProjectionPlot(ds, "x", "density") p.annotate_halos(hc) p.save()