CSST Emulator API
- class CEmulator.Emulator.CBaseEmulator(verbose=False, neutrino_mass_split='single')
Bases:
objectThe 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. Theneutrino_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 fromNncdm=1toNncdm=3. The transform spectrum can also be directly obtained from theTkmm_CEmulatorclass.
- 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:
- 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:
- 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:
CBaseEmulatorThe 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. Theneutrino_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 fromNncdm=1toNncdm=3. The transform spectrum can also be directly obtained from theTkmm_CEmulatorclass.
- class CEmulator.Emulator.Pkmm_CEmulator(verbose=False, neutrino_mass_split='single')
Bases:
CBaseEmulatorThe 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:
CBaseEmulatorThe 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_ximmhalofit(z=None, r=None, Pcb=False, 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 [default]) 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=False, 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.XihmMassBin_CEmulator(verbose=False, neutrino_mass_split='single')
Bases:
CBaseEmulatorThe halo-matter correlation function [for specified mass bin] emulator class.
- __init__(verbose=False, neutrino_mass_split='single')
Initialize the halo-matter correlation function [for specified mass bin] emulator class.
- Parameters:
verbose – bool, whether to output the running information
- get_xihmMassBin(z=None, r=None, neutrino_mass_split=None)
Get the halo-matter cross correlation function. This function only supports the fixed mass bin Now. Mass bin is [13.0, 13.2, 13.4, 13.6, 13.8, 14.0, 14.4, 15.0].
- Parameters:
z – float or array-like, redshift
r – float or array-like, wavenumber [Mpc/h]
- Returns:
halo-matter cross correlation function with shape (len(z), len(r))
- Return type:
array-like
- class CEmulator.Emulator.HMF_CEmulator(verbose=False, neutrino_mass_split='single')
Bases:
CBaseEmulatorThe 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')
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
Note
For the original Castro23 model, the mass definition only supports RockstarM200m. For the revised Castro23 model, the mass definition supports RockstarM200m, FoFM200c, and RockstarMvir.
- 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
- class CEmulator.Emulator.WeakLensingBaseEmulator(verbose=False, neutrino_mass_split='single')
Bases:
CBaseEmulatorweak 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,WeakLensingBaseEmulatorThe 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.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)
Get the normalized Hubble parameter H(z) at redshift z.
- Parameters:
z – float or array-like, redshift
- Returns:
2D 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)
Get the comoving distance at redshift z. TODO: speed up the calculation
- Parameters:
z – float or array-like, redshift
- Returns:
2D 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).
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).
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