From c23157f0a23575b7c0578c16814896c2bd1132b9 Mon Sep 17 00:00:00 2001 From: Ian Harrison Date: Wed, 3 Aug 2022 14:28:47 +0100 Subject: [PATCH 1/2] camb and class tested against truth spectra for massive, massless nu --- skypy/power_spectrum/_camb.py | 17 ++++-- skypy/power_spectrum/_classy.py | 19 ++++++- skypy/power_spectrum/tests/test_camb.py | 66 ++++++++++++++++++---- skypy/power_spectrum/tests/test_class.py | 71 ++++++++++++++++++++---- 4 files changed, 145 insertions(+), 28 deletions(-) diff --git a/skypy/power_spectrum/_camb.py b/skypy/power_spectrum/_camb.py index abf1b744..d5e80a99 100644 --- a/skypy/power_spectrum/_camb.py +++ b/skypy/power_spectrum/_camb.py @@ -14,7 +14,7 @@ class CAMB(TabulatedPowerSpectrum): redshift and wavenumber using CAMB. ''' - def __init__(self, kmax, redshift, cosmology, A_s, n_s, **kwargs): + def __init__(self, kmax, redshift, cosmology, A_s, n_s, tau, **kwargs): try: from camb import CAMBparams, model, get_results @@ -30,16 +30,25 @@ def __init__(self, kmax, redshift, cosmology, A_s, n_s, **kwargs): omk=cosmology.Ok0, TCMB=cosmology.Tcmb0.value, mnu=np.sum(cosmology.m_nu.to_value(units.eV)), - standard_neutrino_neff=cosmology.Neff + num_massive_neutrinos=1, + standard_neutrino_neff=cosmology.Neff, + tau=tau, + YHe=0.24, ) pars.InitPower.ns = n_s pars.InitPower.As = A_s pars.NonLinear = model.NonLinear_none k_per_logint, var1, var2, hubble_units, nonlinear = None, None, None, False, False - pars.set_matter_power(redshifts=redshift, kmax=kmax, k_per_logint=k_per_logint, silent=True) + pars.set_matter_power(redshifts=redshift, + kmax=kmax, + k_per_logint=k_per_logint, + # accurate_massive_neutrino_transfers=True, + silent=True) + results = get_results(pars) k, z, p = results.get_linear_matter_power_spectrum(var1, var2, hubble_units, + k_hunit=False, nonlinear=nonlinear) - super().__init__(k*cosmology.h, z, p) + super().__init__(k, z, p) diff --git a/skypy/power_spectrum/_classy.py b/skypy/power_spectrum/_classy.py index 756108fe..5daf93a3 100644 --- a/skypy/power_spectrum/_classy.py +++ b/skypy/power_spectrum/_classy.py @@ -1,4 +1,5 @@ import numpy as np +from astropy import units from ._base import TabulatedPowerSpectrum __all__ = [ @@ -11,7 +12,7 @@ class CLASSY(TabulatedPowerSpectrum): two dimensional grid of wavenumber and redshift. """ - def __init__(self, kmax, redshift, cosmology, **kwargs): + def __init__(self, kmax, redshift, cosmology, A_s, n_s, tau, **kwargs): try: from classy import Class except ImportError: @@ -23,13 +24,27 @@ def __init__(self, kmax, redshift, cosmology, **kwargs): 'output': 'mPk', 'P_k_max_1/Mpc': kmax, 'z_pk': ', '.join(str(z) for z in np.atleast_1d(redshift)), + 'A_s': A_s, + 'n_s': n_s, 'H0': cosmology.H0.value, 'omega_b': cosmology.Ob0 * h2, 'omega_cdm': cosmology.Odm0 * h2, 'T_cmb': cosmology.Tcmb0.value, - 'N_eff': cosmology.Neff, + 'N_ncdm': cosmology._nmassivenu, + 'N_ur': cosmology.Neff - cosmology._nmassivenu, + 'tau_reio': tau, + 'YHe': 0.24 } + if cosmology.has_massive_nu: + + params['T_ncdm'] = 0.7133 + + if cosmology._nmassivenu == 1: + params['m_ncdm'] = np.sum(cosmology.m_nu.to_value(units.eV)) + else: + params['m_ncdm'] = ', '.join(cosmology.m_nu.to_value(units.eV).astype(str)) + params.update(kwargs) classy_obj = Class() diff --git a/skypy/power_spectrum/tests/test_camb.py b/skypy/power_spectrum/tests/test_camb.py index 84ffadf7..f7bb5490 100644 --- a/skypy/power_spectrum/tests/test_camb.py +++ b/skypy/power_spectrum/tests/test_camb.py @@ -1,13 +1,10 @@ import numpy as np from astropy.cosmology import Planck15 from astropy.units import allclose +from astropy import units from astropy.utils.data import get_pkg_data_filename import pytest -# load the external camb result to test against -camb_result_filename = get_pkg_data_filename('data/camb_result.txt') -test_pzk = np.loadtxt(camb_result_filename) - # try to import the requirement, if it doesn't exist, skip test try: __import__('camb') @@ -24,14 +21,54 @@ def test_camb(): ''' from skypy.power_spectrum import CAMB + # load the external camb result to test against + truth_pk_filename = get_pkg_data_filename('data/truth_pk_massive_nu.txt') + test_k, test_pzk0, test_pzk1 = np.loadtxt(truth_pk_filename, unpack=True) + test_pzk = np.column_stack([test_pzk0, test_pzk1]).T + # Setup CAMB interpolator - k_max, z_grid = 10, np.array([0, 1]) - A_s, n_s = 2.e-9, 0.965 - ps = CAMB(k_max, z_grid, Planck15, A_s, n_s) + k_max, z_grid = test_k.max(), np.array([0, 1]) + A_s, n_s, tau = 2.e-9, 0.965, 0.079 + ps = CAMB(k_max, z_grid, Planck15, A_s, n_s, tau) # test shape and compare with the mocked power spectrum redshift = [0.0, 1.0] - wavenumber = np.logspace(-4.0, np.log10(2.0), 200) + # wavenumber = np.logspace(-4.0, np.log10(2.0), 200) + wavenumber = test_k + pzk = ps(wavenumber, redshift) + assert pzk.shape == (len(redshift), len(wavenumber)) + assert allclose(pzk, test_pzk, rtol=1.e-4) + + # also check redshifts are ordered correctly + redshift = [1.0, 0.0] + pzk = ps(wavenumber, redshift) + assert pzk.shape == (len(redshift), len(wavenumber)) + assert allclose(pzk, test_pzk[np.argsort(redshift), :], rtol=1.e-4) + +@pytest.mark.skipif(CAMB_NOT_FOUND, reason='CAMB not found') +def test_camb_massless(): + ''' + Test a default astropy cosmology + ''' + from skypy.power_spectrum import CAMB + + # load the external camb result to test against + truth_pk_filename = get_pkg_data_filename('data/truth_pk_massless_nu.txt') + test_k, test_pzk0, test_pzk1 = np.loadtxt(truth_pk_filename, unpack=True) + test_pzk = np.column_stack([test_pzk0, test_pzk1]).T + + Planck15massless = Planck15.clone(name='Planck 15 massless neutrino', + m_nu=[0., 0., 0.]*units.eV) + + # Setup CAMB interpolator + k_max, z_grid = test_k.max(), np.array([0, 1]) + A_s, n_s, tau = 2.e-9, 0.965, 0.079 + ps = CAMB(k_max, z_grid, Planck15massless, A_s, n_s, tau) + + # test shape and compare with the mocked power spectrum + redshift = [0.0, 1.0] + # wavenumber = np.logspace(-4.0, np.log10(2.0), 200) + wavenumber = test_k pzk = ps(wavenumber, redshift) assert pzk.shape == (len(redshift), len(wavenumber)) assert allclose(pzk, test_pzk, rtol=1.e-4) @@ -51,12 +88,17 @@ def test_camb_redshift_zero(): """ from skypy.power_spectrum import CAMB + # load the external camb result to test against + truth_pk_filename = get_pkg_data_filename('data/truth_pk_massive_nu.txt') + test_k, test_pzk0, test_pzk1 = np.loadtxt(truth_pk_filename, unpack=True) + test_pzk = np.column_stack([test_pzk0, test_pzk1]).T + # Setup CAMB interpolator - k_max, z_grid = 10, np.array([0, 1]) - A_s, n_s = 2.e-9, 0.965 - ps = CAMB(k_max, z_grid, Planck15, A_s, n_s) + k_max, z_grid = test_k.max(), np.array([0, 1]) + A_s, n_s, tau = 2.e-9, 0.965, 0.079 + ps = CAMB(k_max, z_grid, Planck15, A_s, n_s, tau) redshift = 0.0 - wavenumber = np.logspace(-4.0, np.log10(2.0), 200) + wavenumber = test_k pzk = ps(wavenumber, redshift) assert allclose(pzk, test_pzk[0], rtol=1.e-4) diff --git a/skypy/power_spectrum/tests/test_class.py b/skypy/power_spectrum/tests/test_class.py index b0824776..9447cf37 100644 --- a/skypy/power_spectrum/tests/test_class.py +++ b/skypy/power_spectrum/tests/test_class.py @@ -5,9 +5,15 @@ from astropy.utils.data import get_pkg_data_filename import pytest +''' +from matplotlib import pyplot as plt +plt.ion() +plt.loglog(test_k, np.abs(test_pzk[0]/pzk[0] - 1)) +''' + # load the external class result to test against -class_result_filename = get_pkg_data_filename('data/class_result.txt') -test_pzk = np.loadtxt(class_result_filename) +# class_result_filename = get_pkg_data_filename('data/class_result.txt') +# test_pzk = np.loadtxt(class_result_filename) # try to import the requirement, if it doesn't exist, skip test try: @@ -18,32 +24,77 @@ @pytest.mark.skipif(CLASS_294_NOT_FOUND, reason='classy v2.9.4 not found') -def test_classy(): +def test_classy_massive(): + ''' + Test a default astropy cosmology + ''' + + truth_pk_filename = get_pkg_data_filename('data/truth_pk_massive_nu.txt') + test_k, test_pzk0, test_pzk1 = np.loadtxt(truth_pk_filename, unpack=True) + test_pzk = np.column_stack([test_pzk0, test_pzk1]).T + + from skypy.power_spectrum import CLASSY + + A_s, n_s, tau = 2.e-9, 0.965, 0.079 + redshift = [0.0, 1.0] + # wavenumber = np.logspace(-4.0, np.log10(2.0), 200) + wavenumber = test_k + k_max = wavenumber.max() + ps = CLASSY(k_max, redshift, Planck15, A_s, n_s, tau) + pzk = ps(wavenumber, redshift) + assert pzk.shape == (len(redshift), len(wavenumber)) + assert allclose(pzk, test_pzk, rtol=2.e-3) + + # also check redshifts are ordered correctly + redshift = [1.0, 0.0] + ps = CLASSY(k_max, redshift, Planck15, A_s, n_s, tau) + pzk = ps(wavenumber, redshift) + assert pzk.shape == (len(redshift), len(wavenumber)) + assert allclose(pzk, test_pzk[np.argsort(redshift)], rtol=2.e-3) + + # also check scalar arguments are treated correctly + redshift = 1.0 + wavenumber = 1.e-1 + ps = CLASSY(k_max, redshift, Planck15, A_s, n_s, tau) + pzk = ps(wavenumber, redshift) + assert np.isscalar(pzk) + + +@pytest.mark.skipif(CLASS_294_NOT_FOUND, reason='classy v2.9.4 not found') +def test_classy_massless(): ''' Test a default astropy cosmology ''' + + truth_pk_filename = get_pkg_data_filename('data/truth_pk_massless_nu.txt') + test_k, test_pzk0, test_pzk1 = np.loadtxt(truth_pk_filename, unpack=True) + test_pzk = np.column_stack([test_pzk0, test_pzk1]).T + from skypy.power_spectrum import CLASSY - Pl15massless = Planck15.clone(name='Planck 15 massless neutrino', m_nu=[0., 0., 0.]*u.eV) + Planck15massless = Planck15.clone(name='Planck 15 massless neutrino', + m_nu=[0., 0., 0.]*u.eV) + A_s, n_s, tau = 2.e-9, 0.965, 0.079 redshift = [0.0, 1.0] - wavenumber = np.logspace(-4.0, np.log10(2.0), 200) + # wavenumber = np.logspace(-4.0, np.log10(2.0), 200) + wavenumber = test_k k_max = wavenumber.max() - ps = CLASSY(k_max, redshift, Pl15massless) + ps = CLASSY(k_max, redshift, Planck15massless, A_s, n_s, tau) pzk = ps(wavenumber, redshift) assert pzk.shape == (len(redshift), len(wavenumber)) - assert allclose(pzk, test_pzk, rtol=1.e-4) + assert allclose(pzk, test_pzk, rtol=2.e-3) # also check redshifts are ordered correctly redshift = [1.0, 0.0] - ps = CLASSY(k_max, redshift, Pl15massless) + ps = CLASSY(k_max, redshift, Planck15massless, A_s, n_s, tau) pzk = ps(wavenumber, redshift) assert pzk.shape == (len(redshift), len(wavenumber)) - assert allclose(pzk, test_pzk[np.argsort(redshift)], rtol=1.e-4) + assert allclose(pzk, test_pzk[np.argsort(redshift)], rtol=2.e-3) # also check scalar arguments are treated correctly redshift = 1.0 wavenumber = 1.e-1 - ps = CLASSY(k_max, redshift, Pl15massless) + ps = CLASSY(k_max, redshift, Planck15massless, A_s, n_s, tau) pzk = ps(wavenumber, redshift) assert np.isscalar(pzk) From 702e8ad3b6f29b55439c148848136d8b12fc305f Mon Sep 17 00:00:00 2001 From: Ian Harrison Date: Wed, 3 Aug 2022 14:41:17 +0100 Subject: [PATCH 2/2] added truth data --- .../tests/data/truth_pk_massive_nu.txt | 205 +++++++++++++++++ .../tests/data/truth_pk_massless_nu.txt | 213 ++++++++++++++++++ 2 files changed, 418 insertions(+) create mode 100644 skypy/power_spectrum/tests/data/truth_pk_massive_nu.txt create mode 100644 skypy/power_spectrum/tests/data/truth_pk_massless_nu.txt diff --git a/skypy/power_spectrum/tests/data/truth_pk_massive_nu.txt b/skypy/power_spectrum/tests/data/truth_pk_massive_nu.txt new file mode 100644 index 00000000..b91ba84b --- /dev/null +++ b/skypy/power_spectrum/tests/data/truth_pk_massive_nu.txt @@ -0,0 +1,205 @@ +# k Pk(z=0.0) Pk(z=1.0) +7.0482068471392265e-06 149.9782038185607 55.53062337198318 +7.782589398811979e-06 165.03150076739075 61.10421725964271 +8.593490540988569e-06 181.5956679953026 67.23723248351115 +9.48888250040909e-06 199.82228271068516 73.98579675384428 +1.0477569843715173e-05 219.8783031442084 81.41170683920956 +1.1569272033739253e-05 241.94727635546596 89.58291483251764 +1.2774723236361752e-05 266.2311772381725 98.57425812030543 +1.410577582391852e-05 292.9523506866617 108.4679934852785 +1.5575515584350796e-05 322.3553568925519 119.35472681349943 +1.7198394797014772e-05 354.7092919758921 131.334074544891 +1.8990367772858008e-05 390.31025367746463 144.5156710438236 +2.0969055966997985e-05 429.4840378953578 159.02016922410473 +2.315390939475037e-05 472.589112138901 174.98024871447853 +2.556641363844392e-05 520.0197914299015 192.542044382416 +2.823028576458455e-05 572.2101229699033 211.8660955031027 +3.1171719528356334e-05 629.6373530404383 233.12922577674502 +3.441963181030587e-05 692.826433769211 256.5258931735537 +3.8005958340363575e-05 762.3552374400161 282.2699890695871 +4.196595927933231e-05 838.859130374458 310.59685815037966 +4.633857408771291e-05 923.0372202118009 341.7653332482196 +5.116678625199711e-05 1015.6578709496798 376.05994673003016 +5.6498069335066246e-05 1117.5662010117835 413.7940128674996 +6.238484041969059e-05 1229.6916755291338 455.31151045677177 +6.888498255430022e-05 1353.0558554840627 500.991018881833 +7.606239677115809e-05 1488.781561797604 551.2483921785711 +8.398766253667419e-05 1638.1030420431962 606.5409557598083 +9.273868834425229e-05 1802.3752702809402 667.3708197836536 +0.00010240152988408226 1983.086003571112 734.2896529865532 +0.00011307117371179629 2181.8694337137877 807.9029428724871 +0.0001248525427101413 2400.5165421954134 888.8750906714337 +0.00013786145226331428 2640.992968751654 977.934644500515 +0.0001522258227254497 2905.450481652384 1075.8802474633146 +0.00016808687217417174 3196.2436912036087 1183.5859642660123 +0.00018560055560083128 3515.9486114868096 1302.00775078039 +0.00020493905338807964 3867.3768064667443 1432.1903151784418 +0.00022629253579652868 4253.595708822454 1575.2726988341906 +0.0002498709077364765 4677.942236208305 1732.4954127339531 +0.00027590601684059947 5144.043049036751 1905.206552912328 +0.0003046538221067749 5655.829874314982 2094.867699089723 +0.0003363969962694682 6217.553390982321 2303.0588961545686 +0.00037144762674579395 6833.798502564272 2531.4830654864336 +0.00041015033059520645 7509.4942763479785 2781.9703353675036 +0.0004528856060584076 8249.919507911272 3056.4777407319734 +0.000500073696684558 9060.709476153714 3357.090482596572 +0.0005521784948883578 9947.837912710927 3686.018341802893 +0.0006097123129642568 10917.61478162621 4045.590587876378 +0.000673240811820142 11976.643066098106 4438.24636588256 +0.0007433886000188068 13131.772166784942 4866.515866985488 +0.0008208454242674633 14390.011079677945 5332.999597697991 +0.0009063727542059496 15758.448438568174 5840.326600674321 +0.0010008115500910208 17244.121229539494 6391.116419801656 +0.0011050903853494674 18853.872746763765 6987.907285491563 +0.0012202344365883618 20594.14101572235 7633.087053010613 +0.001347375735361129 22470.725992979198 8328.808031765098 +0.0014877645239699633 24488.57207650982 9076.910178069369 +0.0016427810055669398 26651.407363843264 9878.781539392709 +0.0018139493811875581 28961.46216708297 10735.259352203337 +0.0020029523599427194 31419.07208746624 11646.477427310774 +0.0022116485081613065 34022.30912366742 12611.728093443458 +0.002442089440813288 36766.420953950736 13629.273543136256 +0.0026965412713587282 39643.3652904102 14696.135423847014 +0.0029775052729994057 42641.08527084177 15807.8668392092 +0.0032877439023926854 45742.9625240558 16958.31934951609 +0.0036303080851212144 48927.22567256212 18139.442573573695 +0.004008565132040531 52166.084733837204 19340.949404247036 +0.004426234383881092 55426.58189047734 20550.652249896415 +0.0048874225404113535 58661.9851658501 21751.217502026997 +0.005396664036624133 61822.125153151974 22924.047059823173 +0.005958964888751507 64851.63127975318 24048.629727518986 +0.006579854741692543 67682.47209669683 25099.770027605482 +0.0072654379701241854 70236.51923917355 26048.46942368269 +0.008022454242780804 72427.80573090223 26862.848127605674 +0.008858347919024527 74163.82644955989 27508.595694011594 +0.009781336814537644 75345.9737797725 27949.109986710046 +0.010800494846329093 75875.23269223826 28147.60819743336 +0.011925844771787524 75658.58451013103 28069.513840898526 +0.013168448404222727 74618.60574907725 27686.03806348136 +0.014540525848791003 72706.44166522472 26978.930202855045 +0.016055564013496042 69917.22488899574 25946.285287851562 +0.017728461711108683 66306.76566796024 24608.702608962878 +0.01957566466704011 62005.56986027615 23014.501490923245 +0.02161533585637808 57224.37407512566 21241.840760863208 +0.023867529626190664 52244.50802864436 19395.080432651604 +0.026354387267678976 47388.19437700915 17593.822891722168 +0.029100364132225512 42966.71792623289 15953.66342322631 +0.032010399536043406 39319.54019191567 14600.657627675695 +0.03492043746337294 36644.22794463 13608.20821909483 +0.03783047286719084 34595.083361792385 12848.061433112283 +0.04074050827100873 32899.97733492528 12219.219626424969 +0.043650543674826625 31350.403467839085 11644.292869762598 +0.04656058160215616 29756.235317487724 11052.68379099353 +0.049470619529485706 27984.782732061783 10395.121473239187 +0.05238065745681524 26022.824982016326 9666.697833651653 +0.05529069033712149 23955.028679392424 8898.872739941884 +0.058200728264451024 21907.98104259511 8138.679004422714 +0.06111076619178057 19993.95828378589 7427.838464557173 +0.06472858352512122 17920.021555388645 6657.572459167699 +0.06834639581143856 16270.648963536829 6044.975003728716 +0.0719642131447792 15063.394304518893 5596.591782584755 +0.07558203047811984 14225.813152745719 5285.522495614499 +0.0791998478114605 13621.791392571356 5061.207635709624 +0.08281766514480114 13104.33932806842 4869.040711316698 +0.08643548247814178 12557.800218926726 4666.050342643998 +0.09005329981148243 11918.998033106514 4428.765502211997 +0.09367111714482307 11180.738875394178 4154.509984261828 +0.09728893447816372 10378.148817394893 3856.338115255057 +0.10090675181150437 9568.130986082231 3555.3947893141635 +0.10452455905079841 8813.925033405883 3275.179584833204 +0.10814237638413907 8169.868337724809 3035.8866553986595 +0.11176019371747971 7662.476850798746 2847.3706355773984 +0.11537801105082035 7282.779577917118 2706.2631927061043 +0.11899582838416099 6996.550124060601 2599.924391358032 +0.12261364571750163 6765.220405050068 2513.9830117726524 +0.1262314630508423 6551.9217315517835 2434.740002601823 +0.12984928038418292 6324.422814107089 2350.2171841586246 +0.13346709771752358 6062.566550620322 2252.92469658749 +0.13708491505086423 5765.623830015323 2142.5913173797358 +0.14070273238420486 5449.097393012461 2024.9779283180785 +0.14432054971754552 5134.278961223666 1907.9967431506523 +0.14793836705088614 4840.618234340612 1798.8767396693106 +0.1515561843842268 4582.456403755194 1702.947273157076 +0.15517399162352086 4366.658043702829 1622.7598113061968 +0.15879180895686149 4191.532186294422 1557.685947024672 +0.16240962629020214 4048.6203675509123 1504.5827240399171 +0.1660274436235428 3925.836536334679 1458.9587631055415 +0.16964527105093002 3810.1898004090453 1415.9864884865176 +0.17326307829022408 3690.7291454839838 1371.596724148891 +0.17688088552951814 3561.6757110148724 1323.64079060979 +0.18049871295690537 3423.3851894254094 1272.2520153846287 +0.18411652019619942 3280.27088696846 1219.069728627318 +0.18773434762358665 3138.0823382629637 1166.2307928221016 +0.1913521548628807 3002.5865764912905 1115.8789761521243 +0.19496998229026793 2878.8416807463827 1069.8935237485557 +0.198587789529562 2769.854951930178 1029.3926718630205 +0.20220561695694925 2675.48676609979 994.3241945570101 +0.20582342419624328 2592.8816530440595 963.6271739706725 +0.20944125162363053 2518.051030112089 935.8188799275517 +0.2130590588629246 2447.18211507584 909.4829836664524 +0.21667688629031182 2377.1495060178363 883.4576825719388 +0.22029469352960587 2305.805977717265 856.9451205032506 +0.2239125209569931 2232.4186273705022 829.672776337221 +0.22753032819628716 2157.8613406081 801.9653506951364 +0.23114813543558121 2084.0985818523336 774.5529573139769 +0.23476596286296844 2013.226268778286 748.2147761343824 +0.2383837701022625 1946.7407738828338 723.5068212354363 +0.24200159752964973 1885.3731904020342 700.7006389404235 +0.24561940476894378 1829.2238205847816 679.8339069679893 +0.24923723219633104 1777.8323788845673 660.7352953932522 +0.2528550394356251 1730.1889210080935 643.0294215835256 +0.2564728668630123 1684.9556194018144 626.2192444939066 +0.26009067410230635 1640.8977655289889 609.8459396493728 +0.2637085015296936 1597.2430420154158 593.6223647475445 +0.26732630876898766 1553.7455782755715 577.4571161480633 +0.2709441361963749 1510.5581452270517 561.4069123279016 +0.2745619434356689 1468.0743231817116 545.6182801448874 +0.278179750674963 1426.8001848561346 530.2793392244803 +0.28179757810235023 1387.2398685505307 515.5770301368224 +0.2854153853416443 1349.7712542523466 501.65207666178867 +0.28903321276903154 1314.5280110007266 488.55416641376513 +0.2926510200083256 1281.353596598872 476.2252493484144 +0.2962688474357128 1249.8975068686782 464.53475972955636 +0.29988665467500686 1219.7836866677223 453.34320376447164 +0.3035044821023941 1190.6966657885887 442.5332141069222 +0.30712228934168817 1162.3579143100337 432.0012286661072 +0.31074011676907537 1134.5396521750108 421.6627317963864 +0.3143579240083694 1107.1617077360877 411.4878016629928 +0.3179757514357567 1080.333528476409 401.5172389831272 +0.32159355867505074 1054.2462367258313 391.82194613963384 +0.3252113659143448 1029.0376281991382 382.4532197124814 +0.32882919334173205 1004.7705313882904 373.43437221087436 +0.33244700058102605 981.4784714968619 364.77792677788165 +0.3360648280084133 959.1732916947087 356.488204721005 +0.33968263524770737 937.8020955695852 348.5455617662638 +0.3433004626750946 917.2358686401103 340.9021224696106 +0.3469182901024818 897.3220536669313 333.5011192490445 +0.35053607715368273 877.9458234061964 326.29995727311086 +0.35415390458106993 859.0500835448564 319.2772932917605 +0.3577717320084572 840.6093420111857 312.4238186138705 +0.36138955943584444 822.60785303007 305.73347052475793 +0.3650073464870453 805.0472743397642 299.20699967047665 +0.3686251739144325 787.9623328336924 292.8573223574465 +0.37224300134181976 771.4029400803246 286.7029864508672 +0.3758607883930206 755.3938355011499 280.7530478518495 +0.37947861582040787 739.9154286692914 275.00049778286444 +0.3830964432477951 724.9289121223084 269.43066207492177 +0.3867142706751823 710.4034513370322 264.03221144553834 +0.3903320577263832 696.3155620164538 258.7963278272303 +0.39394988515377044 682.6288357952247 253.70954836120737 +0.3975677125811577 669.2943274235248 248.75378633705992 +0.40118554000854495 656.27560292526 243.91522866552188 +0.4048033270597458 643.5656825982207 239.19150776453893 +0.408421154487133 631.1767440564981 234.58707437574955 +0.41203898191452026 619.1125583704182 230.10333366308785 +0.4156568093419075 607.3628481007793 225.73646300758688 +0.4192745963931084 595.920468435362 221.48380976518138 +0.42289242382049563 584.7910029597055 217.34746480982756 +0.4405129549384117 534.7602248434607 198.75303270494902 +0.5498958795547485 326.2469385129012 121.2564277062891 +0.6874961461544037 196.0236868654745 72.8566909895803 +0.859528093957901 116.52844405905755 43.31063070389224 +1.0746075166225433 68.60765300066335 25.49977142641089 +1.3435062154054642 40.04435525124467 14.883523399249542 +1.6796913442611694 23.189176018531434 8.618869756917878 +2.099999853658676 13.332915488509105 4.955533391580871 diff --git a/skypy/power_spectrum/tests/data/truth_pk_massless_nu.txt b/skypy/power_spectrum/tests/data/truth_pk_massless_nu.txt new file mode 100644 index 00000000..68918972 --- /dev/null +++ b/skypy/power_spectrum/tests/data/truth_pk_massless_nu.txt @@ -0,0 +1,213 @@ +# k Pk(z=0.0) Pk(z=1.0) +7.0375342904299036e-06 150.7860792447684 55.908331004419225 +7.770897210320982e-06 165.9223386502137 61.520541406299266 +8.580681378225563e-06 182.57796866804154 67.69609900826543 +9.474851011691498e-06 200.90550958485366 74.49158053818628 +1.046219958770962e-05 221.07272984244975 81.9691695310858 +1.1552437943828409e-05 243.26432420001402 90.19737783038983 +1.2756286075818934e-05 267.68347484210335 99.25150590982705 +1.4085585266366251e-05 294.5537749793519 109.21448397271246 +1.5553406517210534e-05 324.12116055253813 120.17751056517888 +1.717418485714006e-05 356.6563948218556 132.24091843231042 +1.896386104308476e-05 392.4571986757159 145.5151742429073 +2.094003311867709e-05 431.8511834637911 160.1217888566964 +2.3122138777398505e-05 475.1992103125231 176.19445064072414 +2.553163402917562e-05 522.8976493145716 193.88021543040537 +2.819221868994646e-05 575.3831715809786 213.34096468629087 +3.1130054478126114e-05 633.1357457859682 234.75473146756926 +3.437403363059275e-05 696.683542442214 258.3173087861594 +3.795605984050781e-05 766.6076374435362 284.2443099150329 +4.1911358767538334e-05 843.5470222967429 312.7726436414306 +4.6278827977948823e-05 928.2050057069463 344.1630590551159 +5.110142138582887e-05 1021.3543537778792 378.7023791488949 +5.642656326672295e-05 1123.8453591657758 416.7056933560653 +6.230662634479814e-05 1236.6124303243603 458.51994644911593 +6.879943452368025e-05 1360.6833283808176 504.526134634462 +7.596883954829536e-05 1497.1865994121783 555.1432865693972 +8.388534202531446e-05 1647.3635399335058 610.8317307554835 +9.262681594700552e-05 1812.5770370711477 672.0974099261931 +0.00010227920857141726 1994.3223899755833 739.495536458716 +0.0001129374473093776 2194.242749351407 813.635760464197 +0.00012470635646895972 2414.1383057078506 895.1874414166247 +0.00013770167257462162 2655.9831518831447 984.8834211009745 +0.00015205119769088924 2921.941366077976 1083.5280054102413 +0.000167896051320713 3214.3765833378543 1191.9998629859365 +0.00018539205045090058 3535.8762585104064 1311.2617042134311 +0.0002047112473170273 3889.2622082797866 1442.3638180139494 +0.0002260436544602271 4277.612331867542 1586.4513327287284 +0.00024959905850118955 4704.276018253877 1744.7712143572433 +0.00027560910992324353 5172.887401253169 1918.6781056758532 +0.00030432961000478827 5687.389871685563 2109.63971642845 +0.0003360429949010722 6252.041195888177 2319.2425985314185 +0.0003710611351649277 6871.434592699447 2549.1961203733595 +0.00040972839156165717 7550.508205649324 2801.3358335724633 +0.0004524251046124846 8294.55252390321 3077.6271344370066 +0.0004995711235678755 9109.215486396582 3380.1612018801034 +0.0005516300648334436 10000.500097348562 3711.159966791699 +0.0006091139646945521 10974.74233827201 4072.96581279178 +0.0006725880897603929 12038.607916969626 4468.040407390239 +0.0007426767331548035 13199.014751030574 4898.94367184601 +0.0008200690501369536 14463.092374110129 5368.317614584617 +0.0009055262737674639 15838.078271962526 5878.856072700388 +0.0009998887334251776 17331.211320596587 6433.254896296242 +0.0011040844505187124 18949.619883105213 7034.156113370836 +0.0012191381284967066 20700.09473804593 7684.0806001012 +0.0013461813257541508 22588.89412084014 8385.347975253459 +0.0014864631805568934 24621.471203527435 9139.987253781233 +0.0016413635806180537 26802.176744177457 9949.620574573997 +0.0018124056229367853 29133.928850539687 10815.321999803155 +0.0020012717011850326 31617.77254731137 11737.479901229159 +0.0022098188044968993 34252.452010747336 12715.634234792891 +0.0024400980746839196 37033.91615951298 13748.274885414652 +0.0026943742057308553 39954.64096281249 14832.617212547293 +0.0029751476822420953 43003.027356333274 15964.34204504574 +0.0032851800145581363 46162.69465132428 17137.381125748434 +0.0036275196047499776 49411.91622921241 18343.666016562172 +0.004005533763673156 52722.85896008779 19572.857702053334 +0.00442293962398544 56060.6863744701 20812.02419237927 +0.004883842308260501 59382.80665743035 22045.361763170742 +0.0053927746742963795 62638.31283802119 23253.96751569266 +0.005954741161130369 65767.19290685518 24415.563015363452 +0.006575268890149892 68700.05256698724 25504.384714081956 +0.007260459712520242 71357.75571589054 26491.052419520125 +0.00801705329697579 73651.84826077851 27342.73184475295 +0.00885248895585537 75486.09140727633 28023.689306979766 +0.009774982612207533 76758.49860167028 28496.07155108197 +0.010793608183041216 77366.21236594797 28721.69524923768 +0.011918380224332214 77212.00281449826 28664.4505676555 +0.013160363072901964 76214.46357166876 28294.132100593375 +0.014531769263371826 74321.24397984942 27591.289919895753 +0.016046085703745484 71525.09151796362 26553.23438544404 +0.01771820615977049 67881.12942101194 25200.44068419412 +0.019564572571590545 63521.24306164413 23581.863925065376 +0.021603344129025936 58660.097751933106 21777.192772010436 +0.02385457139387727 53585.67356594009 19893.34487828972 +0.02634039187207818 48628.79736767289 18053.140769420013 +0.029085253344476224 44109.928331634925 16375.536091702237 +0.031993779688328505 40379.02131890108 14990.460027135676 +0.03490230603218079 37641.22367679311 13974.072430514238 +0.03781082985252142 35545.521419581964 13196.057651947542 +0.0407193561963737 33841.05871090193 12563.283362075359 +0.04362788254022598 32256.79668007432 11975.138241407156 +0.046536406360566614 30602.903494585385 11361.138952119156 +0.049444935227930545 28774.875824996598 10682.494880049499 +0.05235345904827118 26769.19265949297 9937.899141690565 +0.055261982868611816 24661.154246597176 9155.301052123037 +0.05817051173597574 22564.515758062134 8376.936831551551 +0.06107903555631638 20591.02152904515 7644.291162602076 +0.06469076617956161 18449.438486182098 6849.2409962991005 +0.06830249680280685 16753.594648449533 6219.669013881186 +0.0719142274260521 15518.064532576926 5760.985791370907 +0.07552595804929733 14656.586676217728 5441.167658848773 +0.07913768867254257 14028.858758342727 5208.128164610014 +0.08274941424876452 13493.784384087754 5009.485130261418 +0.08636114991903306 12937.002741777389 4802.782396079318 +0.0899728805422783 12287.156021654979 4561.531221935028 +0.09358461116552352 11530.204088632745 4280.51782418798 +0.09719634178876876 10703.737031569883 3973.6964631990186 +0.100808072412014 9870.576933179529 3664.3909821226566 +0.10441980303525925 9095.394172230364 3376.6089826562306 +0.10803152356445789 8430.850885447064 3129.9013490889934 +0.11164325418770313 7904.108290258074 2934.352034854752 +0.11525498481094837 7508.719625362977 2787.5657156008024 +0.11886671543419361 7212.582366194295 2677.6261209050917 +0.12247844605743885 6974.605890749433 2589.2791925167844 +0.1260901766806841 6755.408074131543 2507.9037988415084 +0.12970190730392933 6521.991067401333 2421.2492432478425 +0.13331363792717457 6254.256502288058 2321.854537732101 +0.1369253685504198 5950.794765852892 2209.195800830339 +0.14053709917366505 5626.200650504908 2088.6920782363286 +0.1441488297969103 5301.919863536988 1968.3053330796067 +0.14776056042015553 4998.506813310324 1855.6647422834162 +0.15137229104340078 4731.227180966033 1756.439236446495 +0.15498402166664602 4507.319678989424 1673.3148258371953 +0.15859575228989126 4325.304015912573 1605.7424455233377 +0.16220748291313647 4176.927079310311 1550.6585137496163 +0.1658192135363817 4049.995391954457 1503.5357738086327 +0.16943093406558038 3931.0289804604117 1459.3704574828907 +0.17304266468882562 3808.5800981502684 1413.9119620389185 +0.17665439531207086 3676.5565152769723 1364.8992209491616 +0.18026612593531607 3535.027818218677 1312.3572673757892 +0.18387785655856131 3388.103616523468 1257.8125745871855 +0.18748958718180656 3241.5305732092193 1203.3983956023383 +0.1911013178050518 3101.4856850182628 1151.4074084950335 +0.19471304842829704 2973.43364018037 1103.869167648493 +0.19832477905154228 2860.459991577635 1061.9280211352173 +0.20193650967478752 2762.3784130556887 1025.5161092924818 +0.20554824029803276 2676.515355588788 993.640047864484 +0.209159970921278 2599.122828221299 964.9084279627872 +0.21277170154452324 2526.2672330934543 937.8610773939643 +0.21638343216776848 2454.376170444732 911.1720229465734 +0.21999516279101372 2381.032636720425 883.9437425877438 +0.22360689341425896 2305.601214269601 855.9402898486742 +0.2272186240375042 2229.062731000821 827.5258841590836 +0.23083035466074944 2153.2193942288245 799.3695878207957 +0.23444208528399468 2079.9953088223115 772.1855237118194 +0.23805381590723992 2011.0452323130978 746.5883075907565 +0.24166554653048516 1947.428849222661 722.971021684468 +0.2452772771537304 1889.3442137301067 701.4075129167828 +0.24888900777697565 1836.1645954750245 681.6648239565716 +0.25250073840022086 1786.7890068841696 663.3345219554265 +0.2561124690234661 1740.0034062301627 645.9654641405891 +0.25972419964671134 1694.6627100805947 629.1331591998118 +0.2633359302699566 1649.848747886499 612.496181905005 +0.2669476608932018 1605.106373590572 595.8858630803389 +0.2705593915164471 1560.568803823179 579.3514900456054 +0.2741711221396923 1516.75329440071 563.0853633721011 +0.27778285276293757 1474.2102252494394 547.2915432322668 +0.2813945833861828 1433.3638200812109 532.1275492166463 +0.28500631400942805 1394.5599652463268 517.7218475355493 +0.28861804463267327 1358.0252621121547 504.1585518274482 +0.2922297752559185 1323.6969317573003 491.4143511777895 +0.29584150587916375 1291.2040317345989 479.35155510237814 +0.29945323650240896 1260.1008504360652 467.8046719157612 +0.3030649671256542 1230.0587672182146 456.6517781288105 +0.30667669774889944 1200.8306617089856 445.8009721744241 +0.3102884283721447 1172.1785276149865 435.16406524750727 +0.3139001589953899 1143.9729733861523 424.6928488229667 +0.3175118896186352 1116.2989692873844 414.41918609295743 +0.3211236202418804 1089.3666722489454 404.4206769929914 +0.32473535086512567 1063.3281880582306 394.7540789282838 +0.3283470814883709 1038.2417654335968 385.4409499323602 +0.33195881211161615 1014.1492825611608 376.49666843905834 +0.33557054273486137 991.0852369316312 367.93429745228804 +0.33918225317001344 968.9990972718876 359.73493906071985 +0.34279398379325865 947.7428192530908 351.8437339617892 +0.3464057144165039 927.1615632542097 344.20303537892374 +0.35001744503974913 907.1609464583044 336.77797077263284 +0.3536291756629944 887.682476720447 329.5467063663626 +0.3572409062862396 868.664069418728 322.48622556223614 +0.3608526369094849 850.0689183286751 315.5827955248771 +0.3644643675327301 831.9232405189864 308.84639307096717 +0.36807609815597536 814.2900563071566 302.30014695811326 +0.3716878287792206 797.2024146072727 295.956533816002 +0.37529955940246584 780.6514077662758 289.8120212400389 +0.37891129002571106 764.627141477431 283.8631318542644 +0.3825230206489563 749.1322941799874 278.11079172761 +0.38613475127220154 734.1451472682826 272.54689515879227 +0.3897464818954468 719.604567163515 267.14878083944427 +0.393358212518692 705.4508720823284 261.89432261396803 +0.39696994314193723 691.6613799273638 256.77507983966393 +0.4005816737651825 678.2280737638426 251.78806364961463 +0.4041934043884277 665.1271434942314 246.92439631409678 +0.407805135011673 652.33329852871 242.1747717077962 +0.4114168656349182 639.8509765281922 237.5407698657655 +0.41502859625816346 627.7041994913636 233.03130641964665 +0.4186403268814087 615.8975713473699 228.6481477655828 +0.42225205750465394 604.4098196468033 224.3834234690691 +0.4398458999633789 552.7024453946619 205.18739564373024 +0.5434387179493904 345.145098300457 128.13298691137072 +0.6714450777769089 213.22483395467825 79.15841672064457 +0.8296031219244003 130.45580832627303 48.43092148461854 +1.025015223455429 79.11863340974874 29.372307136830702 +1.2664563389539718 47.60259399908546 17.67217126714334 +1.56476860499382 28.43391272103017 10.555914421354018 +1.9333479519367218 16.872151724343805 6.263682388983789 +2.3887457898616793 9.951221088951261 3.6943293828650092 +2.9514120111465454 5.836841305361967 2.166890809729863 +3.6466137102127076 3.4062130402990674 1.264535041545723 +4.505568946838379 1.9784764791395966 0.7344967626672467 +5.566850222396851 1.1442330593431957 0.4247891254079373 +6.878115649223328 0.6591174804045711 0.24469288444362824 +8.498247273445129 0.3782694799026743 0.1404298833385537 +10.499999752807618 0.2163429539127157 0.08031570083251575