BaryonForge.Profiles.Base module

class BaryonForge.Profiles.Base.BaseBFGProfiles(self, mass_def=<function MassDef200c>, c_M_relation=None, use_fftlog_projection=False, padding_lo_proj=0.1, padding_hi_proj=10, n_per_decade_proj=10, r_min_int=1e-06, r_max_int=1000.0, r_steps=500, xi_mm=None, **kwargs)[source]

Bases: HaloProfile

Base class for defining halo density profiles for any BaryonForge model.

This class extends the ccl.halos.profiles.HaloProfile class and provides additional functionality for handling different halo density profiles. It allows for custom real-space projection methods, control over parameter initialization, and adjustments to the Fourier transform settings to minimize artifacts.

Parameters:
  • use_fftlog_projection (bool, optional) – If True, the default FFTLog projection method is used for the projected method. If False, a custom real-space projection is employed. Default is False.

  • padding_lo_proj (float, optional) – The lower padding factor for the projection integral in real-space. Default is 0.1.

  • padding_hi_proj (float, optional) – The upper padding factor for the projection integral in real-space. Default is 10.

  • n_per_decade_proj (int, optional) – Number of integration points per decade in the real-space projection integral. Default is 10.

  • xi_mm (callable, optional) – A function that returns the matter-matter correlation function at different radii. Default is None, in which case we use the CCL inbuilt model.

  • **kwargs – Additional keyword arguments for setting specific parameters of the profile.

model_params

A dictionary containing all model parameters and their values.

Type:

dict

precision_fftlog

Dictionary with precision settings for the FFTLog convolution. Can be modified directly or using the update_precision_fftlog() method.

Type:

dict

real(cosmo, r, M, a)

Computes the real-space density profile.

projected(cosmo, r, M, a)

Computes the projected density profile.

model_param_names = []
hyper_param_names = []
property model_params

Returns a dictionary containing all model parameters and their current values.

Returns:

params – Dictionary of model parameters.

Return type:

dict

update_precision_fftlog(**pars)[source]

Updates the FFT parameters for the fourier method, and does so recursively for any and all BaryonForge (BFG) profiles that are held as attributes within a given class.

property hyper_params

Returns a dictionary containing all hyper parameters oof the calculation and their current values.

Returns:

params – Dictionary of hyper parameters.

Return type:

dict

set_parameter(key, value)[source]

Sets a parameter value for the profile. It can do it recursively in case the profile contains other profiles as its attributes.

Parameters:
  • key (str) – Name of the parameter to set.

  • value (any) – New value for the parameter.

generate_operator_method(reflect=False)

Defines a method for generating simple arithmetic operations for the Profile classes.

The generate_operator_method function dynamically creates methods that can be used to perform arithmetic operations (such as addition, subtraction, multiplication, etc.) on instances of the HaloProfile classes or similar. This function alters the _real() routine in the HaloProfile classes so that the new result is equivalent to computing the _real() of the individual classes and then performing the specified arithmetic operation.

Parameters:
  • op (function) – The arithmetic operation to be applied. It should be one of the Python arithmetic operators like add, mul, sub, pow, truediv, abs, neg, or pos from the operator module.

  • reflect (bool, optional) – If True, the order of the operands is reversed (i.e., the operation is performed with the second operand as the first). Used to handle right-handed/left-handed operations. Default is False.

Returns:

operator_method – A function that defines how the arithmetic operation should be performed on the HaloProfile classes. This function can handle operations with other HaloProfile instances, integers, or floats.

Return type:

function

Examples

To use generate_operator_method for addition, you might do:

>>> from operator import add
>>> add_method = generate_operator_method(add)
>>> profile_sum = add_method(profile1, profile2)

Notes

  • The method returned can handle both unary and binary operations depending on the operator specified.