CSST Emulator API

class CEmulator.Emulator.CBaseEmulator(verbose=False, neutrino_mass_split='single')

Bases: object

The CSST Emulator class for various statistics.

__init__(verbose=False, neutrino_mass_split='single')

Initialize the CSST Emulator class.

Parameters:
  • verbose – bool, whether to output the running information

  • neutrino_mass_split – string, ‘single’ or ‘degenerate’, the neutrino mass split type.

Note

The neutrino_mass_split = 'single' means the neutrino mass is treated as a single massive component. Our training data is based on this treatment. The neutrino_mass_split = 'degenerate' means the neutrino mass is treated as three degenerate components. This is achieved by using transformation of linear or HMCODE-2020 power spectrum from Nncdm=1 to Nncdm=3. The transform spectrum can also be directly obtained from the Tkmm_CEmulator class.

set_cosmos(Omegab=0.049, Omegac=0.26, H0=67.66, As=None, sigma8=None, ns=0.9665, w=-1.0, wa=0.0, mnu=0.06, sigma8type='Emulator', checkbound=True)

Set the cosmological parameters.

Parameters:
  • Omegab – float, baryon density

  • Omegac – float, CDM density

  • H0 – float, Hubble constant

  • As – float, amplitude of the primordial power spectrum

  • ns – float, spectral index

  • w – float, dark energy equation of state

  • wa – float, dark energy equation of state evolution

  • mnu – float, sum of neutrino masses with unit eV

  • sigma8 – float, amplitude of the total matter power spectrum. If both As and sigma8 are provided, the As will be used. You can set As=None to activate sigma8.

  • sigma8type – str, ‘Emulator’, ‘CLASS’ or ‘CAMB’, the method to calculate the sigma8.

  • checkbound – bool, whether to check the parameter range.

get_cosmo_class(z=None, non_linear=None, kmax=10, neutrino_mass_split=None)

Get the CLASS cosmology object.

Parameters:
  • z – float or array-like, redshift.

  • non_linear – string, None, ‘halofit’, ‘HMcode’ or other camb arguments.

  • kmax – maximum wave number for CLASS calculation.

get_camb_results(z=None, non_linear=None, kmax=10, neutrino_mass_split=None)

Get the CAMB results object.

Parameters:
  • z – float or array-like, redshift

  • non_linear – string, None, ‘takahashi’ or other camb arguments.

  • kmax – maximum wave number for CAMB calculation.

get_pklin(z=None, k=None, Pcb=False, type='Emulator', cosmo_class=None, camb_results=None, neutrino_mass_split=None)

Get the linear power spectrum.

Parameters:
  • z – float or array-like, redshift

  • k – float or array-like, wavenumber with unit of [h/Mpc]

  • Pcb – bool, whether to output the total power spectrum (if False [default]) or the cb power spectrum (if True)

  • type – string, ‘Emulator’, ‘CLASS’ or ‘CAMB’, liner Pk calcultion method.

  • cosmo_class – CLASS object, if type is ‘CLASS’, then you can provide the CLASS object directly to avoid the repeated calculation for CLASS.

  • camb_results – CAMB results, if type is CAMB, then you can provide the CAMB object directly to avoid the repeated calculation for CAMB.

Returns:

linear power spectrum with shape (len(z), len(k))

Return type:

array-like

get_sigma_z(z=None, R=None, type='Emulator', cosmo_class=None, camb_results=None)

Get the sigma(z, R) of tot matter changing with the redshift.

Parameters:
  • z – float, redshift

  • R – float, smoothing scale [Mpc/h]

  • type – string, ‘Emulator’, ‘CLASS’ or ‘CAMB’ sigma

  • cosmo_class – CLASS object, if type is ‘CLASS’, then you can provide the CLASS object directly to avoid the repeated calculation for CLASS.

  • camb_results – CAMB results, if type is CAMB, then you can provide the CAMB object directly to avoid the repeated calculation for CAMB.

Returns:

sigma8 value with shape (len(z))

Return type:

float

get_sigma_cb_z(z=None, R=None, type='Emulator', cosmo_class=None, camb_results=None)

Get the sigma_cb(z, R) of tot matter changing with the redshift.

Parameters:
  • z – float, redshift

  • R – float, smoothing scale [Mpc/h]

  • type – string, ‘Emulator’, ‘CLASS’ or ‘CAMB’ sigma_cb for cdm + baryon components

  • cosmo_class – CLASS object, if type is ‘CLASS’, then you can provide the CLASS object directly to avoid the repeated calculation for CLASS.

  • camb_results – CAMB results, if type is CAMB, then you can provide the CAMB object directly to avoid the repeated calculation for CAMB.

Returns:

sigma8 value with shape (len(z))

Return type:

float

get_sigma8(type='Emulator', cosmo_class=None, camb_results=None)

Get the sigma8 of tot matter.

Parameters:
  • type – string, ‘Emulator’, ‘CLASS’ or ‘CAMB’

  • cosmo_class – CLASS object, if type is ‘CLASS’, then you can provide the CLASS object directly to avoid the repeated calculation for CLASS.

  • camb_results – CAMB results, if type is CAMB, then you can provide the CAMB object directly to avoid the repeated calculation for CAMB.

get_sigma8_cb(type='Emulator', cosmo_class=None, camb_results=None)

Get the sigma8 of cb matter.

Parameters:
  • type – string, ‘Emulator’, ‘CLASS’ or ‘CAMB’

  • cosmo_class – CLASS object, if type is ‘CLASS’, then you can provide the CLASS object directly to avoid the repeated calculation for CLASS.

  • camb_results – CAMB results, if type is CAMB, then you can provide the CAMB object directly to avoid the repeated calculation for CAMB.

class CEmulator.Emulator.Tkmm_CEmulator(verbose=False, neutrino_mass_split='degenerate')

Bases: CBaseEmulator

The matter power spectrum transformation from Nncdm=1 to Nncdm=3 emulator class.

__init__(verbose=False, neutrino_mass_split='degenerate')

Initialize the CSST Emulator class.

Parameters:
  • verbose – bool, whether to output the running information

  • neutrino_mass_split – string, ‘single’ or ‘degenerate’, the neutrino mass split type.

Note

The neutrino_mass_split = 'single' means the neutrino mass is treated as a single massive component. Our training data is based on this treatment. The neutrino_mass_split = 'degenerate' means the neutrino mass is treated as three degenerate components. This is achieved by using transformation of linear or HMCODE-2020 power spectrum from Nncdm=1 to Nncdm=3. The transform spectrum can also be directly obtained from the Tkmm_CEmulator class.

class CEmulator.Emulator.Pkmm_CEmulator(verbose=False, neutrino_mass_split='single')

Bases: CBaseEmulator

The matter power spectrum emulator class.

__init__(verbose=False, neutrino_mass_split='single')

Initialize the matter power spectrum emulator class.

Parameters:

verbose – bool, whether to output the running information

get_pkhalofit(z=None, k=None, Pcb=False, lintype='Emulator', cosmo_class=None, camb_results=None, neutrino_mass_split=None)

Get the halofit power spectrum. [only Nncdm=1]

Note

This version can not converge with CLASS in the high redshift (z>2.5) for the c0001 and c0091 (w0 and wa near the lower limit).

Parameters:
  • z – float or array-like, redshift

  • k – float or array-like, wavenumber [h/Mpc]

  • Pcb – bool, whether to output the total power spectrum (if False [default]) or the cb power spectrum (if True)

  • lintype – string, ‘Emulator’, ‘CLASS’ or ‘CAMB’ halofit results

  • cosmo_class – CLASS object, if type is ‘CLASS’, then you can provide the CLASS object directly to avoid the repeated calculation for CLASS.

  • camb_results – CAMB results, if type is CAMB, then you can provide the CAMB object directly to avoid the repeated calculation for CAMB.

Returns:

halofit power spectrum with shape (len(z), len(k))

Return type:

array-like

get_pkHMCODE2020(z=None, k=None, Pcb=False, lintype='Emulator', cosmo_class=None, camb_results=None, neutrino_mass_split=None)

Get the linear power spectrum from HMCODE2020.

Parameters:
  • z – float or array-like, redshift

  • k – float or array-like, wavenumber [h/Mpc]

  • lintype – string, ‘Emulator’, ‘CLASS’ or ‘CAMB’ halofit results

  • Pcb – bool, whether to output the total power spectrum (if False [default]) or the cb power spectrum (if True)

  • cosmo_class – CLASS object, if type is ‘CLASS’, then you can provide the CLASS object directly to avoid the repeated calculation for CLASS.

  • camb_results – CAMB results, if type is CAMB, then you can provide the CAMB object directly to avoid the repeated calculation for CAMB.

Returns:

linear power spectrum with shape (len(z), len(k))

Return type:

array-like

get_pknl(z=None, k=None, Pcb=False, lintype='Emulator', nltype='hmcode2020', cosmo_class=None, camb_results=None, neutrino_mass_split=None)

Get the nonlinear power spectrum.

Note

For now, nltype = ‘hmcode2020’, ‘halofit’ can give a better result than nltype = ‘linear’. For nltype = ‘halofit’ or ‘hmcode2020’, we only use the ‘Emulator’ method to generate the halofit Pk for consistency between trainning and output data. The lintype only determine which method to generate the neutrino linear Pk. For nltype = ‘linear’, lintype determine which method to generate the linear cb and mm Pk. Because the agreements of linear Pk between CAMB, CLASS and Emulator is better than 0.5%.

Parameters:
  • z – float or array-like, redshift.

  • k – float or array-like, wavenumber [h/Mpc].

  • Pcb – bool, whether to output the total power spectrum (if False [default]) or the cb power spectrum (if True).

  • lintype – string, use ‘Emulator’, ‘CLASS’ or ‘CAMB’ method to generate linear Pk. Default is ‘Emulator’.

  • nltype – string, ‘linear’, ‘halofit’ or ‘hmcode2020’. means ratio of nonlinear to nltype power spectrum. Default is ‘hmcode2020’.

  • cosmo_class – CLASS object, if type is ‘CLASS’, then you can provide the CLASS object directly to avoid the repeated calculation for CLASS.

  • camb_results – CAMB results, if type is CAMB, then you can provide the CAMB object directly to avoid the repeated calculation for CAMB.

Returns:

nonlinear power spectrum with shape (len(z), len(k))

Return type:

array-like

class CEmulator.Emulator.Ximm_CEmulator(verbose=False, neutrino_mass_split='single')

Bases: CBaseEmulator

The matter correlation function emulator class.

__init__(verbose=False, neutrino_mass_split='single')

Initialize the matter correlation function emulator class.

Parameters:

verbose – bool, whether to output the running information

get_ximmlinear(z=None, r=None, Pcb=True, neutrino_mass_split=None)

Get the matter [cb] correlation function by combining the linear power spectrum and FFTLog.

Parameters:
  • z – float or array-like, redshift

  • r – float or array-like, wavenumber [Mpc/h]

  • Pcb – bool, whether to output the total power spectrum (if False) or the cb power spectrum (if True)

Returns:

matter-matter correlation function with shape (len(z), len(r))

Return type:

array-like

get_ximmhalofit(z=None, r=None, Pcb=True, neutrino_mass_split=None)

Get the matter [cb] correlation function by combining the halofit power spectrum and FFTLog.

Parameters:
  • z – float or array-like, redshift

  • r – float or array-like, wavenumber [Mpc/h]

  • Pcb – bool, whether to output the total power spectrum (if False) or the cb power spectrum (if True)

Returns:

matter-matter correlation function with shape (len(z), len(r))

Return type:

array-like

get_ximmHMCODE2020(z=None, r=None, Pcb=True, neutrino_mass_split=None)

Get the matter [cb] correlation function by combining the HMCODE202 power spectrum and FFTLog.

Parameters:
  • z – float or array-like, redshift

  • r – float or array-like, wavenumber [Mpc/h]

  • Pcb – bool, whether to output the total power spectrum (if False) or the cb power spectrum (if True)

Returns:

matter-matter correlation function with shape (len(z), len(r))

Return type:

array-like

get_ximmnl(z=None, r=None, Pcb=True, neutrino_mass_split=None)

Get the matter-matter correlation function.

Parameters:
  • z – float or array-like, redshift

  • r – float or array-like, wavenumber [Mpc/h]

  • Pcb – bool, whether to output the total power spectrum (if False [default]) or the cb power spectrum (if True)

Returns:

matter-matter correlation function with shape (len(z), len(r))

Return type:

array-like

class CEmulator.Emulator.HMF_CEmulator(verbose=False, neutrino_mass_split='single')

Bases: CBaseEmulator

The halo mass function emulator class.

__init__(verbose=False, neutrino_mass_split='single')

Initialize the halo mass function emulator class.

Parameters:

verbose – bool, whether to output the running information

get_dndlnM_Tinker08(z=None, M=None, Pcb=True, Delta=200, rho_type='matter')

Get the halo mass function with Tinker08 model.

Parameters:
  • z – float or array-like, redshift

  • M – float or array-like, halo mass [Msun/h]

  • Pcb – bool, whether to use the total power spectrum (if False) or the cb power spectrum (if True [default])

get_dndlnM_Castro23(z=None, M=None, Pcb=True, revisted=True, massdef='RockstarMvir', return_vars=False)

Get the halo mass function with Castro23 model.

Parameters:
  • z – float or array-like, redshift

  • M – float or array-like, halo mass [Msun/h]

  • Pcb – bool, whether to use the total power spectrum (if False[just for test]) or the cb power spectrum (if True [default])

  • revisted – bool, whether to use the revised Castro23 model (if True[default]) or the original Castro23 model (if False)

  • massdef – string, the mass definition used in the emulator

  • return_vars – bool, whether to return the intermediate variables (if True) or not (if False [default])

Note

For the original Castro23 model, the mass definition only supports RockstarMvir For the revised Castro23 model, the mass definition supports RockstarM200m, FoFM200c, FoFM200m, RockstarMvir, RockstarMvir_bound

get_Nhalo(z=None, M=None, V=1, massdef='RockstarM200m')

Get the number of haloes whose mass is not smaller than M. [ $N(geq M)$ ]

Parameters:
  • z – float or array-like, redshift

  • M – float or array-like, halo mass [Msun/h]

  • V – float, volume [Mpc/h]^3

Returns:

halo mass function with shape (len(z), len(m))

Return type:

array-like

get_dndlnM(z=None, M=None, massdef='RockstarM200m')

Get the number density of haloes in the mass bin [ $dn/dln M$ ] with unit of [Mpc/h]^-3. [Affected by the binning effect, not recommended to use.]

Parameters:
  • z – float or array-like, redshift

  • M – float or array-like, halo mass [Msun/h]

Returns:

halo mass function with shape (len(z), len(M))

Return type:

array-like

get_bias_Castro23(z=None, M=None, Pcb=True, revisted=True, massdef='RockstarMvir')

Get the halo bias with Castro23 model.

Parameters:
  • z – float or array-like, redshift

  • M – float or array-like, halo mass [Msun/h]

  • Pcb – bool, whether to use the total power spectrum (if False[just for test]) or the cb power spectrum (if True [default])

  • revisted – bool, whether to use the revised Castro23 model (if True[default]) or the original Castro23 model (if False)

  • massdef – string, the mass definition used in the emulator

Note

For the original Castro23 model, the mass definition only supports RockstarMvir For the revised Castro23 model, the mass definition supports RockstarM200m, FoFM200c, FoFM200m, RockstarMvir, RockstarMvir_bound.

get_bias_mass_threshold(z=None, M=None, Pcb=True, massdef='RockstarM200m')

Get the halo bias emulation result.

Parameters:
  • z – float or array-like, redshift

  • M – float or array-like, halo mass [Msun/h]

  • Pcb – bool, whether to use the total power spectrum (if False[just for test]) or the cb power spectrum (if True [default])

  • massdef – string, the mass definition used in the emulator

get_bias_lgnbar_threshold(z=None, lgden=None, massdef='RockstarM200m')

Get the halo bias with CSST Emulator with lgar{n} threshold.

Parameters:
  • z – float or array-like, redshift

  • lgden – float or array-like, the log10 of the number density threshold [Mpc/h]^-3

  • massdef – string, the mass definition used in the emulator

Returns:

halo bias with shape (len(z), len(lgden))

Return type:

array-like

get_bias_mass(z=None, M=None, massdef='RockstarM200m')

Get the halo bias with CSST Emulator with mass threshold.

Parameters:
  • z – float or array-like, redshift

  • M – float or array-like, halo mass [Msun/h]

  • massdef – string, the mass definition used in the emulator

Returns:

halo bias with shape (len(z), len(mass))

Return type:

array-like

class CEmulator.Emulator.Pkhm_CEmulator(verbose=False, neutrino_mass_split='single')

Bases: HMF_CEmulator

The halo-matter power spectrum emulator class.

__init__(verbose=False, neutrino_mass_split='single')

Initialize the halo-matter power spectrum emulator class.

Parameters:

verbose – bool, whether to output the running information

get_pkhm_lgnbar_threshold(z=None, k=None, lgden=None, massdef='RockstarM200m', Pcb=True)

Get the halo-matter power spectrum with fixed halo number density lgar{n} threshold.

Parameters:
  • z – float or array-like, redshift

  • k – float or array-like, wavenumber [h/Mpc]

  • lgden – float or array-like, log10 of the halo number density threshold [log10(h^3/Mpc^3)]

  • massdef – string, mass definition for the halo-matter power spectrum. For now only support ‘RockstarM200m’.

  • Pcb – bool, whether to output the total power spectrum (if False) or the cb power spectrum (if True)

Returns:

halo-matter power spectrum with shape (len(lgden), len(z), len(k))

Return type:

array-like

get_pkhm_mass_threshold(z=None, k=None, M=None, massdef='RockstarM200m', Pcb=True)

Get the halo-matter power spectrum for halos with mass larger than M.

Parameters:
  • z – float or array-like, redshift

  • k – float or array-like, wavenumber [h/Mpc]

  • lgden – float or array-like, log10 of the halo number density threshold [log10(h^3/Mpc^3)]

  • massdef – string, mass definition for the halo-matter power spectrum. For now only support ‘RockstarM200m’.

  • Pcb – bool, whether to output the total power spectrum (if False) or the cb power spectrum (if True)

Returns:

halo-matter power spectrum with shape (len(M), len(z), len(k))

Return type:

array-like

get_pkhm_mass(z=None, k=None, M=None, massdef='RockstarM200m', Pcb=True)

Get the halo-matter power spectrum for a narrow mass bin (differential).

Uses finite difference: d/dM [N(>M) * P_hm(>M)] / (dN/dM).

Unlike get_pkhm_mass_threshold which returns the cumulative result, this returns the per-mass-bin differential quantity suitable for weighting by dn/dM in HOD integrals.

Parameters:
  • z – float or array-like, redshift

  • k – float or array-like, wavenumber [h/Mpc]

  • M – float or array-like, halo mass [Msun/h]

  • massdef – str, mass definition

  • Pcb – bool, use cb spectrum

Returns:

ndarray with shape (len(M), len(z), len(k))

class CEmulator.Emulator.Xihm_CEmulator(verbose=False, neutrino_mass_split='single')

Bases: Pkhm_CEmulator, Ximm_CEmulator

The halo-matter correlation function emulator class.

__init__(verbose=False, neutrino_mass_split='single')

Initialize the halo-matter correlation function emulator class.

Parameters:

verbose – bool, whether to output the running information

get_xihm_lgnbar_threshold(z=None, r=None, lgden=None, massdef='RockstarM200m', Pcb=True)

Get the halo-matter correlation function with fixed halo number density lgar{n} threshold.

Parameters:
  • z – float or array-like, redshift

  • r – float or array-like, distance [Mpc/h]

  • lgden – float or array-like, log10 of the halo number density threshold [log10(h^3/Mpc^3)]

  • massdef – string, mass definition for the halo-matter correlation function. For now only support ‘RockstarM200m’.

  • Pcb – bool, whether to output the total correlation function (if False) or the cb correlation function (if True)

Returns:

halo-matter correlation function with shape (len(lgden), len(z), len(r))

Return type:

array-like

get_xihm_mass(z=None, r=None, M=None, massdef='RockstarM200m', Pcb=True)

Get the halo-matter correlation function with fixed halo number density lgar{n} threshold.

Parameters:
  • z – float or array-like, redshift

  • r – float or array-like, distance [Mpc/h]

  • M – float or array-like, halo mass [Msun/h]

  • massdef – string, mass definition for the halo-matter correlation function. For now only support ‘RockstarM200m’.

  • Pcb – bool, whether to output the total correlation function (if False) or the cb correlation function (if True)

Returns:

halo-matter correlation function with shape (len(M), len(z), len(r))

Return type:

array-like

class CEmulator.Emulator.Xihh_CEmulator(verbose=False, neutrino_mass_split='single')

Bases: HMF_CEmulator

The halo-halo correlation function

__init__(verbose=False, neutrino_mass_split='single')

Initialize the halo-halo correlation function [for specified mass bin] emulator class.

Parameters:

verbose – bool, whether to output the running information

get_xihh_lgnbar_threshold(z=None, r=None, lgden1=None, lgden2=None, massdef='RockstarM200m')

Get the halo-halo auto correlation function for a number density threshold. :param z: float or array-like, redshift :param r: float or array-like, wavenumber [Mpc/h] :param lgden1: float or array-like, log10 of number density :param lgden2: float or array-like, log10 of number density

Returns:

halo-halo auto correlation function with shape (len(lgden1), len(lgden2), len(z), len(r))

Return type:

array-like

get_xihh_mass(z=None, r=None, M1=None, M2=None, massdef='RockstarM200m')

Get the halo-halo auto correlation function for a fixed mass. :param z: float or array-like, redshift :param r: float or array-like, wavenumber [Mpc/h] :param M1: float or int, halo mass [Msun/h] for the first halo sample :param M2: float or int, halo mass [Msun/h] for the second halo sample

Returns:

halo-halo auto correlation function with shape (len(M), len(z), len(r))

Return type:

array-like

class CEmulator.Emulator.WeakLensingBaseEmulator(verbose=False, neutrino_mass_split='single')

Bases: CBaseEmulator

weak lensing part

get_lensing_kernel(chi=None, dndz=None, Pcb=False, use_ccl=False)

Get the weak lensing kernel.

Parameters:
  • chi – float or array-like, comoving distance [Mpc]

  • dndz – tuple, redshift distribution function, tuple (zarr, narr)

  • Pcb – bool, whether to output the total matter (if False [default]) or the cb component (if True )

  • case (Pcb=True only for my specific case. For general)

  • Pcb=False. (you should set)

Returns:

weak lensing kernel with shape (len(z), len(chi))

Return type:

array-like

get_kappa_kernel(chi=None, z_s=1100, Pcb=False, use_ccl=False)

Get the lensing kernel for a specific source redshift.

Parameters:
  • chi – float or array-like, comoving distance [Mpc]

  • z_s – float, source redshift

  • Pcb – bool, whether to output the total matter (if False [default]) or the cb component (if True )

Returns:

lensing kernel with shape (len(z))

Return type:

array-like

class CEmulator.Emulator.Cell_CEmulator(verbose=False, neutrino_mass_split='single')

Bases: Pkmm_CEmulator, WeakLensingBaseEmulator

The convergence power spectrum emulator class.

get_Limber_Cells(ells=None, dndz=None, z_s=None, Pcb=False, non_linear='Emulator', return_shot_noise=None, verbose=False, use_ccl=False)

Get the weak lensing power spectrum.

Parameters:
  • ells – float or array-like, multipole

  • dndz – tuple, redshift distribution function, tuple (zarr, narr)

  • z_s – float, source redshift for single source plane

  • Pcb – bool, whether to output the total matter (if False [default]) or the cb component (if True )

  • non_linear – string, ‘Emulator’, ‘halofit’ or ‘linear’ power spectrum

  • return_shot_noise – float, return the shot noise if not None. The vaule should be the shot noise level V_{sim}/N_{sim} [Mpc^3/h^3].

  • verbose – bool, whether to output the time for each step

Returns:

weak lensing power spectrum with shape (len(ells))

Return type:

array-like

class CEmulator.Emulator.GalaxyEmulator(verbose=False, neutrino_mass_split='single')

Bases: Xihm_CEmulator

Galaxy clustering statistics emulator with HOD support.

This class extends the Xihm_CEmulator to compute galaxy clustering statistics using Halo Occupation Distribution (HOD) models. It combines the halo mass function (HMF), halo-matter correlation (Xihm), and halo-halo correlation (Xihh) emulators with HOD models to compute galaxy observables.

The emulator supports computing galaxy number densities, galaxy-matter correlations, galaxy-galaxy correlations, and related statistics for various HOD parameterizations.

Parameters:
  • verbose (bool, default=False) – Whether to print diagnostic information during calculations

  • neutrino_mass_split (str, default='single') – Neutrino mass treatment: ‘single’ for one massive species, ‘degenerate’ for three degenerate species

Cosmo

Cosmology object for distance and background calculations

Type:

Cosmology

_xihh_emu

Halo-halo correlation emulator (lazy loaded)

Type:

Xihh_CEmulator

_hod_model

Current HOD model instance

Type:

HODModel

_hod_params

Current HOD parameters

Type:

dict

_galaxy_calc

Calculator for galaxy statistics (initialized with HOD)

Type:

GalaxyStatsCalculator

Notes

The GalaxyEmulator inherits from Xihm_CEmulator, which provides access to: - HMF (halo mass function) - Xihm (halo-matter correlation) - Pk (power spectrum calculations)

Additional emulators (Xihh) are loaded lazily to minimize memory usage when only a subset of statistics is needed.

The HOD parameters are cached, so repeated calculations with the same parameters are efficient.

Examples

>>> emu = GalaxyEmulator(verbose=True)
>>> emu.set_cosmos(Omegab=0.049, Omegam=0.30, H0=67.66, mnu=0.06)
>>> # Set HOD parameters
>>> emu.set_hod('Zheng05', logMmin=12.0, sigma_logM=0.5,
...             logM0=12.5, logM1=13.5, alpha=1.0)
>>> # Compute galaxy statistics
>>> r = np.logspace(-1, 1, 50)  # Mpc/h
>>> z = 0.5
>>> ngal = emu.ngal(z)  # Galaxy number density
>>> Xigm = emu.Xigm(r, z)  # Galaxy-matter correlation
>>> Xigg = emu.Xigg(r, z)  # Galaxy-galaxy correlation

References

__init__(verbose=False, neutrino_mass_split='single')

Initialize the GalaxyEmulator.

property Xihh

Halo-halo correlation emulator (lazy loaded).

Returns:

Halo-halo correlation emulator instance

Return type:

Xihh_CEmulator

set_hod(model_name='Zheng05', check_bounds=True, **hod_params)

Set the HOD model and parameters.

Parameters:
  • model_name (str, default='Zheng05') – Name of the HOD model. Options: ‘Zheng05’, ‘Zheng07’

  • check_bounds (bool, default=True) – Whether to check parameter bounds

  • **hod_params (dict) – HOD model parameters (e.g., logMmin, sigma_logM, etc.)

Raises:

ValueError – If model_name is not recognized or parameters are out of bounds

Examples

>>> emu.set_hod('Zheng05', logMmin=12.0, sigma_logM=0.5,
...             logM0=12.5, logM1=13.5, alpha=1.0)
>>> # With assembly bias (Zheng07)
>>> emu.set_hod('Zheng07', logMcut=12.0, sigma=0.3,
...             logM1=13.5, alpha=1.0, kappa=1.0, fic=1.0,
...             A_cen=0.1, A_sat=0.05)
ngal(z)

Compute the galaxy number density n_gal(z).

Parameters:

z (float or array_like) – Redshift(s)

Returns:

Galaxy number density in (Mpc/h)^(-3)

Return type:

float or ndarray

Raises:

ValueError – If HOD has not been initialized

Examples

>>> emu.set_hod('Zheng05', logMmin=12.0, sigma_logM=0.5,
...             logM0=12.5, logM1=13.5, alpha=1.0)
>>> ngal_05 = emu.ngal(0.5)  # At single redshift
>>> ngal_arr = emu.ngal([0.0, 0.5, 1.0])  # At multiple redshifts
f_sat(z)

Compute the satellite fraction f_sat = n_sat / n_gal.

Parameters:

z (float or array_like) – Redshift(s)

Returns:

Satellite fraction (0 to 1)

Return type:

float or ndarray

Examples

>>> emu.set_hod('Zheng05', **params)
>>> fsat = emu.f_sat(0.5)
M_eff(z)

Compute the effective halo mass for galaxy hosting.

Parameters:

z (float or array_like) – Redshift(s)

Returns:

Effective mass in Msun/h

Return type:

float or ndarray

Examples

>>> emu.set_hod('Zheng05', **params)
>>> Meff = emu.M_eff(0.5)
bias_gal(z)

Compute the large-scale galaxy bias.

Parameters:

z (float or array_like) – Redshift(s)

Returns:

Galaxy bias b_g

Return type:

float or ndarray

Examples

>>> emu.set_hod('Zheng05', **params)
>>> b_g = emu.bias_gal(0.5)
Xigm(r, z)

Compute the galaxy-matter correlation function xi_{gm}(r, z).

Uses the Fourier-space calculation (P_gm(k) → FFTLog → ξ_gm(r)) which properly includes off-centering and satellite profile convolution (Eq. G8 in Dark Quest I).

Parameters:
  • r (array_like) – Separation in Mpc/h

  • z (float or array_like) – Redshift(s)

Returns:

Galaxy-matter correlation with shape (len(z), len(r))

Return type:

ndarray

Raises:

ValueError – If HOD has not been initialized

Examples

>>> r = np.logspace(-1, 1, 50)
>>> z = 0.5
>>> Xigm = emu.Xigm(r, z)
Xigg(r, z)

Compute xi_gg(r, z) using Fourier-space cc/cs/ss decomposition.

Uses the full P_gg(k) = P_cc + P_cs + P_ss decomposition with HOD weights convolved with the satellite profile and off-centering kernel, avoiding the linear bias approximation for the 2-halo term.

Parameters:
  • r (array_like) – Separation in Mpc/h

  • z (float or array_like) – Redshift(s)

Returns:

Galaxy-galaxy correlation with shape (len(z), len(r))

Return type:

ndarray

Raises:

ValueError – If HOD has not been initialized

wgm(rp, z, pimax=None)

Compute the projected galaxy-matter correlation w_{gm}(r_p).

Uses the FFTLog J_0 Hankel transform of P_gm(k), which is equivalent to integrating ξ_gm along the line of sight to infinity. This is faster and more accurate than the real-space projection approach.

Parameters:
  • rp (array_like) – Projected separation in Mpc/h

  • z (float or array_like) – Redshift(s)

  • pimax (float, optional) – Ignored when using FFTLog method (infinite projection). Kept for API compatibility.

Returns:

Projected galaxy-matter correlation w_{gp}(r_p)

Return type:

ndarray

Examples

>>> rp = np.logspace(-1, 1.5, 30)
>>> z = 0.5
>>> wgm = emu.wgm(rp, z)
Pgm(k, z)

Galaxy-matter cross power spectrum P_{gm}(k, z).

Parameters:
  • k (array_like) – Wavenumbers in h/Mpc

  • z (float) – Redshift

Returns:

Galaxy-matter power spectrum P_{gm}(k)

Return type:

ndarray

Pgg(k, z)

Galaxy-galaxy power spectrum P_{gg}(k, z).

Parameters:
  • k (array_like) – Wavenumbers in h/Mpc

  • z (float) – Redshift

Returns:

Galaxy-galaxy power spectrum P_{gg}(k)

Return type:

ndarray

wp(rp, z, pimax=100.0)

Projected galaxy correlation function w_p(r_p, z).

When pimax is given (default 100 Mpc/h), uses real-space projection \(w_p(r_p) = 2\int_0^{\pi_{\\rm max}} \\xi_{gg}(\\sqrt{r_p^2+\pi^2})\\, d\pi\).

When pimax=None, uses the FFTLog J_0 Hankel transform of P_gg(k) (equivalent to infinite LOS integration).

Parameters:
  • rp (array_like) – Projected separations in Mpc/h

  • z (float or array_like) – Redshift(s)

  • pimax (float or None, default=100.0) – Maximum LOS integration distance in Mpc/h. None uses FFTLog (infinite projection).

Returns:

Projected correlation w_p(r_p) with shape (len(z), len(rp))

Return type:

ndarray

Examples

>>> rp = np.logspace(-1, 1.5, 30)
>>> z = 0.5
>>> wp = emu.wp(rp, z)
>>> wp_inf = emu.wp(rp, z, pimax=None)
wp_cc_2h(rp, z, pimax=100.0)

w_p contributed by the central-central 2-halo term.

Parameters:
  • rp (array_like) – Projected separations in Mpc/h

  • z (float or array_like) – Redshift(s)

  • pimax (float or None, default=100.0) – Maximum LOS integration distance. None for FFTLog.

Returns:

Projected correlation w_p^{cc,2h}(r_p) with shape (len(z), len(rp))

Return type:

ndarray

wp_cs_1h(rp, z, pimax=100.0)

w_p contributed by the central-satellite 1-halo term.

Parameters:
  • rp (array_like) – Projected separations in Mpc/h

  • z (float or array_like) – Redshift(s)

  • pimax (float or None, default=100.0) – Maximum LOS integration distance. None for FFTLog.

Returns:

with shape (len(z), len(rp))

Return type:

ndarray

wp_cs_2h(rp, z, pimax=100.0)

w_p contributed by the central-satellite 2-halo term.

Parameters:
  • rp (array_like)

  • z (float or array_like)

  • pimax (float or None, default=100.0)

Returns:

with shape (len(z), len(rp))

Return type:

ndarray

wp_ss_1h(rp, z, pimax=100.0)

w_p contributed by the satellite-satellite 1-halo term.

Parameters:
  • rp (array_like)

  • z (float or array_like)

  • pimax (float or None, default=100.0)

Returns:

with shape (len(z), len(rp))

Return type:

ndarray

wp_ss_2h(rp, z, pimax=100.0)

w_p contributed by the satellite-satellite 2-halo term.

Parameters:
  • rp (array_like)

  • z (float or array_like)

  • pimax (float or None, default=100.0)

Returns:

with shape (len(z), len(rp))

Return type:

ndarray

DeltaSigma(R, z)

Excess surface density ΔΣ(R, z) for galaxy-galaxy lensing.

\[\Delta\Sigma(R) = \bar{\rho}_m \int_0^\infty \frac{k\,dk}{2\pi} P_{gm}(k) J_2(kR)\]
Parameters:
  • R (array_like) – Projected separations in Mpc/h

  • z (float or array_like) – Redshift(s)

Returns:

Excess surface density ΔΣ(R) in \(h M_\odot / \mathrm{pc}^2\)

Return type:

ndarray

Examples

>>> R = np.logspace(-1, 1.5, 30)
>>> z = 0.5
>>> ds = emu.DeltaSigma(R, z)
DeltaSigma_components(R, z)

Decompose ΔΣ(R, z) into central (centered), central (off-centered), and satellite contributions.

When f_off and R_off are not given (both None), the values stored in self._hod_params (set via set_hod()) are used.

Parameters:
  • R (array_like) – Projected separations in Mpc/h

  • z (float or array_like) – Redshift(s)

Returns:

(DS_cen, DS_off, DS_sat) – Each component has shape (n_z, n_R) or (n_R,).

Return type:

tuple of ndarray

Examples

>>> R = np.logspace(-1, 1.5, 30)
>>> z = 0.5
>>> ds_cen, ds_off, ds_sat = emu.DeltaSigma_components(R, z)
>>> ds_cen, ds_off, ds_sat = emu.DeltaSigma_components(R, z, f_off=0.15, R_off=0.25)
Xigm_fourier(r, z)

Compute xi_{gm}(r, z) via P_gm(k) + FFTLog.

Parameters:
  • r (array_like) – Separation in Mpc/h

  • z (float or array_like) – Redshift(s)

Returns:

Galaxy-matter correlation ξ_{gm}(r)

Return type:

ndarray

get_hod_summary(z)

Get a summary of galaxy properties at given redshift(s).

Parameters:

z (float or array_like) – Redshift(s)

Returns:

Dictionary containing: - ‘ngal’: Galaxy number density - ‘f_sat’: Satellite fraction - ‘M_eff’: Effective halo mass - ‘bias’: Galaxy bias - ‘hod_params’: HOD parameters used

Return type:

dict

Examples

>>> summary = emu.get_hod_summary(0.5)
>>> print(f"n_gal = {summary['ngal']:.4e} h^3/Mpc^3")
class CEmulator.cosmology.Cosmology(verbose=False, neutrino_mass_split='single')

Bases: object

__init__(verbose=False, neutrino_mass_split='single')

Initialize the CSST cosmology class.

Parameters:
  • verbose – bool, whether to output the running information

  • neutrino_mass_split – string, ‘single’ or ‘degenerate’, the neutrino mass split type.

set_cosmos(cosmologies)

set the cosmologies for the cosmology class

get_Ez(z, neutrino_matter_like=False)

Get the normalized Hubble parameter H(z) at redshift z.

Parameters:

z – float or array-like, redshift

Returns:

array of shape (len(z)), normalized Hubble parameter H(z)/H0

Return type:

array-like

get_Omegam(z)

Get the total matter density without massive neutrinos at redshift z.

Parameters:

z – float or array-like, redshift

Returns:

2D array of shape (len(z)), total matter density without massive neutrinos

Return type:

array-like

get_OmegaM(z)

Get the total matter density at redshift z.

Parameters:

z – float or array-like, redshift

Returns:

2D array of shape (len(z)), total matter density

Return type:

array-like

get_OmegaL(z)

Get the dark energy density at redshift z.

Parameters:

z – float or array-like, redshift

Returns:

2D array of shape (len(z)), dark energy density

Return type:

array-like

comoving_distance(z, neutrino_matter_like=False)

Get the comoving distance at redshift z.

Uses a single trapezoidal integration over a shared fine grid so that the cost scales with one get_Ez call, not N individual quad calls.

Parameters:

z – float or array-like, redshift

Returns:

array of shape (len(z)), comoving distance in Mpc

Return type:

array-like

Note

The hankl module is from the hankl package, which is a Python package for Hankel Transform.

CEmulator.hankl.cosmology.P2xi(k, P, l, n=0, lowring=False, ext=0, range=None, return_ext=False)

Hankel Transform Power Spectrum Multipole to Correlation Function Multipole.

\[\xi_{l}^{(n)}(r) = i^{l} \int_{0}^{\infty} k^{2} dk / (2 \pi^{2}) (kr)^{-n} P_{l}^{(n)}(k) j_{l}(ks)\]
Parameters:
  • k (array) – Array of uniformly logarithmically spaced wavenumbers.

  • P (array) – Array of respective Power Spectrum values.

  • l (int) – Degree of Power Spectrum multipole.

  • n (int) – Order of expansion (Default is 0, plane-parallel).

  • lowring (bool) – If True then use low-ringing value of kr (Default is False).

  • ext (int or tuple or list) –

    Controls the extrapolation mode. When ext is an integer then the same extrapolation method will be used for both ends of the input array. Alternatively, when ext is an tuple (ext_left, ext_right) or a list [ext_left, ext_right] then different methods can be used for the two ends of the the input array.

    • if ext=0 then no extrapolation is performed (Default).

    • if ext=1 then zero padding is performed.

    • if ext=2 then constant padding is performed.

    • if ext=3 then Power-Law extrapolation is performed.

  • range (tuple or list) – The minimum extrapolation range in the form of a tuple (k_min, k_max) or list [k_min, k_max]. When range=None (Default) then the extended range is chosen automatically such that its array-size is the next power of two.

  • return_ext (bool) – When False (Default) the result is cropped to fit the original k range.

Returns:

r, xi – Array of uniformly logarithmically spaced r values and respective array of \(xi_{l}^{(n)}(r)\) values.

Return type:

array, array

CEmulator.hankl.cosmology.xi2P(r, xi, l, n=0, lowring=False, ext=0, range=None, return_ext=False)

Hankel Transform Correlation Function Multipole to Power Spectrum Multipole.

\[P_{l}^{(n)}(k) = 4 \pi (-i)^{l} \int_{0}^{\infty} r^{2} dr (kr)^{n} \xi_{l}^{(n)}(r) j_{l}(kr)\]
Parameters:
  • r (array) – Array of uniformly logarithmically spaced separations.

  • xi (array) – Array of respective two point correlation function values.

  • l (int) – Degree of Power Spectrum multipole.

  • n (int) – Order of expansion (Default is 0, plane-parallel).

  • lowring (bool) – If True then use low-ringing value of kr (Default is False).

  • ext (int or tuple or list) –

    Controls the extrapolation mode. When ext is an integer then the same extrapolation method will be used for both ends of the input array. Alternatively, when ext is an tuple (ext_left, ext_right) or a list [ext_left, ext_right] then different methods can be used for the two ends of the the input array.

    • if ext=0 then no extrapolation is performed (Default).

    • if ext=1 then zero padding is performed.

    • if ext=2 then constant padding is performed.

    • if ext=3 then Power-Law extrapolation is performed.

  • range (tuple or list) – The minimum extrapolation range in the form of a tuple (k_min, k_max) or list [k_min, k_max]. When range=None (Default) then the extended range is chosen automatically such that its array-size is the next power of two.

  • return_ext (bool) – When False (Default) the result is cropped to fit the original k range.

Returns:

k, P – Array of uniformly logarithmically spaced k values and array of respective \(P_{l}^{(n)}(k)\) values.

Return type:

array, array