mirror of
https://github.com/Richard-Sti/csiborgtools.git
synced 2024-12-23 03:58:02 +00:00
9e4b34f579
* Update README * Update density field reader * Update name of SDSSxALFAFA * Fix quick bug * Add little fixes * Update README * Put back fit_init * Add paths to initial snapshots * Add export * Remove some choices * Edit README * Add Jens' comments * Organize imports * Rename snapshot * Add additional print statement * Add paths to initial snapshots * Add masses to the initial files * Add normalization * Edit README * Update README * Fix bug in CSiBORG1 so that does not read fof_00001 * Edit README * Edit README * Overwrite comments * Add paths to init lag * Fix Quijote path * Add lagpatch * Edit submits * Update README * Fix numpy int problem * Update README * Add a flag to keep the snapshots open when fitting * Add a flag to keep snapshots open * Comment out some path issue * Keep snapshots open * Access directly snasphot * Add lagpatch for CSiBORG2 * Add treatment of x-z coordinates flipping * Add radial velocity field loader * Update README * Add lagpatch to Quijote * Fix typo * Add setter * Fix typo * Update README * Add output halo cat as ASCII * Add import * Add halo plot * Update README * Add evaluating field at radial distanfe * Add field shell evaluation * Add enclosed mass computation * Add BORG2 import * Add BORG boxsize * Add BORG paths * Edit run * Add BORG2 overdensity field * Add bulk flow clauclation * Update README * Add new plots * Add nbs * Edit paper * Update plotting * Fix overlap paths to contain simname * Add normalization of positions * Add default paths to CSiBORG1 * Add overlap path simname * Fix little things * Add CSiBORG2 catalogue * Update README * Add import * Add TNG density field constructor * Add TNG density * Add draft of calculating BORG ACL * Fix bug * Add ACL of enclosed density * Add nmean acl * Add galaxy bias calculation * Add BORG acl notebook * Add enclosed mass calculation * Add TNG300-1 dir * Add TNG300 and BORG1 dir * Update nb
4.8 KiB
4.8 KiB
In [1]:
import numpy as np
import scipy.integrate
import symbolic_pofk.linear
import symbolic_pofk.syrenhalofit as syrenhalofit
In [26]:
def compute_sigma8_from_pk(k, pk):
"""Given a power spectrum P(k), compute sigma8."""
R = 8.0
x = k * R
W = np.zeros(x.shape)
m = x < 1.e-3
W[m] = 1.0
W[~m] =3.0 / x[~m]**3 * (np.sin(x[~m]) - x[~m] * np.cos(x[~m]))
y = pk * W**2 * k**3
sigma2 = scipy.integrate.simpson(y, x=np.log(x))
sigma = np.sqrt(sigma2 / (2.0 * np.pi**2))
return sigma
# Cosmological parameters
As = 2.105 # 10^9 A_s
h = 0.6766
Om = 0.3111
Ob = 0.02242 / h ** 2
ns = 0.9665
tau = 0.0561
# Define k integration range
def linear_sigma8(As, Om, Ob, h, ns):
"""Calculated from Deaglan's emulator."""
return symbolic_pofk.linear.As_to_sigma8(As, Om, Ob, h, ns)
# print('sigma8 from emulator', sigma8)
# # Test linear sigma8
# pk_lin = symbolic_pofk.linear.plin_emulated(k, sigma8, Om, Ob, h, ns,
# emulator='fiducial', extrapolate=True)
# new_sigma8 = compute_sigma8(k, pk_lin)
# print('sigma8 from integral:', new_sigma8)
# Get non-linear sigma8
def nonlinear_sigma8(As, Om0, Ob, h, ns, ks):
a = 1.
sigma8 = linear_sigma8(As, Om0, Ob, h, ns) # Linear sigma8
pk_nl = syrenhalofit.run_halofit(
ks, sigma8, Om, Ob, h, ns, a, emulator='fiducial', extrapolate=True,
which_params='Bartlett', add_correction=True)
return compute_sigma8_from_pk(ks, pk_nl)
# print('non-linear sigma8:', sigma8_nl)
# print('sigma8 non-linear bigger by a factor', sigma8_nl / sigma8)
In [18]:
kmin, kmax, nk = 1e-4, 1e1, 256
ks = np.logspace(np.log10(kmin), np.log10(kmax), nk) # Wavenumber
In [21]:
linear_sigma8(As, Om, Ob, h, ns)
Out[21]:
In [20]:
nonlinear_sigma8(As, Om, Ob, h, ns, ks)
Out[20]:
In [25]:
1e-10 * np.exp(3.0448)
Out[25]:
In [ ]: