# yt.analysis_modules.halo_analysis.halo_callbacks module¶

Halo callback object

class yt.analysis_modules.halo_analysis.halo_callbacks.HaloCallback(function, args=None, kwargs=None)[source]

Bases: object

A HaloCallback is a function that minimally takes in a Halo object and performs some analysis on it. This function may attach attributes to the Halo object, write out data, etc, but does not return anything.

yt.analysis_modules.halo_analysis.halo_callbacks.add_callback(name, function)[source]
yt.analysis_modules.halo_analysis.halo_callbacks.delete_attribute(halo, attribute)[source]

Delete attribute from halo object.

Parameters: halo (Halo object) – The Halo object to be provided by the HaloCatalog. attribute (string) – The attribute to be deleted.
yt.analysis_modules.halo_analysis.halo_callbacks.halo_sphere(halo, radius_field='virial_radius', factor=1.0, field_parameters=None)[source]

Create a sphere data container to associate with a halo.

Parameters: halo (Halo object) – The Halo object to be provided by the HaloCatalog. radius_field (string) – Field to be retrieved from the quantities dictionary as the basis of the halo radius. Default: “virial_radius”. factor (float) – Factor to be multiplied by the base radius for defining the radius of the sphere. Default: 1.0. field_parameters (dict) – Dictionary of field parameters to be set with the sphere created.
yt.analysis_modules.halo_analysis.halo_callbacks.iterative_center_of_mass(halo, radius_field='virial_radius', inner_ratio=0.1, step_ratio=0.9, units='pc')[source]

Adjust halo position by iteratively recalculating the center of mass while decreasing the radius.

Parameters: halo (Halo object) – The Halo object to be provided by the HaloCatalog. radius_field (string) – The halo quantity to be used as the radius for the sphere. Default: “virial_radius” inner_ratio (float) – The ratio of the smallest sphere radius used for calculating the center of mass to the initial radius. The sphere radius is reduced and center of mass recalculated until the sphere has reached this size. Default: 0.1 step_ratio (float) – The multiplicative factor used to reduce the radius of the sphere after the center of mass is calculated. Default: 0.9 units (str) – The units for printing out the distance between the initial and final centers. Default : “pc”
yt.analysis_modules.halo_analysis.halo_callbacks.load_profiles(halo, storage='profiles', fields=None, filename=None, output_dir='.')[source]

Parameters: halo (Halo object) – The Halo object to be provided by the HaloCatalog. storage (string) – Name of the dictionary attribute to store profile data. Default: “profiles” fields (string or list of strings) – The fields to be loaded. If None, all fields present will be loaded. Default : None filename (string) – The name of the file to be loaded. The final filename will be “_.h5”. If None, filename is set to the value given by the storage keyword. Default: None output_dir (string) – Name of directory where profile data will be read. The full path will be the output_dir of the halo catalog concatenated with this directory. Default : ”.”
yt.analysis_modules.halo_analysis.halo_callbacks.phase_plot(halo, output_dir='.', phase_args=None, phase_kwargs=None)[source]

Make a phase plot for the halo object.

Parameters: halo (Halo object) – The Halo object to be provided by the HaloCatalog. output_dir (string) – Name of directory where profile data will be written. The full path will be the output_dir of the halo catalog concatenated with this directory. Default : ”.” phase_args (list) – List of arguments to be given to PhasePlot. phase_kwargs (dict) – Dictionary of keyword arguments to be given to PhasePlot.
yt.analysis_modules.halo_analysis.halo_callbacks.profile(halo, bin_fields, profile_fields, n_bins=32, extrema=None, logs=None, units=None, weight_field='cell_mass', accumulation=False, fractional=False, storage='profiles', output_dir='.')[source]

Create 1, 2, or 3D profiles of a halo.

Store profile data in a dictionary associated with the halo object.

Parameters: halo (Halo object) – The Halo object to be provided by the HaloCatalog. bin_fields (list of strings) – The binning fields for the profile. profile_fields (string or list of strings) – The fields to be profiled. n_bins (int or list of ints) – The number of bins in each dimension. If None, 32 bins for each bin are used for each bin field. Default: 32. extrema (dict of min, max tuples) – Minimum and maximum values of the bin_fields for the profiles. The keys correspond to the field names. Defaults to the extrema of the bin_fields of the dataset. If a units dict is provided, extrema are understood to be in the units specified in the dictionary. logs (dict of boolean values) – Whether or not to log the bin_fields for the profiles. The keys correspond to the field names. Defaults to the take_log attribute of the field. units (dict of strings) – The units of the fields in the profiles, including the bin_fields. weight_field (string) – Weight field for profiling. Default : “cell_mass” accumulation (bool or list of bools) – If True, the profile values for a bin n are the cumulative sum of all the values from bin 0 to n. If -True, the sum is reversed so that the value for bin n is the cumulative sum from bin N (total bins) to n. If the profile is 2D or 3D, a list of values can be given to control the summation in each dimension independently. Default: False. fractional (If True the profile values are divided by the sum of all) – the profile data such that the profile represents a probability distribution function. storage (string) – Name of the dictionary to store profiles. Default: “profiles” output_dir (string) – Name of directory where profile data will be written. The full path will be the output_dir of the halo catalog concatenated with this directory. Default : ”.”
yt.analysis_modules.halo_analysis.halo_callbacks.save_profiles(halo, storage='profiles', filename=None, output_dir='.')[source]

Save profile data to disk.

Parameters: halo (Halo object) – The Halo object to be provided by the HaloCatalog. storage (string) – Name of the dictionary attribute containing the profile data to be written. Default: “profiles” filename (string) – The name of the file to be written. The final filename will be “_.h5”. If None, filename is set to the value given by the storage keyword. Default: None output_dir (string) – Name of directory where profile data will be written. The full path will be the output_dir of the halo catalog concatenated with this directory. Default : ”.”
yt.analysis_modules.halo_analysis.halo_callbacks.sphere_bulk_velocity(halo)[source]

Set the bulk velocity for the sphere.

Parameters: halo (Halo object) – The Halo object to be provided by the HaloCatalog.
yt.analysis_modules.halo_analysis.halo_callbacks.sphere_field_max_recenter(halo, field)[source]

Recenter the halo sphere on the location of the maximum of the given field.

Parameters: halo (Halo object) – The Halo object to be provided by the HaloCatalog. field (string) – Field to be used for recentering.
yt.analysis_modules.halo_analysis.halo_callbacks.virial_quantities(halo, fields, overdensity_field=('gas', 'overdensity'), critical_overdensity=200, profile_storage='profiles')[source]

Calculate the value of the given fields at the virial radius defined at the given critical density by interpolating from radial profiles.

Parameters: halo (Halo object) – The Halo object to be provided by the HaloCatalog. fields (string or list of strings) – The fields whose virial values are to be calculated. overdensity_field (string or tuple of strings) – The field used as the overdensity from which interpolation is done to calculate virial quantities. Default: (“gas”, “overdensity”) critical_overdensity (float) – The value of the overdensity at which to evaluate the virial quantities. Overdensity is with respect to the critical density. Default: 200 profile_storage (string) – Name of the halo attribute that holds the profiles to be used. Default: “profiles”