Skip to content

Commit

Permalink
BCM 3param fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
sambit-giri committed Dec 30, 2024
1 parent cda1cd4 commit b56d192
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/BCemu/BaryonEffectsEmulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,12 @@ def get_boost(self, z, BCM_params, k_eval, fb=None):

class BCM_3param(use_emul):
def __init__(self, emul_names=None, Ob=0.0463, Om=0.2793, verbose=True,
below_kmin='extrapolate', above_kmax='extrapolate'):
super().__init__(emul_names=emul_names, Ob=Ob, Om=Om, verbose=verbose,
below_kmin=below_kmin, above_kmax=above_kmax)
below_kmin='extrapolate', above_kmax='extrapolate',
above_zmax='extrapolate'):
super().__init__(emul_names=emul_names, Ob=Ob, Om=Om, verbose=verbose)
self.below_kmin = below_kmin
self.above_kmax = above_kmax
self.above_zmax = above_zmax

def print_param_names(self):
print('\nBaryonification parameters:')
Expand All @@ -294,5 +297,20 @@ def get_boost(self, z, BCM_params, k_eval, fb=None):
pp, kk = self.run(BCM_params, z=z)
pp_tck = splrep(kk, pp, k=3)
return splev(k_eval, pp_tck, ext=0)

def get_boost_BCM_7param(z, BCM_params, k_eval, verbose=True, Ob=0.0463, Om=0.2793):
bfcemu = BCM_7param(Ob=Ob, Om=Om, verbose=verbose)
return bfcemu.get_boost(z, BCM_params, k_eval)

def get_boost_BCM_3param(z, BCM_params, k_eval, verbose=True, Ob=0.0463, Om=0.2793):
if 'delta' in BCM_params.keys() or 'eta' in BCM_params.keys() or 'mu' in BCM_params.keys() or 'gamma' in BCM_params.keys():
print('3 parameter BCM model')
print('delta, mu, gamma, eta = 7.0, 1.0, 2.5, 0.2')
BCM_params['delta'] = 7.0
BCM_params['mu'] = 1.0
BCM_params['gamma'] = 2.5
BCM_params['eta'] = 0.2
bfcemu = BCM_7param(Ob=Ob, Om=Om, verbose=verbose)
return bfcemu.get_boost(z, BCM_params, k_eval)


11 changes: 11 additions & 0 deletions tests/test_Sk.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@ def test_BCM_7param():
p1p5 = bfcemu.get_boost(1.5, bcmdict, k_eval)
p2 = bfcemu.get_boost(2.0, bcmdict, k_eval)
assert np.abs(p0[0]-0.999129)<0.00001 and np.abs(p0p5[0]-0.998741)<0.00001 and np.abs(p1[0]-0.998928)<0.00001 and np.abs(p1p5[0]-0.999030)<0.00001 and np.abs(p2[0]-0.999575)<0.00001

def test_BCM_3param():
'''
With this test, the 3 parameter baryonic power suppression is tested.
'''
p0 = BCemu.get_boost_BCM_3param(0.0, bcmdict, k_eval, verbose=True)
p0p5 = BCemu.get_boost_BCM_3param(0.5, bcmdict, k_eval, verbose=True)
p1 = BCemu.get_boost_BCM_3param(1.0, bcmdict, k_eval, verbose=True)
p1p5 = BCemu.get_boost_BCM_3param(1.5, bcmdict, k_eval, verbose=True)
p2 = BCemu.get_boost_BCM_3param(2.0, bcmdict, k_eval, verbose=True)
assert np.abs(p0[0]-0.999203)<0.00001 and np.abs(p0p5[0]-0.999118)<0.00001 and np.abs(p1[0]-0.999041)<0.00001 and np.abs(p1p5[0]-0.999229)<0.00001 and np.abs(p2[0]-0.999595)<0.00001

0 comments on commit b56d192

Please sign in to comment.