BaryonForge.utils.Pixel module

class BaryonForge.utils.Pixel.ConvolvedProfile(self, Profile, Pixel)[source]

Bases: BaseBFGProfiles

A class to compute profiles convolved with a pixel window function.

The ConvolvedProfile class takes in a HaloProfile object from CCL and a pixel window function object (eg. HealPixel) and returns a new object that computes profiles while including the pixel window function of the map that we paint into. It is assumed that the window function is isotropic. This class supports both real-space and projected-space profiles.

Parameters:
  • Profile (object) – A ccl.halos.profiles.HaloProfile object that defines the halo profile to be convolved with the pixel window function.

  • Pixel (object) – An object that defines the pixel window function. This object must provide real() and projected() methods to return the window function in real space and harmonic space, respectively. It must also have an isHarmonic attribute, to specify where the pixel scale is defined in angular space or physical space.

Profile

The original profile object to be convolved with the pixel window function.

Type:

object

Pixel

The pixel window function object used to convolve the profile.

Type:

object

fft_par

A dictionary of FFT log parameters used for Fourier transforms, derived from the Profile object.

Type:

dict

isHarmonic

A boolean indicating whether the pixel window function is defined in harmonic space.

Type:

bool

real(cosmo, r, M, a)

Computes the real-space profile convolved with the pixel window function.

projected(cosmo, r, M, a)[source]

Computes the projected-space profile convolved with the pixel window function, accounting for harmonic space if applicable.

Examples

>>> profile = SomeHaloProfile()
>>> pixel = SomePixelWindowFunction()
>>> convolved_profile = ConvolvedProfile(profile, pixel)
>>> result = convolved_profile.real(cosmo, r, M, a)
>>> projected_result = convolved_profile.projected(cosmo, r, M, a)

Notes

  • This class uses FFTLog for computing convolutions in Fourier space.

  • The real and projected methods perform clipping on the radius r to prevent artifacts like ringing at small scales.

  • The convolved profile is scaled by appropriate powers of (2pi) to account for the transformations.

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.

projected(cosmo, r, M, a)[source]

Computes the projected-space profile convolved with the pixel window function.

This method convolves the projected-space profile with the pixel window function using FFTLog. It can account for harmonic space considerations if the pixel window function is harmonic.

Parameters:
  • cosmo (object) – A ccl.Cosmology object representing the cosmological parameters.

  • r (ndarray) – An array of radii at which to compute the convolved profile. In comoving Mpc.

  • M (float) – The mass of the halo, in solar masses.

  • a (float) – The scale factor at which to compute the profile.

Returns:

prof – The convolved projected-space profile evaluated at the input radii r.

Return type:

ndarray

fourier(cosmo, k, M, a)[source]

Computes the fourier-space profile convolved with the pixel window function.

Parameters:
  • cosmo (object) – A ccl.Cosmology object representing the cosmological parameters.

  • k (ndarray) – An array of wavenumbers at which to compute the convolved profile. In comoving 1/Mpc.

  • M (float) – The mass of the halo, in solar masses.

  • a (float) – The scale factor at which to compute the profile.

Returns:

prof – The convolved real-space profile evaluated at the input radii r.

Return type:

ndarray

class BaryonForge.utils.Pixel.GridPixelApprox(size)[source]

Bases: object

A class for approximating the window function of a grid’s pixel as a circular tophat.

The GridPixelApprox class provides methods to approximate the window function of a grid’s pixel. In this approximation, the pixel window function is considered as a circular tophat in real space. This approximation is used to compute the effective window function in both real and projected spaces, for use in Fourier transforms.

Parameters:

size (float) – The size of the grid’s square pixel, in comoving Mpc. This size is used to compute the radius of the tophat approximation.

beam(k, R)[source]

Computes the beam function given a wavenumber k and a radius R.

real(k)[source]

Computes the real-space approximation of the pixel window function for given wavenumbers k.

projected(k)[source]

Computes the projected-space approximation of the pixel window function for given wavenumbers k.

Examples

>>> pixel_approx = GridPixelApprox(size=0.1)
>>> k = np.linspace(0.01, 1.0, 100)
>>> real_space_beam = pixel_approx.real(k)
>>> projected_space_beam = pixel_approx.projected(k)

Notes

  • The beam() method uses the spherical Bessel function of the first kind (spherical_jn) to compute the beam function.

  • The real() and projected() methods compute the effective radius from the given pixel size and use this radius in the beam() function.

isHarmonic = False
beam(k, R)[source]

Computes the beam function for given wavenumbers and a radius.

The beam function represents the response of a circular tophat window function and is derived from the spherical Bessel function of the first kind, ( j_1 ). The beam function ( B(k) ) is calculated as:

\[B(k) = \frac{3j_1(kr)}{kr}\]

where:

  • ( k ) is the wavenumber.

  • ( r = 2R ) is the diameter of the pixel (not the radius).

  • ( j_1 ) is the spherical Bessel function of the first kind of order one.

The factor of 2 in the radius calculation arises because the window function is defined for the diameter rather than the radius.

Parameters:
  • k (ndarray) – An array of wavenumbers at which to evaluate the beam function.

  • R (float) – The effective radius of the pixel, which depends on the size of the grid’s pixel.

Returns:

beam – An array of the beam function values corresponding to the input wavenumbers. The output is calculated as ( frac{3j_1(kr)}{kr} ), with special handling to avoid division by zero when ( kr = 0 ).

Return type:

ndarray

real(k)[source]

Computes the real-space approximation of the pixel window function.

This method approximates the pixel window function using a circular tophat in real space. The effective radius ( R ) is calculated based on the volume-equivalent size of the grid’s pixel, assuming a spherical shape. The real-space window function is then computed using this radius.

The effective radius ( R ) of the tophat is given by:

\[R = \left( \frac{\text{size}^3}{\frac{4}{3} \pi} \right)^{\frac{1}{3}}\]

where size is the linear size of the pixel.

Parameters:

k (ndarray) – An array of wavenumbers at which to evaluate the real-space window function.

Returns:

beam – An array of the real-space window function values corresponding to the input wavenumbers, computed using the beam function with the effective radius.

Return type:

ndarray

Notes

  • This function approximates the real-space window function by using a circular tophat model, which

simplifies the computation while capturing the essential behavior of the pixel’s effect in real space.

projected(k)[source]

Computes the projected-space approximation of the pixel window function.

This method approximates the pixel window function using a circular tophat in projected space. The effective radius ( R ) is calculated based on the area-equivalent size of the grid’s pixel, assuming a circular shape. The projected-space window function is then computed using this radius.

The effective radius ( R ) is given by:

\[R = \sqrt{\frac{\text{size}^2}{\pi}}\]

where size is the linear size of the pixel.

Parameters:

k (ndarray) – An array of wavenumbers at which to evaluate the projected-space window function.

Returns:

beam – An array of the projected-space window function values corresponding to the input wavenumbers, computed using the beam function with the effective radius.

Return type:

ndarray

Notes

  • This function approximates the projected-space window function by using a circular tophat model,

which simplifies the computation while capturing the essential behavior of the pixel’s effect in projected space. - The beam function is calculated by calling the self.beam() method, which computes the response using the spherical Bessel function of the first kind.

class BaryonForge.utils.Pixel.HealPixel(NSIDE)[source]

Bases: object

A class for approximating the window function of a HEALPix pixel using a Gaussian beam.

The HealPixel class provides methods to approximate the window function of a HEALPix pixel. Instead of using the built-in HEALPix pixel window function, which is limited to 3 * NSIDE - 1, this class uses a Gaussian beam approximation. The Gaussian beam, with a full width at half maximum (FWHM) that is (

rac{1}{sqrt{2}} )

smaller than the HEALPix pixel, provides a smooth window function for stable FFTLogs over a wide range of multipoles.

The Gaussian beam ( B(k) ) is computed as:

\[B(k) = \exp\left(-\frac{k(k+1)\sigma^2}{2}\right)\]

where ( sigma ) is the standard deviation of the Gaussian beam, calculated as:

\[\sigma = \frac{\text{size}}{\sqrt{8 \log(2)} \cdot \sqrt{2}}\]
isHarmonicbool

A class-level attribute indicating whether the pixel window function is defined in harmonic space. For HealPixel, this is always True.

NSIDEint

The NSIDE parameter of the HEALPix map, which determines the resolution.

sizefloat

The size (resolution) of a single pixel in the HEALPix grid, in radians.

real(k)

Returns a zero array, indicating that the real-space representation of the pixel is not supported.

projected(k)

Computes the projected-space approximation of the pixel window function using a Gaussian beam.

>>> heal_pixel = HealPixel(NSIDE=64)
>>> k = np.linspace(0.01, 1.0, 100)
>>> real_space_response = heal_pixel.real(k)  # Will return zeros
>>> projected_space_beam = heal_pixel.projected(k)
  • The Gaussian beam used for approximation is designed to match the HEALPix pixel window function closely, with <0.1% deviation for most scales and about 1% at the smallest scales.

  • This approximation is suitable for stable FFTLogs, ensuring smooth behavior at large multipoles.

isHarmonic = True
real(k)[source]

Returns a zero array for the real-space window function.

This method indicates that the real-space representation of the HEALPix pixel window function is not supported. It returns a zero array, which will propagate through calculations and help to throw errors when attempting to use real-space profiles.

Parameters:

k (ndarray) – An array of wavenumbers at which to evaluate the real-space window function.

Returns:

zeros – An array of zeros, indicating that real-space representation is not supported.

Return type:

ndarray

projected(k)[source]

Computes the projected-space approximation of the HEALPix pixel window function.

This method uses a Gaussian beam to approximate the pixel window function in harmonic space. The Gaussian beam is chosen to have a full width at half maximum (FWHM) that is (

rac{1}{sqrt{2}} )

smaller than the pixel size, providing a close approximation to the actual HEALPix pixel window function.

The Gaussian beam ( B(k) ) is computed as:

\[B(k) = \exp\left(-\frac{k(k+1)\sigma^2}{2}\right)\]

where ( sigma ) is the standard deviation of the Gaussian beam, given by:

\[\sigma = \frac{\text{size}}{\sqrt{8 \log(2)} \cdot \sqrt{2}}\]
kndarray

An array of wavenumbers (or multipole moments) at which to evaluate the projected-space window function.

beamndarray

An array representing the Gaussian beam values corresponding to the input wavenumbers.