velociraptor.tools.mass_functions module

Tools for creating mass functions!

velociraptor.tools.mass_functions.create_mass_function_given_bins(masses: unyt.array.unyt_array, bins: unyt.array.unyt_array, box_volume: unyt.array.unyt_quantity, minimum_in_bin: int = 3)[source]

Creates a mass function (with equal width bins in log M) for you to plot.

Parameters:
  • masses (unyt.unyt_array) – The array that you want to create a mass function of (usually this is for example halo masses or stellar masses).
  • bins (unyt.unyt_array) – The mass bin edges to use.
  • unyt.unyt_quantity (box_volume) – The volume of the box such that we can return n / volume.
  • minimum_in_bin (int, optional) – The number of objects in a bin for it to be classed as valid. Bins with a number of objects smaller than this are not returned. By default this parameter takes a value of 3.
Returns:

  • bin_centers (unyt.unyt_array) – The centers of the bins (taken to be the linear mean of the bin edges).
  • mass_function (unyt.unyt_array) – The value of the mass function at the bin centers.
  • error (unyt.unyt_array) – Scatter in the mass function (Poisson errors).

velociraptor.tools.mass_functions.create_mass_function(masses: unyt.array.unyt_array, lowest_mass: unyt.array.unyt_quantity, highest_mass: unyt.array.unyt_quantity, box_volume: unyt.array.unyt_quantity, n_bins: int = 25, minimum_in_bin: int = 3, return_bin_edges: bool = False)[source]

Creates a mass function (with equal width bins in log M) for you to plot.

Parameters:
  • masses (unyt.unyt_array) – The array that you want to create a mass function of (usually this is for example halo masses or stellar masses).
  • lowest_mass (unyt.unyt_quantity) – the lowest mass edge of the bins
  • highest_mass (unyt.unyt_quantity) – the highest mass edge of the bins
  • box_volume (unyt.unyt_quantity) – The volume of the box such that we can return n / volume.
  • n_bins (unyt.unyt_array) – The number of equal log-width bins across the range to use.
  • minimum_in_bin (int, optional) – The number of objects in a bin for it to be classed as valid. Bins with a number of objects smaller than this are not returned. By default this parameter takes a value of 3.
  • return_bin_edges (bool, optional) – Return the bin edges used in the binning process? Default is False.
Returns:

  • bin_centers (unyt.unyt_array) – The centers of the bins (taken to be the linear mean of the bin edges).
  • mass_function (unyt.unyt_array) – The value of the mass function at the bin centers.
  • error (unyt.unyt_array) – Scatter in the mass function (Poisson errors).
  • bin_edges (unyt.unyt_array, optional) – Bin edges that were used in the binning process.

velociraptor.tools.mass_functions.create_adaptive_mass_function(masses: unyt.array.unyt_array, lowest_mass: unyt.array.unyt_quantity, highest_mass: unyt.array.unyt_quantity, box_volume: unyt.array.unyt_quantity, base_n_bins: int = 25, minimum_in_bin: int = 3, return_bin_edges: bool = False)[source]

Creates a mass function (with equal width bins in log M) for you to plot.

Parameters:
  • masses (unyt.unyt_array) – The array that you want to create a mass function of (usually this is for example halo masses or stellar masses).
  • lowest_mass (unyt.unyt_quantity) – the lowest mass edge of the bins
  • highest_mass (unyt.unyt_quantity) – the highest mass edge of the bins
  • box_volume (unyt.unyt_quantity) – The volume of the box such that we can return n / volume.
  • base_n_bins (unyt.unyt_array) – The number of equal log-width bins across the range to use in the case where no adaptive sampling is required. This returns the minimal allowed bin width.
  • minimum_in_bin (int, optional) – The number of objects in a bin for it to be classed as valid. Bins with a number of objects smaller than this are not returned. By default this parameter takes a value of 3.
  • return_bin_edges (bool, optional) – Return the bin edges used in the binning process? Default is False.
Returns:

  • bin_centers (unyt.unyt_array) – The centers of the bins (taken to be the linear mean of the bin edges).
  • mass_function (unyt.unyt_array) – The value of the mass function at the bin centers.
  • error (unyt.unyt_array) – Scatter in the mass function (Poisson errors).
  • bin_edges (unyt.unyt_array, optional) – Bin edges that were used in the binning process.