def load_halos(ds,location): #Merely loads an already saved halocatalog #Calls a fn to gather positions and radii of halos over a mass threshold halo_ds = yt.load(location) hc = HaloCatalog(data_ds=ds,halos_ds=halo_ds) hc.add_filter('quantity_value','particle_mass','>',1E12,'Msun') halo_ds = hc.halos_ds.all_data() radii, positions = get_halo_pos(ds,halo_ds) return hc, radii, positions
def generate_halos(ds,dsname): #function to find the halos for the given dataset, using the HOP finder #Calls a fn to gather positions and radii of halos over a mass threshold #Autosaves the HC hc = HaloCatalog(data_ds=ds,finder_method='hop',finder_kwargs={'threshold':300,'padding':0.04},output_dir="".join(['~/',dsname])) hc.add_filter('quantity_value','particle_mass','>',1E12,'Msun') hc.create() hc = hc.halos_ds.all_data() radii, positions = get_halo_pos(ds,hc) return hc, radii, positions
import yt from yt.analysis_modules.halo_analysis.api import HaloCatalog # Load the data set with the full simulation information # and rockstar halos data_ds = yt.load('Enzo_64/RD0006/RedshiftOutput0006') halos_ds = yt.load('rockstar_halos/halos_0.0.bin') # Instantiate a catalog using those two paramter files hc = HaloCatalog(data_ds=data_ds, halos_ds=halos_ds) # Filter out less massive halos hc.add_filter("quantity_value", "particle_mass", ">", 1e14, "Msun") # attach a sphere object to each halo whose radius extends # to twice the radius of the halo hc.add_callback("sphere", factor=2.0) # use the sphere to calculate radial profiles of gas density # weighted by cell volume in terms of the virial radius hc.add_callback("profile", x_field="radius", y_fields=[("gas", "overdensity")], weight_field="cell_volume", accumulation=False, storage="virial_quantities_profiles") hc.add_callback("virial_quantities", ["radius"], profile_storage="virial_quantities_profiles") hc.add_callback('delete_attribute', 'virial_quantities_profiles')
x = halo.quantities['particle_position_x'] y = halo.quantities['particle_position_y'] z = halo.quantities['particle_position_z'] return (lower_bound < x < upper_bound) and (lower_bound < y < upper_bound) and (lower_bound < z < upper_bound) def filter_particles(halo): """ Checks to see if there are more than a certain number of particles within a sphere. """ minimum_particles = 50000 x = halo.quantities['particle_position_x'] y = halo.quantities['particle_position_y'] z = halo.quantities['particle_position_z'] sphere = halo.halo_catalog.data_ds.sphere([x, y, z], (30, 'kpc')) n_particles = len(sphere['x']) return n_particles > minimum_particles # Add to the filter registry. add_filter('position', filter_position) add_filter('particles', filter_particles) # Run the analysis. hc.add_filter('quantity_value', 'particle_mass', '<', 1e13, 'Msun') hc.add_callback('iterative_center_of_mass') hc.add_filter('position') hc.add_filter('particles') hc.create()
import yt from yt.analysis_modules.halo_analysis.api import HaloCatalog # Load the data set with the full simulation information # and rockstar halos data_ds = yt.load('Enzo_64/RD0006/RedshiftOutput0006') halos_ds = yt.load('rockstar_halos/halos_0.0.bin') # Instantiate a catalog using those two paramter files hc = HaloCatalog(data_ds=data_ds, halos_ds=halos_ds) # Filter out less massive halos hc.add_filter("quantity_value", "particle_mass", ">", 1e14, "Msun") # attach a sphere object to each halo whose radius extends # to twice the radius of the halo hc.add_callback("sphere", factor=2.0) # use the sphere to calculate radial profiles of gas density # weighted by cell volume in terms of the virial radius hc.add_callback("profile", ["radius"], [("gas", "overdensity")], weight_field="cell_volume", accumulation=True, storage="virial_quantities_profiles") hc.add_callback("virial_quantities", ["radius"], profile_storage="virial_quantities_profiles") hc.add_callback('delete_attribute', 'virial_quantities_profiles')