# yt.analysis_modules.halo_finding.halo_objects module¶

HOP-output data handling

class yt.analysis_modules.halo_finding.halo_objects.FOFHalo(halo_list, id, indices=None, size=None, CoM=None, max_dens_point=None, group_total_mass=None, max_radius=None, bulk_vel=None, tasks=None, rms_vel=None, supp=None, ptype=None)[source]
bulk_velocity()

Returns the mass-weighted average velocity in cm/s.

This calculates and returns the mass-weighted average velocity of just the particles in the halo in cm/s.

Examples

>>> bv = halos[0].bulk_velocity()

center_of_mass()

Calculate and return the center of mass.

The center of mass of the halo is directly calculated and returned.

Examples

>>> com = halos[0].center_of_mass()

dont_wrap = ['get_sphere', 'write_particle_list']
extra_wrap = ['__getitem__']
get_size()
get_sphere(center_of_mass=True)

Returns a sphere source.

This will generate a new, empty sphere source centered on this halo, with the maximum radius of the halo. This can be used like any other data container in yt.

Parameters: center_of_mass (bool, optional) – True chooses the center of mass when calculating the maximum radius. False chooses from the maximum density location for HOP halos (it has no effect for FOF halos). Default = True. sphere – The empty data source. yt.data_objects.api.YTSphere

Examples

>>> sp = halos[0].get_sphere()

indices = None
maximum_density()[source]

Not implemented.

maximum_density_location()[source]

Not implemented.

maximum_radius(center_of_mass=True)

Returns the maximum radius in the halo for all particles, either from the point of maximum density or from the center of mass.

The maximum radius from the most dense point is calculated. This accounts for periodicity.

Parameters: center_of_mass (bool) – True chooses the center of mass when calculating the maximum radius. False chooses from the maximum density location for HOP halos (it has no effect for FOF halos). Default = True.

Examples

>>> radius = halos[0].maximum_radius()

particle_mask
rms_velocity()

Returns the mass-weighted RMS velocity for the halo particles in cgs units.

Calculate and return the mass-weighted RMS velocity for just the particles in the halo. The bulk velocity of the halo is subtracted before computation.

Examples

>>> rms_vel = halos[0].rms_velocity()

total_mass()

Returns the total mass in solar masses of the halo.

Returns the total mass in solar masses of just the particles in the halo.

Examples

>>> halos[0].total_mass()

virial_bin(virial_overdensity=200.0, bins=300)

Returns the bin index of the virial radius of the halo. Generally, it is better to call virial_radius instead, which calls this function automatically.

virial_info(bins=300)

Calculates the virial information for the halo. Generally, it is better to call virial_radius or virial_mass instead, which calls this function automatically.

virial_mass(virial_overdensity=200.0, bins=300)

Return the virial mass of the halo in Msun, using only the particles in the halo (no baryonic information used).

The virial mass is calculated, using the built in Halo.virial_info functionality. The mass is then returned.

Parameters: virial_overdensity (float) – The overdensity threshold compared to the universal average when calculating the virial mass. Default = 200. bins (int) – The number of spherical bins used to calculate overdensities. Default = 300. mass – The virial mass in solar masses of the particles in the halo. -1 if not virialized. float

Examples

>>> vm = halos[0].virial_mass()

virial_radius(virial_overdensity=200.0, bins=300)

Return the virial radius of the halo in code units.

The virial radius of the halo is calculated, using only the particles in the halo (no baryonic information used). Returns -1 if the halo is not virialized.

Parameters: virial_overdensity (float) – The overdensity threshold compared to the universal average when calculating the virial radius. Default = 200. bins (integer) – The number of spherical bins used to calculate overdensities. Default = 300. radius – The virial radius in code units of the particles in the halo. -1 if not virialized. float

Examples

>>> vr = halos[0].virial_radius()

write_particle_list(handle)
class yt.analysis_modules.halo_finding.halo_objects.FOFHaloFinder(ds, subvolume=None, link=0.2, dm_only=True, ptype=None, padding=0.02)[source]

Friends-of-friends halo finder.

Halos are found by linking together all pairs of particles closer than some distance from each other. Particles may have multiple links, and halos are found by recursively linking together all such pairs.

Larger linking lengths produce more halos, and the largest halos become larger. Also, halos become more filamentary and over-connected.

Davis et al. “The evolution of large-scale structure in a universe dominated by cold dark matter.” ApJ (1985) vol. 292 pp. 371-394

Parameters: ds (Dataset) – The dataset on which halo finding will be conducted. subvolume (yt.data_objects.data_containers.YTSelectionContainer, optional) – A region over which HOP will be run, which can be used to run HOP on a subvolume of the full volume. Default = None, which defaults to the full volume automatically. link (float) – If positive, the interparticle distance (compared to the overall average) used to build the halos. If negative, this is taken to be the actual linking length, and no other calculations will be applied. Default = 0.2. dm_only (bool (deprecated)) – If True, only dark matter particles are used when building halos. This has been deprecated. Instead, the ptype keyword should be used to specify a particle type. Default = True. ptype (string) – When dm_only is set to False, this sets the type of particle to be used for halo finding, with a default of “all”. This should not be used when dm_only is set to True. padding (float) – When run in parallel, the finder needs to surround each subvolume with duplicated particles for halo finding to work. This number must be no smaller than the radius of the largest halo in the box in code units. Default = 0.02.

Examples

>>> ds = load("RedshiftOutput0000")
>>> halos = FOFHaloFinder(ds)

comm = None
dump(basename='HopAnalysis', ellipsoid_data=False)

Save the full halo data to disk.

This function will save the halo data in such a manner that it can be easily re-loaded later using GenericHaloFinder.load. This is similar in concept to pickling the data, but outputs the data in the already-established data formats. The simple halo data is written to a text file (e.g. “HopAnalysis.out”) using write_out(), and the particle data to hdf5 files (e.g. “HopAnalysis.h5”) using write_particle_lists().

Parameters: basename (String) – The base name for the files the data will be written to. Default = “HopAnalysis”. ellipsoid_data (bool.) – Whether to save the ellipsoidal information to the files. Default = False.

Examples

>>> halos.dump("MyHalos")

get_dependencies(fields)
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

write_out(filename, ellipsoid_data=False)

Write out standard halo information to a text file.

Parameters: filename (String) – The name of the file to write to. ellipsoid_data (bool.) – Whether to print the ellipsoidal information to the file. Default = False.

Examples

>>> halos.write_out("HopAnalysis.out")

write_particle_lists(prefix)

Write out the particle data for halos to HDF5 files.

This function will accept a filename prefix, and for every halo it will write out an HDF5 file containing the positions, velocities, indices and masses of the constituent particles. However, if the halo finder is run in parallel, halos will only be written out on the processors to which they belong. See Halo.write_particle_lists_txt for how to track these halos globally across files.

Parameters: prefix (String) – The prefix for the name(s) of the HDF5 files.

Examples

>>> halos.write_particle_lists("halo-parts")

write_particle_lists_txt(prefix)

Write out the names of the HDF5 files containing halo particle data to a text file.

This function writes out the names of all the HDF5 files that would contain halo particle data. Only the root processor writes out.

Parameters: prefix (String) – The prefix for the name of the file.

Examples

>>> halos.write_particle_lists_txt("halo-parts")

class yt.analysis_modules.halo_finding.halo_objects.FOFHaloList(data_source, link=0.2, dm_only=True, redshift=-1, ptype=None)[source]
write_out(filename='FOFAnalysis.out', ellipsoid_data=False)[source]

Write out standard halo information to a text file.

Parameters: filename (String) – The name of the file to write to. Default = “FOFAnalysis.out”. ellipsoid_data (bool.) – Whether to print the ellipsoidal information to the file. Default = False.

Examples

>>> halos.write_out("FOFAnalysis.out")

write_particle_lists_txt(prefix, fp=None)

Write out the names of the HDF5 files containing halo particle data to a text file. Needed in particular for parallel analysis output.

Parameters: prefix (String) – The prefix for the name of the file.

Examples

>>> halos.write_particle_lists_txt("halo-parts")

class yt.analysis_modules.halo_finding.halo_objects.GenericHaloFinder(ds, data_source, padding=0.0, ptype=None)[source]
comm = None
dump(basename='HopAnalysis', ellipsoid_data=False)[source]

Save the full halo data to disk.

This function will save the halo data in such a manner that it can be easily re-loaded later using GenericHaloFinder.load. This is similar in concept to pickling the data, but outputs the data in the already-established data formats. The simple halo data is written to a text file (e.g. “HopAnalysis.out”) using write_out(), and the particle data to hdf5 files (e.g. “HopAnalysis.h5”) using write_particle_lists().

Parameters: basename (String) – The base name for the files the data will be written to. Default = “HopAnalysis”. ellipsoid_data (bool.) – Whether to save the ellipsoidal information to the files. Default = False.

Examples

>>> halos.dump("MyHalos")

get_dependencies(fields)
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

write_out(filename, ellipsoid_data=False)[source]

Write out standard halo information to a text file.

Parameters: filename (String) – The name of the file to write to. ellipsoid_data (bool.) – Whether to print the ellipsoidal information to the file. Default = False.

Examples

>>> halos.write_out("HopAnalysis.out")

write_particle_lists(prefix)[source]

Write out the particle data for halos to HDF5 files.

This function will accept a filename prefix, and for every halo it will write out an HDF5 file containing the positions, velocities, indices and masses of the constituent particles. However, if the halo finder is run in parallel, halos will only be written out on the processors to which they belong. See Halo.write_particle_lists_txt for how to track these halos globally across files.

Parameters: prefix (String) – The prefix for the name(s) of the HDF5 files.

Examples

>>> halos.write_particle_lists("halo-parts")

write_particle_lists_txt(prefix)[source]

Write out the names of the HDF5 files containing halo particle data to a text file.

This function writes out the names of all the HDF5 files that would contain halo particle data. Only the root processor writes out.

Parameters: prefix (String) – The prefix for the name of the file.

Examples

>>> halos.write_particle_lists_txt("halo-parts")

class yt.analysis_modules.halo_finding.halo_objects.HOPHalo(halo_list, id, indices=None, size=None, CoM=None, max_dens_point=None, group_total_mass=None, max_radius=None, bulk_vel=None, tasks=None, rms_vel=None, supp=None, ptype=None)[source]
bulk_velocity()

Returns the mass-weighted average velocity in cm/s.

This calculates and returns the mass-weighted average velocity of just the particles in the halo in cm/s.

Examples

>>> bv = halos[0].bulk_velocity()

center_of_mass()

Calculate and return the center of mass.

The center of mass of the halo is directly calculated and returned.

Examples

>>> com = halos[0].center_of_mass()

dont_wrap = ['get_sphere', 'write_particle_list']
extra_wrap = ['__getitem__']
get_size()
get_sphere(center_of_mass=True)

Returns a sphere source.

This will generate a new, empty sphere source centered on this halo, with the maximum radius of the halo. This can be used like any other data container in yt.

Parameters: center_of_mass (bool, optional) – True chooses the center of mass when calculating the maximum radius. False chooses from the maximum density location for HOP halos (it has no effect for FOF halos). Default = True. sphere – The empty data source. yt.data_objects.api.YTSphere

Examples

>>> sp = halos[0].get_sphere()

indices = None
maximum_density()

Return the HOP-identified maximum density. Not applicable to FOF halos.

Return the HOP-identified maximum density. Not applicable to FOF halos.

Examples

>>> max_dens = halos[0].maximum_density()

maximum_density_location()

Return the location HOP identified as maximally dense. Not applicable to FOF halos.

Return the location HOP identified as maximally dense.

Examples

>>> max_dens_loc = halos[0].maximum_density_location()

maximum_radius(center_of_mass=True)

Returns the maximum radius in the halo for all particles, either from the point of maximum density or from the center of mass.

The maximum radius from the most dense point is calculated. This accounts for periodicity.

Parameters: center_of_mass (bool) – True chooses the center of mass when calculating the maximum radius. False chooses from the maximum density location for HOP halos (it has no effect for FOF halos). Default = True.

Examples

>>> radius = halos[0].maximum_radius()

particle_mask
rms_velocity()

Returns the mass-weighted RMS velocity for the halo particles in cgs units.

Calculate and return the mass-weighted RMS velocity for just the particles in the halo. The bulk velocity of the halo is subtracted before computation.

Examples

>>> rms_vel = halos[0].rms_velocity()

total_mass()

Returns the total mass in solar masses of the halo.

Returns the total mass in solar masses of just the particles in the halo.

Examples

>>> halos[0].total_mass()

virial_bin(virial_overdensity=200.0, bins=300)

Returns the bin index of the virial radius of the halo. Generally, it is better to call virial_radius instead, which calls this function automatically.

virial_info(bins=300)

Calculates the virial information for the halo. Generally, it is better to call virial_radius or virial_mass instead, which calls this function automatically.

virial_mass(virial_overdensity=200.0, bins=300)

Return the virial mass of the halo in Msun, using only the particles in the halo (no baryonic information used).

The virial mass is calculated, using the built in Halo.virial_info functionality. The mass is then returned.

Parameters: virial_overdensity (float) – The overdensity threshold compared to the universal average when calculating the virial mass. Default = 200. bins (int) – The number of spherical bins used to calculate overdensities. Default = 300. mass – The virial mass in solar masses of the particles in the halo. -1 if not virialized. float

Examples

>>> vm = halos[0].virial_mass()

virial_radius(virial_overdensity=200.0, bins=300)

Return the virial radius of the halo in code units.

The virial radius of the halo is calculated, using only the particles in the halo (no baryonic information used). Returns -1 if the halo is not virialized.

Parameters: virial_overdensity (float) – The overdensity threshold compared to the universal average when calculating the virial radius. Default = 200. bins (integer) – The number of spherical bins used to calculate overdensities. Default = 300. radius – The virial radius in code units of the particles in the halo. -1 if not virialized. float

Examples

>>> vr = halos[0].virial_radius()

write_particle_list(handle)
class yt.analysis_modules.halo_finding.halo_objects.HOPHaloFinder(ds, subvolume=None, threshold=160, dm_only=True, ptype=None, padding=0.02, total_mass=None)[source]

HOP halo finder.

Halos are built by: 1. Calculating a density for each particle based on a smoothing kernel. 2. Recursively linking particles to other particles from lower density particles to higher. 3. Geometrically proximate chains are identified and 4. merged into final halos following merging rules.

Lower thresholds generally produce more halos, and the largest halos become larger. Also, halos become more filamentary and over-connected.

Eisenstein and Hut. “HOP: A New Group-Finding Algorithm for N-Body Simulations.” ApJ (1998) vol. 498 pp. 137-142

Parameters: ds (Dataset) – The dataset on which halo finding will be conducted. subvolume (yt.data_objects.data_containers.YTSelectionContainer, optional) – A region over which HOP will be run, which can be used to run HOP on a subvolume of the full volume. Default = None, which defaults to the full volume automatically. threshold (float) – The density threshold used when building halos. Default = 160.0. dm_only (bool (deprecated)) – If True, only dark matter particles are used when building halos. This has been deprecated. Instead, the ptype keyword should be used to specify a particle type. Default = True. ptype (string) – When dm_only is set to False, this sets the type of particle to be used for halo finding, with a default of “all”. This should not be used when dm_only is set to True. padding (float) – When run in parallel, the finder needs to surround each subvolume with duplicated particles for halo finding to work. This number must be no smaller than the radius of the largest halo in the box in code units. Default = 0.02. total_mass (float) – If HOP is run on the same dataset mulitple times, the total mass of particles in Msun units in the full volume can be supplied here to save time. This must correspond to the particles being operated on, meaning if stars are included in the halo finding, they must be included in this mass as well, and visa-versa. If halo finding on a subvolume, this still corresponds with the mass in the entire volume. Default = None, which means the total mass is automatically calculated.

Examples

>>> ds = load("RedshiftOutput0000")
>>> halos = HaloFinder(ds)

comm = None
dump(basename='HopAnalysis', ellipsoid_data=False)

Save the full halo data to disk.

This function will save the halo data in such a manner that it can be easily re-loaded later using GenericHaloFinder.load. This is similar in concept to pickling the data, but outputs the data in the already-established data formats. The simple halo data is written to a text file (e.g. “HopAnalysis.out”) using write_out(), and the particle data to hdf5 files (e.g. “HopAnalysis.h5”) using write_particle_lists().

Parameters: basename (String) – The base name for the files the data will be written to. Default = “HopAnalysis”. ellipsoid_data (bool.) – Whether to save the ellipsoidal information to the files. Default = False.

Examples

>>> halos.dump("MyHalos")

get_dependencies(fields)
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

write_out(filename, ellipsoid_data=False)

Write out standard halo information to a text file.

Parameters: filename (String) – The name of the file to write to. ellipsoid_data (bool.) – Whether to print the ellipsoidal information to the file. Default = False.

Examples

>>> halos.write_out("HopAnalysis.out")

write_particle_lists(prefix)

Write out the particle data for halos to HDF5 files.

This function will accept a filename prefix, and for every halo it will write out an HDF5 file containing the positions, velocities, indices and masses of the constituent particles. However, if the halo finder is run in parallel, halos will only be written out on the processors to which they belong. See Halo.write_particle_lists_txt for how to track these halos globally across files.

Parameters: prefix (String) – The prefix for the name(s) of the HDF5 files.

Examples

>>> halos.write_particle_lists("halo-parts")

write_particle_lists_txt(prefix)

Write out the names of the HDF5 files containing halo particle data to a text file.

This function writes out the names of all the HDF5 files that would contain halo particle data. Only the root processor writes out.

Parameters: prefix (String) – The prefix for the name of the file.

Examples

>>> halos.write_particle_lists_txt("halo-parts")

class yt.analysis_modules.halo_finding.halo_objects.HOPHaloList(data_source, threshold=160.0, dm_only=True, ptype=None)[source]

Run hop on data_source with a given density threshold. If dm_only is True (default), only run it on the dark matter particles, otherwise on all particles. Returns an iterable collection of HopGroup items.

write_out(filename='HopAnalysis.out', ellipsoid_data=False)[source]

Write out standard halo information to a text file.

Parameters: filename (String) – The name of the file to write to. Default = “HopAnalysis.out”. ellipsoid_data (bool.) – Whether to print the ellipsoidal information to the file. Default = False.

Examples

>>> halos.write_out("HopAnalysis.out")

write_particle_lists_txt(prefix, fp=None)

Write out the names of the HDF5 files containing halo particle data to a text file. Needed in particular for parallel analysis output.

Parameters: prefix (String) – The prefix for the name of the file.

Examples

>>> halos.write_particle_lists_txt("halo-parts")

class yt.analysis_modules.halo_finding.halo_objects.Halo(halo_list, id, indices=None, size=None, CoM=None, max_dens_point=None, group_total_mass=None, max_radius=None, bulk_vel=None, tasks=None, rms_vel=None, supp=None, ptype=None)[source]

Bases: object

A data source that returns particle information about the members of a HOP-identified halo.

bulk_velocity()[source]

Returns the mass-weighted average velocity in cm/s.

This calculates and returns the mass-weighted average velocity of just the particles in the halo in cm/s.

Examples

>>> bv = halos[0].bulk_velocity()

center_of_mass()[source]

Calculate and return the center of mass.

The center of mass of the halo is directly calculated and returned.

Examples

>>> com = halos[0].center_of_mass()

dont_wrap = ['get_sphere', 'write_particle_list']
extra_wrap = ['__getitem__']
get_size()[source]
get_sphere(center_of_mass=True)[source]

Returns a sphere source.

This will generate a new, empty sphere source centered on this halo, with the maximum radius of the halo. This can be used like any other data container in yt.

Parameters: center_of_mass (bool, optional) – True chooses the center of mass when calculating the maximum radius. False chooses from the maximum density location for HOP halos (it has no effect for FOF halos). Default = True. sphere – The empty data source. yt.data_objects.api.YTSphere

Examples

>>> sp = halos[0].get_sphere()

indices = None
maximum_density()[source]

Return the HOP-identified maximum density. Not applicable to FOF halos.

Return the HOP-identified maximum density. Not applicable to FOF halos.

Examples

>>> max_dens = halos[0].maximum_density()

maximum_density_location()[source]

Return the location HOP identified as maximally dense. Not applicable to FOF halos.

Return the location HOP identified as maximally dense.

Examples

>>> max_dens_loc = halos[0].maximum_density_location()

maximum_radius(center_of_mass=True)[source]

Returns the maximum radius in the halo for all particles, either from the point of maximum density or from the center of mass.

The maximum radius from the most dense point is calculated. This accounts for periodicity.

Parameters: center_of_mass (bool) – True chooses the center of mass when calculating the maximum radius. False chooses from the maximum density location for HOP halos (it has no effect for FOF halos). Default = True.

Examples

>>> radius = halos[0].maximum_radius()

particle_mask
rms_velocity()[source]

Returns the mass-weighted RMS velocity for the halo particles in cgs units.

Calculate and return the mass-weighted RMS velocity for just the particles in the halo. The bulk velocity of the halo is subtracted before computation.

Examples

>>> rms_vel = halos[0].rms_velocity()

total_mass()[source]

Returns the total mass in solar masses of the halo.

Returns the total mass in solar masses of just the particles in the halo.

Examples

>>> halos[0].total_mass()

virial_bin(virial_overdensity=200.0, bins=300)[source]

Returns the bin index of the virial radius of the halo. Generally, it is better to call virial_radius instead, which calls this function automatically.

virial_info(bins=300)[source]

Calculates the virial information for the halo. Generally, it is better to call virial_radius or virial_mass instead, which calls this function automatically.

virial_mass(virial_overdensity=200.0, bins=300)[source]

Return the virial mass of the halo in Msun, using only the particles in the halo (no baryonic information used).

The virial mass is calculated, using the built in Halo.virial_info functionality. The mass is then returned.

Parameters: virial_overdensity (float) – The overdensity threshold compared to the universal average when calculating the virial mass. Default = 200. bins (int) – The number of spherical bins used to calculate overdensities. Default = 300. mass – The virial mass in solar masses of the particles in the halo. -1 if not virialized. float

Examples

>>> vm = halos[0].virial_mass()

virial_radius(virial_overdensity=200.0, bins=300)[source]

Return the virial radius of the halo in code units.

The virial radius of the halo is calculated, using only the particles in the halo (no baryonic information used). Returns -1 if the halo is not virialized.

Parameters: virial_overdensity (float) – The overdensity threshold compared to the universal average when calculating the virial radius. Default = 200. bins (integer) – The number of spherical bins used to calculate overdensities. Default = 300. radius – The virial radius in code units of the particles in the halo. -1 if not virialized. float

Examples

>>> vr = halos[0].virial_radius()

write_particle_list(handle)[source]
yt.analysis_modules.halo_finding.halo_objects.HaloFinder

alias of HOPHaloFinder

class yt.analysis_modules.halo_finding.halo_objects.HaloList(data_source, dm_only=True, redshift=-1, ptype=None)[source]

Bases: object

write_out(filename, ellipsoid_data=False)[source]

Write out standard halo information to a text file.

Parameters: filename (String) – The name of the file to write to. ellipsoid_data (bool.) – Whether to print the ellipsoidal information to the file. Default = False.

Examples

>>> halos.write_out("HopAnalysis.out")

write_particle_lists_txt(prefix, fp=None)[source]

Write out the names of the HDF5 files containing halo particle data to a text file. Needed in particular for parallel analysis output.

Parameters: prefix (String) – The prefix for the name of the file.

Examples

>>> halos.write_particle_lists_txt("halo-parts")

class yt.analysis_modules.halo_finding.halo_objects.LoadHaloes(ds, basename)[source]

Load the full halo data into memory.

This function takes the output of GenericHaloFinder.dump and re-establishes the list of halos in memory. This enables the full set of halo analysis features without running the halo finder again. To be precise, the particle data for each halo is only read in when necessary, so examining a single halo will not require as much memory as is required for halo finding.

Parameters: basename (String) – The base name of the files that will be read in. This should match what was used when GenericHaloFinder.dump was called. Default = “HopAnalysis”.

Examples

>>> ds = load("data0005")

comm = None
dump(basename='HopAnalysis', ellipsoid_data=False)

Save the full halo data to disk.

This function will save the halo data in such a manner that it can be easily re-loaded later using GenericHaloFinder.load. This is similar in concept to pickling the data, but outputs the data in the already-established data formats. The simple halo data is written to a text file (e.g. “HopAnalysis.out”) using write_out(), and the particle data to hdf5 files (e.g. “HopAnalysis.h5”) using write_particle_lists().

Parameters: basename (String) – The base name for the files the data will be written to. Default = “HopAnalysis”. ellipsoid_data (bool.) – Whether to save the ellipsoidal information to the files. Default = False.

Examples

>>> halos.dump("MyHalos")

get_dependencies(fields)
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

write_out(filename, ellipsoid_data=False)

Write out standard halo information to a text file.

Parameters: filename (String) – The name of the file to write to. ellipsoid_data (bool.) – Whether to print the ellipsoidal information to the file. Default = False.

Examples

>>> halos.write_out("HopAnalysis.out")

write_particle_lists(prefix)

Write out the particle data for halos to HDF5 files.

This function will accept a filename prefix, and for every halo it will write out an HDF5 file containing the positions, velocities, indices and masses of the constituent particles. However, if the halo finder is run in parallel, halos will only be written out on the processors to which they belong. See Halo.write_particle_lists_txt for how to track these halos globally across files.

Parameters: prefix (String) – The prefix for the name(s) of the HDF5 files.

Examples

>>> halos.write_particle_lists("halo-parts")

write_particle_lists_txt(prefix)

Write out the names of the HDF5 files containing halo particle data to a text file.

This function writes out the names of all the HDF5 files that would contain halo particle data. Only the root processor writes out.

Parameters: prefix (String) – The prefix for the name of the file.

Examples

>>> halos.write_particle_lists_txt("halo-parts")

class yt.analysis_modules.halo_finding.halo_objects.LoadTextHaloes(ds, filename, columns, comment='#')[source]

Load a text file of halos.

Like LoadHaloes, but when all that is available is a plain text file. This assumes the text file has the 3-positions of halos along with a radius. The halo objects created are spheres.

Parameters: fname (String) – The name of the text file to read in. columns (dict) – A dict listing the column name : column number pairs for data in the text file. It is zero-based (like Python). An example is {‘x’:0, ‘y’:1, ‘z’:2, ‘r’:3, ‘m’:4}. Any column name outside of [‘x’, ‘y’, ‘z’, ‘r’] will be attached to each halo object in the supplementary dict ‘supp’. See example. comment (String) – If the first character of a line is equal to this, the line is skipped. Default = “#”.

Examples

>>> ds = load("data0005")
{'x':0, 'y':1, 'z':2, 'r':3, 'm':4},
comment = ";")
>>> halos[0].supp['m']
3.28392048e14

comm = None
dump(basename='HopAnalysis', ellipsoid_data=False)

Save the full halo data to disk.

This function will save the halo data in such a manner that it can be easily re-loaded later using GenericHaloFinder.load. This is similar in concept to pickling the data, but outputs the data in the already-established data formats. The simple halo data is written to a text file (e.g. “HopAnalysis.out”) using write_out(), and the particle data to hdf5 files (e.g. “HopAnalysis.h5”) using write_particle_lists().

Parameters: basename (String) – The base name for the files the data will be written to. Default = “HopAnalysis”. ellipsoid_data (bool.) – Whether to save the ellipsoidal information to the files. Default = False.

Examples

>>> halos.dump("MyHalos")

get_dependencies(fields)
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

write_out(filename, ellipsoid_data=False)

Write out standard halo information to a text file.

Parameters: filename (String) – The name of the file to write to. ellipsoid_data (bool.) – Whether to print the ellipsoidal information to the file. Default = False.

Examples

>>> halos.write_out("HopAnalysis.out")

write_particle_lists(prefix)

Write out the particle data for halos to HDF5 files.

This function will accept a filename prefix, and for every halo it will write out an HDF5 file containing the positions, velocities, indices and masses of the constituent particles. However, if the halo finder is run in parallel, halos will only be written out on the processors to which they belong. See Halo.write_particle_lists_txt for how to track these halos globally across files.

Parameters: prefix (String) – The prefix for the name(s) of the HDF5 files.

Examples

>>> halos.write_particle_lists("halo-parts")

write_particle_lists_txt(prefix)

Write out the names of the HDF5 files containing halo particle data to a text file.

This function writes out the names of all the HDF5 files that would contain halo particle data. Only the root processor writes out.

Parameters: prefix (String) – The prefix for the name of the file.

Examples

>>> halos.write_particle_lists_txt("halo-parts")

yt.analysis_modules.halo_finding.halo_objects.LoadTextHalos

alias of LoadTextHaloes

class yt.analysis_modules.halo_finding.halo_objects.LoadedHalo(ds, id, size=None, CoM=None, max_dens_point=None, group_total_mass=None, max_radius=None, bulk_vel=None, rms_vel=None, fnames=None, mag_A=None, mag_B=None, mag_C=None, e0_vec=None, tilt=None, supp=None)[source]
bulk_velocity()

Returns the mass-weighted average velocity in cm/s.

This calculates and returns the mass-weighted average velocity of just the particles in the halo in cm/s.

Examples

>>> bv = halos[0].bulk_velocity()

center_of_mass()

Calculate and return the center of mass.

The center of mass of the halo is directly calculated and returned.

Examples

>>> com = halos[0].center_of_mass()

dont_wrap = ['get_sphere', 'write_particle_list']
extra_wrap = ['__getitem__']
get_ellipsoid()[source]

Returns an ellipsoidal data object. This will generate a new, empty ellipsoidal data object for this halo.

Parameters: None. – ellipsoid – The ellipsoidal data object. yt.data_objects.data_containers.YTEllipsoid

Examples

>>> ell = halos[0].get_ellipsoid()

get_ellipsoid_parameters()[source]

Calculate the parameters that describe the ellipsoid of the particles that constitute the halo.

Parameters: None – tuple – The 6-tuple has in order: #. The center of mass as an array. #. mag_A as a float. #. mag_B as a float. #. mag_C as a float. #. e0_vector as an array. #. tilt as a float. (cm, mag_A, mag_B, mag_C, e0_vector, tilt)

Examples

>>> params = halos[0].get_ellipsoid_parameters()

get_size()
get_sphere()[source]

Returns a sphere source.

This will generate a new, empty sphere source centered on this halo, with the maximum radius of the halo. This can be used like any other data container in yt.

Parameters: center_of_mass (bool, optional) – True chooses the center of mass when calculating the maximum radius. False chooses from the maximum density location for HOP halos (it has no effect for FOF halos). Default = True. sphere – The empty data source. yt.data_objects.api.YTSphere

Examples

>>> sp = halos[0].get_sphere()

indices = None
maximum_density()

Return the HOP-identified maximum density. Not applicable to FOF halos.

Return the HOP-identified maximum density. Not applicable to FOF halos.

Examples

>>> max_dens = halos[0].maximum_density()

maximum_density_location()

Return the location HOP identified as maximally dense. Not applicable to FOF halos.

Return the location HOP identified as maximally dense.

Examples

>>> max_dens_loc = halos[0].maximum_density_location()

maximum_radius(center_of_mass=True)

Returns the maximum radius in the halo for all particles, either from the point of maximum density or from the center of mass.

The maximum radius from the most dense point is calculated. This accounts for periodicity.

Parameters: center_of_mass (bool) – True chooses the center of mass when calculating the maximum radius. False chooses from the maximum density location for HOP halos (it has no effect for FOF halos). Default = True.

Examples

>>> radius = halos[0].maximum_radius()

particle_mask
rms_velocity()

Returns the mass-weighted RMS velocity for the halo particles in cgs units.

Calculate and return the mass-weighted RMS velocity for just the particles in the halo. The bulk velocity of the halo is subtracted before computation.

Examples

>>> rms_vel = halos[0].rms_velocity()

total_mass()

Returns the total mass in solar masses of the halo.

Returns the total mass in solar masses of just the particles in the halo.

Examples

>>> halos[0].total_mass()

virial_bin(virial_overdensity=200.0, bins=300)

Returns the bin index of the virial radius of the halo. Generally, it is better to call virial_radius instead, which calls this function automatically.

virial_info(bins=300)

Calculates the virial information for the halo. Generally, it is better to call virial_radius or virial_mass instead, which calls this function automatically.

virial_mass(virial_overdensity=200.0, bins=300)

Return the virial mass of the halo in Msun, using only the particles in the halo (no baryonic information used).

The virial mass is calculated, using the built in Halo.virial_info functionality. The mass is then returned.

Parameters: virial_overdensity (float) – The overdensity threshold compared to the universal average when calculating the virial mass. Default = 200. bins (int) – The number of spherical bins used to calculate overdensities. Default = 300. mass – The virial mass in solar masses of the particles in the halo. -1 if not virialized. float

Examples

>>> vm = halos[0].virial_mass()

virial_radius(virial_overdensity=200.0, bins=300)

Return the virial radius of the halo in code units.

The virial radius of the halo is calculated, using only the particles in the halo (no baryonic information used). Returns -1 if the halo is not virialized.

Parameters: virial_overdensity (float) – The overdensity threshold compared to the universal average when calculating the virial radius. Default = 200. bins (integer) – The number of spherical bins used to calculate overdensities. Default = 300. radius – The virial radius in code units of the particles in the halo. -1 if not virialized. float

Examples

>>> vr = halos[0].virial_radius()

write_particle_list(handle)
class yt.analysis_modules.halo_finding.halo_objects.LoadedHaloList(ds, basename)[source]
write_out(filename, ellipsoid_data=False)

Write out standard halo information to a text file.

Parameters: filename (String) – The name of the file to write to. ellipsoid_data (bool.) – Whether to print the ellipsoidal information to the file. Default = False.

Examples

>>> halos.write_out("HopAnalysis.out")

write_particle_lists_txt(prefix, fp=None)

Write out the names of the HDF5 files containing halo particle data to a text file. Needed in particular for parallel analysis output.

Parameters: prefix (String) – The prefix for the name of the file.

Examples

>>> halos.write_particle_lists_txt("halo-parts")

class yt.analysis_modules.halo_finding.halo_objects.TextHalo(ds, id, size=None, CoM=None, max_dens_point=None, group_total_mass=None, max_radius=None, bulk_vel=None, rms_vel=None, fnames=None, mag_A=None, mag_B=None, mag_C=None, e0_vec=None, tilt=None, supp=None)[source]
bulk_velocity()

Returns the mass-weighted average velocity in cm/s.

This calculates and returns the mass-weighted average velocity of just the particles in the halo in cm/s.

Examples

>>> bv = halos[0].bulk_velocity()

center_of_mass()

Calculate and return the center of mass.

The center of mass of the halo is directly calculated and returned.

Examples

>>> com = halos[0].center_of_mass()

dont_wrap = ['get_sphere', 'write_particle_list']
extra_wrap = ['__getitem__']
get_ellipsoid()

Returns an ellipsoidal data object. This will generate a new, empty ellipsoidal data object for this halo.

Parameters: None. – ellipsoid – The ellipsoidal data object. yt.data_objects.data_containers.YTEllipsoid

Examples

>>> ell = halos[0].get_ellipsoid()

get_ellipsoid_parameters()

Calculate the parameters that describe the ellipsoid of the particles that constitute the halo.

Parameters: None – tuple – The 6-tuple has in order: #. The center of mass as an array. #. mag_A as a float. #. mag_B as a float. #. mag_C as a float. #. e0_vector as an array. #. tilt as a float. (cm, mag_A, mag_B, mag_C, e0_vector, tilt)

Examples

>>> params = halos[0].get_ellipsoid_parameters()

get_size()[source]
get_sphere()

Returns a sphere source.

This will generate a new, empty sphere source centered on this halo, with the maximum radius of the halo. This can be used like any other data container in yt.

Parameters: center_of_mass (bool, optional) – True chooses the center of mass when calculating the maximum radius. False chooses from the maximum density location for HOP halos (it has no effect for FOF halos). Default = True. sphere – The empty data source. yt.data_objects.api.YTSphere

Examples

>>> sp = halos[0].get_sphere()

indices = None
maximum_density()[source]

Undefined for text halos.

maximum_density_location()[source]

Undefined, default to CoM

maximum_radius(center_of_mass=True)

Returns the maximum radius in the halo for all particles, either from the point of maximum density or from the center of mass.

The maximum radius from the most dense point is calculated. This accounts for periodicity.

Parameters: center_of_mass (bool) – True chooses the center of mass when calculating the maximum radius. False chooses from the maximum density location for HOP halos (it has no effect for FOF halos). Default = True.

Examples

>>> radius = halos[0].maximum_radius()

particle_mask
rms_velocity()

Returns the mass-weighted RMS velocity for the halo particles in cgs units.

Calculate and return the mass-weighted RMS velocity for just the particles in the halo. The bulk velocity of the halo is subtracted before computation.

Examples

>>> rms_vel = halos[0].rms_velocity()

total_mass()

Returns the total mass in solar masses of the halo.

Returns the total mass in solar masses of just the particles in the halo.

Examples

>>> halos[0].total_mass()

virial_bin(virial_overdensity=200.0, bins=300)

Returns the bin index of the virial radius of the halo. Generally, it is better to call virial_radius instead, which calls this function automatically.

virial_info(bins=300)

Calculates the virial information for the halo. Generally, it is better to call virial_radius or virial_mass instead, which calls this function automatically.

virial_mass(virial_overdensity=200.0, bins=300)

Return the virial mass of the halo in Msun, using only the particles in the halo (no baryonic information used).

The virial mass is calculated, using the built in Halo.virial_info functionality. The mass is then returned.

Parameters: virial_overdensity (float) – The overdensity threshold compared to the universal average when calculating the virial mass. Default = 200. bins (int) – The number of spherical bins used to calculate overdensities. Default = 300. mass – The virial mass in solar masses of the particles in the halo. -1 if not virialized. float

Examples

>>> vm = halos[0].virial_mass()

virial_radius(virial_overdensity=200.0, bins=300)

Return the virial radius of the halo in code units.

The virial radius of the halo is calculated, using only the particles in the halo (no baryonic information used). Returns -1 if the halo is not virialized.

Parameters: virial_overdensity (float) – The overdensity threshold compared to the universal average when calculating the virial radius. Default = 200. bins (integer) – The number of spherical bins used to calculate overdensities. Default = 300. radius – The virial radius in code units of the particles in the halo. -1 if not virialized. float

Examples

>>> vr = halos[0].virial_radius()

write_particle_list(handle)
class yt.analysis_modules.halo_finding.halo_objects.TextHaloList(ds, fname, columns, comment)[source]
write_out(filename, ellipsoid_data=False)

Write out standard halo information to a text file.

Parameters: filename (String) – The name of the file to write to. ellipsoid_data (bool.) – Whether to print the ellipsoidal information to the file. Default = False.

Examples

>>> halos.write_out("HopAnalysis.out")

write_particle_lists_txt(prefix, fp=None)

Write out the names of the HDF5 files containing halo particle data to a text file. Needed in particular for parallel analysis output.

Parameters: prefix (String) – The prefix for the name of the file.

Examples

>>> halos.write_particle_lists_txt("halo-parts")