Skip to content

Commit

Permalink
Check if Ob0 and Tcmb0 are non-zero for wiggle=T (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
jucordero authored Oct 7, 2020
1 parent 0c36d3d commit e2b39ce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
10 changes: 10 additions & 0 deletions skypy/power_spectrum/_eisenstein_hu.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,18 @@ def transfer_with_wiggles(wavenumber, A_s, n_s, cosmology, kwmap=0.02):

om0 = cosmology.Om0
ob0 = cosmology.Ob0

if not ob0:
raise ValueError("Ob0 for input cosmology must be non-zero if "
"wiggles = True")

h0 = cosmology.H0.value / 100
Tcmb0 = cosmology.Tcmb0.value

if not Tcmb0:
raise ValueError("Tcmb0 for input cosmology must be non-zero if"
"wiggles = True")

ak = wavenumber * h0
om0h2 = om0 * h0**2
ob0h2 = ob0 * h0**2
Expand Down
16 changes: 15 additions & 1 deletion skypy/power_spectrum/tests/test_eisenstein_hu.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import pytest
from astropy.cosmology import default_cosmology
from astropy.cosmology import default_cosmology, FlatLambdaCDM
from skypy.power_spectrum import eisenstein_hu


Expand Down Expand Up @@ -60,3 +60,17 @@ def test_eisenstein_hu():
with pytest.raises(ValueError):
eisenstein_hu(negative_wavenumber_array, A_s, n_s, cosmology, kwmap,
wiggle=False)

# Test for failure when cosmology has Ob0 = 0 and wiggle = True
zero_ob0_cosmology = FlatLambdaCDM(H0=70, Om0=0.3, Tcmb0=2.725)
wavenumber = np.logspace(-3, 1, num=5, base=10.0)
with pytest.raises(ValueError):
eisenstein_hu(wavenumber, A_s, n_s, zero_ob0_cosmology, kwmap,
wiggle=True)

# Test for failure when cosmology has Tcmb = 0 and wiggle = True
zero_Tcmb0_cosmology = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
wavenumber = np.logspace(-3, 1, num=5, base=10.0)
with pytest.raises(ValueError):
eisenstein_hu(wavenumber, A_s, n_s, zero_Tcmb0_cosmology, kwmap,
wiggle=True)

0 comments on commit e2b39ce

Please sign in to comment.