Repository: skypyproject/skypy
Pull request #241 (2020-07-21 15:51:30)

Evaluate halofit integrals using trapezoidal rule
## Description
Previously halofit evaluated a series of integrals at each redshift using [`scipy.integrate.quad`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.quad.html) and interpolating the power spectrum. This was slow and in some cases lead to convergence issues. This pull request switches to [`np.trapz`](https://numpy.org/doc/stable/reference/generated/numpy.trapz.html) using the raw power spectrum data. It is significantly faster as it doesn't require iterative interpolation and the calculation is vectorised over redshifts.

## Checklist
- [x] Follow the [Contributor Guidelines](https://github.com/skypyproject/skypy/blob/master/CONTRIBUTING.md)
- [ ] Write unit tests
- [ ] Write documentation strings
- [x] Assign someone from your working team to review this pull request
- [x] Assign someone from the infrastructure team to review this pull request


skypybot: Hello @rrjbca! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:

* In the file [`skypy/power_spectrum/_halofit.py`](https://github.com/skypyproject/skypy/blob/6a039dff6acc9cb43aa0850e944d12512a9fe98e/skypy/power_spectrum/_halofit.py):

> [Line 102:80](https://github.com/skypyproject/skypy/blob/6a039dff6acc9cb43aa0850e944d12512a9fe98e/skypy/power_spectrum/_halofit.py#L102): [E501](https://duckduckgo.com/?q=pep8%20E501) line too long (86 > 79 characters)





Patch:
diff --git a/skypy/power_spectrum/_halofit.py b/skypy/power_spectrum/_halofit.py
index e07a43f..a9942d1 100644
--- a/skypy/power_spectrum/_halofit.py
+++ b/skypy/power_spectrum/_halofit.py
@@ -2,8 +2,6 @@ from astropy.utils import isiterable
 from collections import namedtuple
 from functools import partial
 import numpy as np
-from scipy import interpolate
-from scipy import integrate
 from scipy import optimize
 
 
@@ -100,13 +98,14 @@ def halofit(wavenumber, redshift, linear_power_spectrum,
     Examples
     --------
     >>> import numpy as np
-    >>> from astropy.cosmology import FlatLambdaCDM
-    >>> kvec = np.array([1.00000000e-04, 1.01000000e+01])
-    >>> zvalue = 0.0
-    >>> pvec = np.array([388.6725682632502, 0.21676249605280398])
-    >>> cosmo = FlatLambdaCDM(H0=67.04, Om0=0.21479, Ob0=0.04895)
-    >>> halofit(kvec, zvalue, pvec, cosmo, _takahashi_parameters)
-    array([388.67064424,   0.72797614])
+    >>> from astropy.cosmology import default_cosmology
+    >>> from skypy.power_spectrum import growth_function, eisenstein_hu, halofit_smith
+    >>> k = np.logspace(-4, 2, 100, base=10)
+    >>> z, A_s, n_s = 0, 2.2e-09, 0.97
+    >>> cosmology = default_cosmology.get()
+    >>> dz = growth_function(z, cosmology)
+    >>> linear_power = eisenstein_hu(k, A_s, n_s, cosmology) * np.square(dz)
+    >>> nonlinear_power = halofit_smith(k, z, linear_power, cosmology)
     '''
 
     # Manage shapes of input arrays
@@ -139,42 +138,32 @@ def halofit(wavenumber, redshift, linear_power_spectrum,
     ode_1pw_z = omega_de_z * wp1_z
 
     # Linear power spectrum interpolated at each redshift
+    lnk = np.log(wavenumber)
     k2 = np.square(wavenumber)
     k3 = np.power(wavenumber, 3)
     dl2kz = (linear_power_spectrum.T * k3) / (2 * np.pi * np.pi)
-    dl2k = [interpolate.interp1d(np.log(wavenumber), np.log(d)) for d in dl2kz]
-    lnk_lo = np.log(wavenumber[0])
-    lnk_up = np.log(wavenumber[-1])
 
     # Integrals required to evaluate Smith et al. 2003 equations C5, C7 & C8
-    def integrand_kn(lnk, lnR, lnd, n):
-        R2 = np.exp(2*lnR)
-        k2 = np.exp(2*lnk)
-        dl2 = np.exp(lnd(lnk))
-        return dl2 * np.power(k2, n/2) * np.exp(-k2*R2)
-
-    def integral_kn(lnR, lnd, n, lnk_lo, lnk_up):
-        integrand = partial(integrand_kn, lnR=lnR, lnd=lnd, n=n)
-        return integrate.quad(integrand, lnk_lo, lnk_up)[0]
+    def integral_kn(lnR, n):
+        R2 = np.exp(2*lnR)[:, np.newaxis]
+        integrand = dl2kz * np.power(k2, n/2) * np.exp(-k2*R2)
+        return np.trapz(integrand, lnk, axis=1)
 
     # Find root at which sigma^2(R) == 1.0 for each redshift
     # Smith et al. 2003 equation C5 & C6
     def log_sigma_squared(lnR):
-        ik0 = [integral_kn(r, d, 0, lnk_lo, lnk_up) for r, d in zip(lnR, dl2k)]
+        ik0 = integral_kn(lnR, 0)
         return np.log(ik0)
-    guess = np.zeros(np.size(redshift))
+    guess = np.zeros_like(redshift)
     root = optimize.fsolve(log_sigma_squared, guess)
     R = np.exp(root)[:, np.newaxis]
     ksigma = 1.0 / R
     y = wavenumber / ksigma
 
     # Evaluate integrals at lnR = root for each redshift
-    ik0 = [integral_kn(r, d, 0, lnk_lo, lnk_up) for r, d in zip(root, dl2k)]
-    ik2 = [integral_kn(r, d, 2, lnk_lo, lnk_up) for r, d in zip(root, dl2k)]
-    ik4 = [integral_kn(r, d, 4, lnk_lo, lnk_up) for r, d in zip(root, dl2k)]
-    ik0 = np.asarray(ik0)[:, np.newaxis]
-    ik2 = np.asarray(ik2)[:, np.newaxis]
-    ik4 = np.asarray(ik4)[:, np.newaxis]
+    ik0 = integral_kn(root, 0)[:, np.newaxis]
+    ik2 = integral_kn(root, 2)[:, np.newaxis]
+    ik4 = integral_kn(root, 4)[:, np.newaxis]
 
     # Effective spectral index neff and curvature C
     # Smith et al. 2003 equations C7 & C8


Test patch:
diff --git a/skypy/power_spectrum/tests/data/linear_power.txt b/skypy/power_spectrum/tests/data/linear_power.txt
new file mode 100644
index 0000000..d3a3dda
--- /dev/null
+++ b/skypy/power_spectrum/tests/data/linear_power.txt
@@ -0,0 +1,100 @@
+4.307566660102520473e+02 2.566487270756076100e+02 1.600492036921232284e+02 1.068609742737917543e+02 7.569752992301025074e+01
+4.931290635794836135e+02 2.938107670483471452e+02 1.832238945350652557e+02 1.223341536763868476e+02 8.665832705958763427e+01
+5.645220945652492901e+02 3.363473821964690273e+02 2.097502344853492389e+02 1.400451479557332846e+02 9.920433394880144817e+01
+6.462349969961428542e+02 3.850326703169853886e+02 2.401109601511138862e+02 1.603162686452428431e+02 1.135638676831241298e+02
+7.397514716658428142e+02 4.407506337947823454e+02 2.748573459508031078e+02 1.835155883131517385e+02 1.299976612797983933e+02
+8.467645674632100281e+02 5.045100065079157048e+02 3.146184503479429395e+02 2.100631140493851774e+02 1.488032368180824108e+02
+9.692042938494228110e+02 5.774607055918372680e+02 3.601113753673050724e+02 2.404376374958448253e+02 1.703197578222284960e+02
+1.109267951517405209e+03 6.609119027212760784e+02 4.121525360615732438e+02 2.751842591961697622e+02 1.949333593148076602e+02
+1.269452996079960030e+03 7.563516045935871261e+02 4.716698711340245040e+02 3.149225413325579552e+02 2.230829230030551003e+02
+1.452591979990952950e+03 8.654674716421956191e+02 5.397158257362485756e+02 3.603551760251460792e+02 2.552662176762990782e+02
+1.661888720275040669e+03 9.901683670978836744e+02 6.174807897194829138e+02 4.122769577267299610e+02 2.920462550166060964e+02
+1.900954271762260532e+03 1.132605790168111525e+03 7.063064636205739362e+02 4.715837073676458431e+02 3.340576112304971161e+02
+2.173840498851174743e+03 1.295193878397878279e+03 8.076983323724997490e+02 5.392806007499679026e+02 3.820123266664012931e+02
+2.485067982837536874e+03 1.480626035109163695e+03 9.233360343736912910e+02 6.164890917237838721e+02 4.367048100123470817e+02
+2.839643632832506682e+03 1.691885422145670645e+03 1.055079904888654482e+03 7.044512810572012995e+02 4.990149330896443303e+02
+3.243061664426086281e+03 1.932245542969373219e+03 1.204971339673925058e+03 8.045301592205846646e+02 5.699082028349117763e+02
+3.701279594371046187e+03 2.205255940075554918e+03 1.375223875715696749e+03 9.182036512112415494e+02 6.504315428090467321e+02
+4.220658669616384032e+03 2.514706702070842766e+03 1.568201057420852976e+03 1.047049838345619719e+03 7.417028246998615941e+02
+4.807855912881123913e+03 2.864564143447303650e+03 1.786376325757837776e+03 1.192720177210814427e+03 8.448918973251101079e+02
+5.469653073200213839e+03 3.258868891766866000e+03 2.032269464210761271e+03 1.356897066168450237e+03 9.611905278494376716e+02
+6.212706719389893806e+03 3.701586991082202985e+03 2.308353745098840591e+03 1.541231849202621106e+03 1.091768485325565280e+03
+7.043204131930760923e+03 4.196404879200796131e+03 2.616928074955806551e+03 1.747259450488466200e+03 1.237713070046858093e+03
+7.966412192744414824e+03 4.746460612123860301e+03 2.959949382888062701e+03 1.976286464161232288e+03 1.399949839255538336e+03
+8.986111670954331203e+03 5.354006806373603467e+03 3.338822427394555689e+03 2.229250813424246189e+03 1.579143193311343111e+03
+1.010391732880717973e+04 6.020005551936877055e+03 3.754147179252581282e+03 2.506553084224320628e+03 1.775576896861765590e+03
+1.131849470281023241e+04 6.743661763365764273e+03 4.205427813704868640e+03 2.807862226388079307e+03 1.989016442589466578e+03
+1.262469605332017272e+04 7.521908370708660186e+03 4.690751669391216637e+03 3.131901202281519090e+03 2.218557210307613332e+03
+1.401264880793206976e+04 8.348863205816769550e+03 5.206450556179043815e+03 3.476220850257182519e+03 2.462464277717820096e+03
+1.546683715782898980e+04 9.215281809122470804e+03 5.746759518951603241e+03 3.836972049505911400e+03 2.718011027927357645e+03
+1.696521824105437190e+04 1.010803084361985384e+04 6.303488452292952388e+03 4.208686465140915971e+03 2.981323834979370531e+03
+1.847840567402784654e+04 1.100960163553931125e+04 6.865718738657385984e+03 4.584074000855929626e+03 3.247238584593266296e+03
+1.996893357193833799e+04 1.189767167102497115e+04 7.419529792473534144e+03 4.953840219051125132e+03 3.509171339339017777e+03
+2.139058689781252178e+04 1.274470561203827128e+04 7.947750248908690992e+03 5.306520215601372001e+03 3.759000659851371438e+03
+2.268776614249323393e+04 1.351757676692895075e+04 8.429721908407413139e+03 5.628321011345814441e+03 3.986955959067539425e+03
+2.379489826507436010e+04 1.417721612340544198e+04 8.841080869470737525e+03 5.902975419749129287e+03 4.181513985885901093e+03
+2.463613891687013165e+04 1.467843493087597199e+04 9.153646888890509217e+03 6.111668175411502489e+03 4.329346496527181444e+03
+2.512628121139638097e+04 1.497046615384278084e+04 9.335761038536400520e+03 6.233261379321712411e+03 4.415479954077784896e+03
+2.517521160885320933e+04 1.499961932827630153e+04 9.353941305418487900e+03 6.245399902892967475e+03 4.424078567907582510e+03
+2.470034647761462111e+04 1.471669037770708383e+04 9.177503441276223384e+03 6.127596617240273190e+03 4.340629789704643372e+03
+2.365234461194576579e+04 1.409228136440496201e+04 8.788114541919834664e+03 5.867611086561428237e+03 4.156462813670078503e+03
+2.205369123692036737e+04 1.313978918933174464e+04 8.194129074388030858e+03 5.471021386015196185e+03 3.875529002910140207e+03
+2.003243514681675151e+04 1.193550648507623737e+04 7.443124033246685940e+03 4.969593521773701468e+03 3.520330568536883675e+03
+1.781569366515657020e+04 1.061475181215785960e+04 6.619485684902320827e+03 4.419670158689408709e+03 3.130779186329009008e+03
+1.566440880465207556e+04 9.332996787588223015e+03 5.820167981875827536e+03 3.885985101036702872e+03 2.752730596601364141e+03
+1.378743280726244848e+04 8.214677470690985501e+03 5.122770733183479933e+03 3.420349860548506058e+03 2.422886724321528618e+03
+1.228848024387500482e+04 7.321587943131705288e+03 4.565829464312396340e+03 3.048493673626566306e+03 2.159473490183688682e+03
+1.112325477066422718e+04 6.627336041645168734e+03 4.132885707837310292e+03 2.759427620466566623e+03 1.954706629713728262e+03
+1.002361767305866124e+04 5.972162289002957550e+03 3.724311550524327686e+03 2.486632558033478745e+03 1.761465715135592745e+03
+8.573117377860675333e+03 5.107941062124727978e+03 3.185372897869555345e+03 2.126796281638884011e+03 1.506567072437695515e+03
+6.742857875273539321e+03 4.017455856387148287e+03 2.505333332487551161e+03 1.672750345607630607e+03 1.184932761476930864e+03
+5.232419772215945159e+03 3.117523140158444221e+03 1.944124569638468529e+03 1.298044856385669618e+03 9.195011558280567669e+02
+4.467473668696667119e+03 2.661761316277589231e+03 1.659906066719841419e+03 1.108279050446718884e+03 7.850760032309696044e+02
+3.728585248113538000e+03 2.221524896142763282e+03 1.385369390533277510e+03 9.249775655632391818e+02 6.552300072423062147e+02
+2.751789933317056239e+03 1.639541391446476155e+03 1.022437543763776944e+03 6.826567676704844416e+02 4.835762676604721264e+02
+2.248542864176949934e+03 1.339702224949945048e+03 8.354542675157618987e+02 5.578125659385904100e+02 3.951398879574271064e+02
+1.727670922198509970e+03 1.029361999419959375e+03 6.419224057540799322e+02 4.285960323739692512e+02 3.036062623047691318e+02
+1.339943586669423667e+03 7.983505375715925538e+02 4.978609060775501689e+02 3.324096605855094140e+02 2.354703426566132691e+02
+1.012396154052899192e+03 6.031948075012107893e+02 3.761594678915037662e+02 2.511525599247667628e+02 1.779099296945897493e+02
+7.787483047651917332e+02 4.639853005211925847e+02 2.893467609188279539e+02 1.931898195146944204e+02 1.368506346017953490e+02
+5.860367302088504857e+02 3.491659971759394807e+02 2.177440754962799758e+02 1.453824418560583354e+02 1.029851338851056397e+02
+4.385847963767009787e+02 2.613127981218888181e+02 1.629577739602347890e+02 1.088029561482662899e+02 7.707317928473455027e+01
+3.269127434685278786e+02 1.947775765215795332e+02 1.214656171280236805e+02 8.109964865577636317e+01 5.744887806410242348e+01
+2.423868885696911377e+02 1.444163058169547185e+02 9.005972875662283172e+01 6.013069815879234881e+01 4.259501987605424489e+01
+1.788338783323765142e+02 1.065508461125153019e+02 6.644637698906717560e+01 4.436463548843527605e+01 3.142675186364000695e+01
+1.313709709107551475e+02 7.827201554700847907e+01 4.881136135923902231e+01 3.259016296333562934e+01 2.308602230962368296e+01
+9.607377220583134658e+01 5.724162453562973241e+01 3.569655898691486584e+01 2.383372727615346776e+01 1.688319141692470282e+01
+6.996901040698986662e+01 4.168817077636705193e+01 2.599723993243574327e+01 1.735772702095818332e+01 1.229576156771645579e+01
+5.075620411608954896e+01 3.024100659483251263e+01 1.885865197735943966e+01 1.259146485769225343e+01 8.919465635767227951e+00
+3.668202452203230024e+01 2.185548278877186235e+01 1.362933943412608251e+01 9.099979612773301696e+00 6.446188458583363534e+00
+2.641590711328366581e+01 1.573883695861455578e+01 9.814926226087749228e+00 6.553188361765932335e+00 4.642107892774103739e+00
+1.895848926214262065e+01 1.129563979002863761e+01 7.044095539404557904e+00 4.703171867486696023e+00 3.331604410230888380e+00
+1.356240291332200876e+01 8.080602619641789275e+00 5.039160058819049937e+00 3.364525039704918452e+00 2.383341875746340488e+00
+9.672398201459081690e+00 5.762902543483304107e+00 3.593814680281249174e+00 2.399502960558685061e+00 1.699745378437842680e+00
+6.877990552690430803e+00 4.097969130776124125e+00 2.555542369561032867e+00 1.706273702770608081e+00 1.208679834243294504e+00
+4.877308250036834991e+00 2.905944475616126788e+00 1.812181593867290053e+00 1.209949729298290144e+00 8.570968631095334800e-01
+3.449463096551290242e+00 2.055221387573610503e+00 1.281660541395452046e+00 8.557336805327313556e-01 6.061794432295478652e-01
+2.433504093772473897e+00 1.449903802498835770e+00 9.041772841201642930e-01 6.036972585204244401e-01 4.276434086610874097e-01
+1.712684066745943756e+00 1.020432695062599260e+00 6.363539851809317804e-01 4.248781329162656384e-01 3.009725991984494309e-01
+1.202650160190359863e+00 7.165498693008858222e-01 4.468490348425400716e-01 2.983502705107641262e-01 2.113435581418399156e-01
+8.426899095778834781e-01 5.020822883968446559e-01 3.131044964121753593e-01 2.090522836994074263e-01 1.480871909352470261e-01
+5.892640665071615658e-01 3.510888734032030500e-01 2.189432040190619488e-01 1.461830709080495783e-01 1.035522786452222482e-01
+4.112543256277583215e-01 2.450290558572332245e-01 1.528030382937760889e-01 1.020228852589538660e-01 7.227035372084925080e-02
+2.864914185112704681e-01 1.706941846310342792e-01 1.064469270366772552e-01 7.107203328216479821e-02 5.034557660200295742e-02
+1.992293059008539424e-01 1.187026267734973689e-01 7.402437217490953625e-02 4.942427920999332980e-02 3.501087164745471381e-02
+1.383161501478919753e-01 8.241001630514574461e-02 5.139186792852414726e-02 3.431310465721735398e-02 2.430650931448716939e-02
+9.587514508345165720e-02 5.712328069525785673e-02 3.562275835821427511e-02 2.378445238503851603e-02 1.684828636791148651e-02
+6.635688243758573746e-02 3.953603218274234776e-02 2.465514066676026406e-02 1.646163986904641136e-02 1.166099677676786170e-02
+4.586105557697581214e-02 2.732443271323491477e-02 1.703984175929268777e-02 1.137708935667058885e-02 8.059233671281917921e-03
+3.165262408188262294e-02 1.885892040733864322e-02 1.176064743464902244e-02 7.852299255263430269e-03 5.562364201516683745e-03
+2.181778660666879727e-02 1.299923507179229221e-02 8.106477852251981614e-03 5.412498789353206892e-03 3.834073120235489008e-03
+1.502010555344503000e-02 8.949115068926606284e-03 5.580774768888429639e-03 3.726148054776998782e-03 2.639506197570061670e-03
+1.032811507310447442e-02 6.153584600683980124e-03 3.837448665394871828e-03 2.562171467585624540e-03 1.814975510503212758e-03
+7.093783639760866885e-03 4.226540608546418970e-03 2.635721074786377769e-03 1.759807080998925617e-03 1.246601484573145241e-03
+4.867043401835602703e-03 2.899828585991315062e-03 1.808367652237913813e-03 1.207403252908926129e-03 8.552930055835086158e-04
+3.335824931142205262e-03 1.987514738319446500e-03 1.239437868322936041e-03 8.275426250517417147e-04 5.862096340420900687e-04
+2.284079270565322808e-03 1.360875138067905521e-03 8.486579483716337772e-04 5.666283436351345721e-04 4.013847551834076881e-04
+1.562453159326178658e-03 9.309237583494098028e-04 5.805351459156417359e-04 3.876092467917505234e-04 2.745722913051341484e-04
+1.067843796784676176e-03 6.362310157583220705e-04 3.967612409250406377e-04 2.649078644645270781e-04 1.876538290374015004e-04
+7.291709233128611852e-04 4.344466471572545506e-04 2.709261047834744872e-04 1.808907938652263073e-04 1.281383252816582969e-04
+4.974929598788272334e-04 2.964108160288772185e-04 1.848453160540263168e-04 1.234167375270255073e-04 8.742520125276057475e-05
diff --git a/skypy/power_spectrum/tests/data/truth_bird.txt b/skypy/power_spectrum/tests/data/truth_bird.txt
new file mode 100644
index 0000000..c0199e5
--- /dev/null
+++ b/skypy/power_spectrum/tests/data/truth_bird.txt
@@ -0,0 +1,100 @@
+4.307269013457246842e+02 2.566372050509418727e+02 1.600445443906299090e+02 1.068589186525389323e+02 7.569654554520784018e+01
+4.930899095542520172e+02 2.937956056329187504e+02 1.832177624840515477e+02 1.223314481262159887e+02 8.665703142299147999e+01
+5.644705908182455687e+02 3.363274322722764964e+02 2.097421643284513095e+02 1.400415870596666537e+02 9.920262866952434422e+01
+6.461672506949836361e+02 3.850064202318699813e+02 2.401003396046942271e+02 1.603115821133931718e+02 1.135616233049270392e+02
+7.396623643672360231e+02 4.407160951923852963e+02 2.748433694966484495e+02 1.835094205317375042e+02 1.299947074784229244e+02
+8.466473702082029149e+02 5.044645643480864692e+02 3.146000583896338867e+02 2.100549972085824777e+02 1.487993495300450491e+02
+9.690501620345186211e+02 5.774009212317585025e+02 3.600871743282839361e+02 2.404269562985884079e+02 1.703146423412462696e+02
+1.109065262440231209e+03 6.608332555390960579e+02 4.121206935247508341e+02 2.751702045410015103e+02 1.949266281074130234e+02
+1.269186480915614084e+03 7.562481532642976845e+02 4.716279783439352968e+02 3.149040495775216755e+02 2.230740666185803320e+02
+1.452241587671554498e+03 8.653314105663698683e+02 5.396607175017364852e+02 3.603308494307695469e+02 2.552545666433662177e+02
+1.661428132569519903e+03 9.899894463399404003e+02 6.174083088458933162e+02 4.122449603904642004e+02 2.920309300027826112e+02
+1.900348965943235271e+03 1.132370558246708697e+03 7.062111533280722142e+02 4.715416293390209148e+02 3.340374579648135409e+02
+2.173045225806472899e+03 1.294884696033375121e+03 8.075730355762785848e+02 5.392252809910291944e+02 3.819858311552784471e+02
+2.484023493511534980e+03 1.480219794240075544e+03 9.231713730757762733e+02 6.164163880928063008e+02 4.366699883892551952e+02
+2.838272443883833148e+03 1.691351887938967593e+03 1.054863606160904965e+03 7.043557725019380769e+02 4.989691890066966948e+02
+3.241262604912159077e+03 1.931545217139445867e+03 1.204687366784980668e+03 8.044047618659324144e+02 5.698481436281476817e+02
+3.698920820032097254e+03 2.204337321951985814e+03 1.374851314019202846e+03 9.180391260833532669e+02 6.503527437803829798e+02
+4.217568772419810557e+03 2.513502800514278988e+03 1.567712695095607842e+03 1.046834164280719961e+03 7.415995288474113067e+02
+4.803812695735952730e+03 2.862988069880992498e+03 1.785736860207064865e+03 1.192437758434088892e+03 8.447566358997962652e+02
+5.464369511237957340e+03 3.256808345636588001e+03 2.031433257330329070e+03 1.356527740760672714e+03 9.610136455321628546e+02
+6.205813602138261558e+03 3.698897439208063133e+03 2.307262046995361743e+03 1.540749663260740590e+03 1.091537553103515620e+03
+7.034228892064775209e+03 4.192901237298452543e+03 2.615505639420132411e+03 1.746631164826466829e+03 1.237412169765083718e+03
+7.954753498732950902e+03 4.741907270532071379e+03 2.958100413777570338e+03 1.975469768178839104e+03 1.399558707394340217e+03
+8.971009518700651824e+03 5.348105915979500423e+03 3.336425829496752158e+03 2.228192237462644698e+03 1.578636219252471847e+03
+1.008441863920382275e+04 6.012383616720258942e+03 3.751051148628974715e+03 2.505185631597579686e+03 1.774921984707324555e+03
+1.129341484491272786e+04 6.733854792146437831e+03 4.201443901728283890e+03 2.806102794957200331e+03 1.988173768034433124e+03
+1.259257728963055888e+04 7.509346144892929260e+03 4.685648605260679687e+03 3.129647940231665416e+03 2.217477938413597258e+03
+1.397171741819885392e+04 8.332853648301292196e+03 5.199948331523130037e+03 3.473350700936650355e+03 2.461089357820826990e+03
+1.541496196479661194e+04 9.194997024154421524e+03 5.738524545952745029e+03 3.833338897162211651e+03 2.716270253373651485e+03
+1.689987449346785797e+04 1.008249718161225610e+04 6.293131028155137756e+03 4.204120509989336824e+03 2.979135453639252319e+03
+1.839664989941351814e+04 1.097769718486012607e+04 6.852794610808294237e+03 4.578383279968901661e+03 3.244509876566112325e+03
+1.986739749739583203e+04 1.185813599158647048e+04 7.403548342518211939e+03 4.946815553053824260e+03 3.505800743260301260e+03
+2.126550274199267733e+04 1.269616845782909695e+04 7.928192696512293878e+03 5.297945279809251588e+03 3.754882221113598916e+03
+2.253504322580065127e+04 1.345861519558747386e+04 8.406073899882243495e+03 5.617989622032812804e+03 3.981987058556846478e+03
+2.361028473725260847e+04 1.410645287036274385e+04 8.812884574901814631e+03 5.890718269356811106e+03 4.175607392252891259e+03
+2.441552547880502607e+04 1.459469472687603047e+04 9.120577506390171038e+03 6.097390631855999345e+03 4.322447545207881376e+03
+2.486623482817330296e+04 1.487300817929185723e+04 9.297729594801439816e+03 6.216991570065852102e+03 4.407588637689520510e+03
+2.487384749385593022e+04 1.488845542425277199e+04 9.311216494063448408e+03 6.227340590201335544e+03 4.415273802255197552e+03
+2.435859293537778285e+04 1.459296348951615801e+04 9.130825943432868371e+03 6.108164330571360551e+03 4.331088535249802590e+03
+2.327540438318622546e+04 1.395859700686417273e+04 8.738749174250617216e+03 5.847434943998574454e+03 4.146461355776842538e+03
+2.165197393134290178e+04 1.300027678509019097e+04 8.143783249262372010e+03 5.450875265940903773e+03 3.865413324015332819e+03
+1.962073978624396477e+04 1.179534941385216553e+04 7.393698588420975284e+03 4.950267251363956348e+03 3.510456265449885450e+03
+1.740985921237814546e+04 1.047915037160502106e+04 6.572736103625030410e+03 4.401841015991898530e+03 3.121447252850642144e+03
+1.527635727521488116e+04 9.205964332040335648e+03 5.777456432525072159e+03 3.870174794662428212e+03 2.744159312352199777e+03
+1.342066657546548049e+04 8.098213693630070338e+03 5.085049674463397423e+03 3.407006406911242266e+03 2.415241394620433312e+03
+1.193544634075051363e+04 7.215480057051692711e+03 4.533870682606760056e+03 3.038179881879046661e+03 2.152948451643580938e+03
+1.076823790719756289e+04 6.530223487369859868e+03 4.107751593626251633e+03 2.753039836680869030e+03 1.949631091664078895e+03
+9.663874283269122316e+03 5.885948990063721794e+03 3.707847525826492983e+03 2.485234047650671528e+03 1.758267355012300413e+03
+8.260333090039557646e+03 5.044945988897807183e+03 3.179709040644539982e+03 2.130371433070030889e+03 1.505284372814509652e+03
+6.567593631768332671e+03 3.996285669519063049e+03 2.511587581916398904e+03 1.679719373012314918e+03 1.184971322640226845e+03
+5.196248783916698812e+03 3.138532618495913539e+03 1.962256803655259546e+03 1.308204710525487144e+03 9.207559942835440552e+02
+4.465262712763136733e+03 2.703322226465698350e+03 1.689280713546306515e+03 1.123809432986656475e+03 7.883868321718200605e+02
+3.771825174973546382e+03 2.284516461570183765e+03 1.425586879613462315e+03 9.455095617259846676e+02 6.605016427043894964e+02
+2.940839819393791004e+03 1.742566985655430926e+03 1.072238293025411167e+03 7.048852048445424998e+02 4.895449236646347799e+02
+2.477118534366473341e+03 1.458781625614147742e+03 8.935138705849365124e+02 5.840099203465522351e+02 4.027971073758608895e+02
+2.028957449640702407e+03 1.169413988777075701e+03 7.065885390313513881e+02 4.569945990888368783e+02 3.123285711312957460e+02
+1.690079789383751859e+03 9.522511019116781199e+02 5.674122888755709937e+02 3.628005742294832885e+02 2.452652382576368382e+02
+1.410148845149354429e+03 7.692036685063405912e+02 4.489611812225294898e+02 2.826056365581287650e+02 1.884701795340540968e+02
+1.199399958480103578e+03 6.349400277239973320e+02 3.637364292755124779e+02 2.255030917469377698e+02 1.481485424898141616e+02
+1.025477489343606067e+03 5.232468096408149449e+02 2.923767303288539665e+02 1.777726156525733643e+02 1.147177676775025645e+02
+8.854781345671450481e+02 4.351050906456204075e+02 2.366147856253086275e+02 1.407917593998938344e+02 8.903896084745807116e+01
+7.708918638170872555e+02 3.652323721913830354e+02 1.931091021424126382e+02 1.122804390005792214e+02 6.945575653171330544e+01
+6.749430720288331713e+02 3.090758249523728409e+02 1.588462794702028589e+02 9.015202284365858532e+01 5.446072647654650467e+01
+5.928357729227226400e+02 2.633838347258957242e+02 1.317047622042278476e+02 7.294670747710922853e+01 4.299294637500825900e+01
+5.210829556534134781e+02 2.256570314627952598e+02 1.100269735689040971e+02 5.952052646115501489e+01 3.422172045997492518e+01
+4.572146441464641953e+02 1.939819941788163931e+02 9.250234001102158743e+01 4.895912976027293695e+01 2.748441671661727526e+01
+3.995665866901977097e+02 1.669623193643859906e+02 7.815578644855651191e+01 4.057879347212503518e+01 2.228480538445809245e+01
+3.470623371602093243e+02 1.435775361937998298e+02 6.624888978176419130e+01 3.385500865088642541e+01 1.824176197503834373e+01
+2.990602734437238723e+02 1.230982672953774539e+02 5.623262680172326355e+01 2.839192878973010892e+01 1.506672133534975977e+01
+2.552307844480522760e+02 1.050122907709820765e+02 4.770252659771870185e+01 2.389233961435146014e+01 1.254189181682893484e+01
+2.154544821452882388e+02 8.896734536890564016e+01 4.036484738213990653e+01 2.013609333344681573e+01 1.050475166946161210e+01
+1.797288756738040547e+02 7.472574349853043429e+01 3.400791223610865188e+01 1.696159941662111237e+01 8.834914366482303549e+00
+1.480802602322040968e+02 6.212947771672407526e+01 2.847978148530639686e+01 1.425177420199413625e+01 7.444345116358795700e+00
+1.204892768208950002e+02 5.107206029081356036e+01 2.367044702482261798e+01 1.192262152944657494e+01 6.269572851132196867e+00
+9.684426413622729513e+01 4.147408580838982317e+01 1.949821634567302553e+01 9.914077758655523098e+00 5.265582628650760988e+00
+7.692843971844459361e+01 3.326128359702440918e+01 1.589972877787024963e+01 8.182627753324782205e+00 4.400928027054657576e+00
+6.043374424126144362e+01 2.634720144665046604e+01 1.282292020930636767e+01 6.695508158014927602e+00 3.653793195195512045e+00
+4.698885891392644965e+01 2.062447142473543238e+01 1.022194970536965819e+01 5.426450687485676383e+00 3.008861155689652289e+00
+3.619130953744849677e+01 1.596609704321752687e+01 8.053200643496714051e+00 4.352848395873063936e+00 2.454866823349546756e+00
+2.763692728960397105e+01 1.223350221668543902e+01 6.272260545448747671e+00 3.454122160078960224e+00 1.982791706105456520e+00
+2.094270840202186434e+01 9.286250008171895942e+00 4.832578681816528388e+00 2.710889819763047104e+00 1.584657531211403514e+00
+1.576181945925353745e+01 6.990175125066887318e+00 3.686255867226801541e+00 2.104521166381269293e+00 1.252853042915384130e+00
+1.179144917372067525e+01 5.222981950427214137e+00 2.786253601591068829e+00 1.616873882018566411e+00 9.798754621146523736e-01
+8.775065012182748703e+00 3.877434660403003441e+00 2.088676122513974942e+00 1.230285159011821117e+00 7.583249627345184374e-01
+6.500762336011747244e+00 2.862550559093461455e+00 1.554291387860955664e+00 9.279174278483200977e-01 5.810007025587953233e-01
+4.797203433029175734e+00 2.103281537441191062e+00 1.149219348942160934e+00 6.943053719891815190e-01 4.410184655114193220e-01
+3.528341362750625265e+00 1.539187485111150000e+00 8.450248268484529257e-01 5.158032599984636590e-01 3.319453540496589694e-01
+2.587798156287789197e+00 1.122562906016414619e+00 6.184327778808454967e-01 3.807723487546819108e-01 2.479537214738308237e-01
+1.893467228177847961e+00 8.163806260104576884e-01 4.508121891336519527e-01 2.795448463487534285e-01 1.839516195976669821e-01
+1.382664253624534823e+00 5.922989298620008336e-01 3.275378560290994057e-01 2.042629483474907026e-01 1.356379967262777986e-01
+1.007969648484281722e+00 4.288724108388075051e-01 2.373187605403186684e-01 1.486628057895998112e-01 9.947598587554040694e-02
+7.337855196135111280e-01 3.100271948296682289e-01 1.715583980231222549e-01 1.078392854794387457e-01 7.261564961220443037e-02
+5.335591340181766729e-01 2.238093360641297547e-01 1.237863571894008280e-01 7.801202190343449472e-02 5.279876712406497696e-02
+3.875900097483609974e-01 1.613858595998066692e-01 8.917794899880705783e-02 5.630738044088808708e-02 3.826322277083853141e-02
+2.813263320321804928e-01 1.162643948373295461e-01 6.416302411290354668e-02 4.056606942237907937e-02 2.765365904604897423e-02
+2.040589100085554164e-01 8.369368341424217317e-02 4.611616172058426166e-02 2.918090436874877514e-02 1.994110947691092942e-02
+1.479305405369756576e-01 6.020907527345398247e-02 3.311644657928903418e-02 2.096484709447135608e-02 1.435320562548800596e-02
+1.071910855231500148e-01 4.329154661049863101e-02 2.376422247196396248e-02 1.504663881063740376e-02 1.031566935668742739e-02
+7.764124920212671366e-02 3.111402825430063107e-02 1.704307884652621688e-02 1.079002170753740920e-02 7.404817951845461127e-03
+5.621963589264222100e-02 2.235396226917294241e-02 1.221694350330704976e-02 7.732250577483334129e-03 5.310034910426884858e-03
diff --git a/skypy/power_spectrum/tests/data/truth_smith.txt b/skypy/power_spectrum/tests/data/truth_smith.txt
new file mode 100644
index 0000000..8396b9e
--- /dev/null
+++ b/skypy/power_spectrum/tests/data/truth_smith.txt
@@ -0,0 +1,100 @@
+4.307268924531355196e+02 2.566372070647824444e+02 1.600445454886789491e+02 1.068589188878538749e+02 7.569654554222167064e+01
+4.930898975252965215e+02 2.937956082549575285e+02 1.832177639030060448e+02 1.223314484124126409e+02 8.665703140076294630e+01
+5.644705745323444717e+02 3.363274356739386803e+02 2.097421661538284638e+02 1.400415874001882628e+02 9.920262861245024055e+01
+6.461672286240507219e+02 3.850064246260228629e+02 2.401003419400704502e+02 1.603115825061008195e+02 1.135616231875471698e+02
+7.396623344240108509e+02 4.407161008392331496e+02 2.748433724645088887e+02 1.835094209636677078e+02 1.299947072597673525e+02
+8.466473295364911564e+02 5.044645715590253303e+02 3.146000621299231170e+02 2.100549976472497633e+02 1.487993491448931138e+02
+9.690501067183487294e+02 5.774009303684969154e+02 3.600871789925964208e+02 2.404269566778199874e+02 1.703146416866574100e+02
+1.109065187099530249e+03 6.608332670034329794e+02 4.121206992627674595e+02 2.751702047381854754e+02 1.949266270220325907e+02
+1.269186378142639114e+03 7.562481674709129038e+02 4.716279852766159024e+02 3.149040493774637639e+02 2.230740648509327855e+02
+1.452241447243328366e+03 8.653314278862086439e+02 5.396607256725123989e+02 3.603308484687854047e+02 2.552545638033934665e+02
+1.661427940344499348e+03 9.899894669943378176e+02 6.174083181360579147e+02 4.122449580634386166e+02 2.920309254879463197e+02
+1.900348702312104933e+03 1.132370582120972813e+03 7.062111633148324472e+02 4.715416246672880334e+02 3.340374508476671167e+02
+2.173044863512668144e+03 1.294884722361138529e+03 8.075730453001588103e+02 5.392252724050856614e+02 3.819858200128091994e+02
+2.484022994580630893e+03 1.480219821083515853e+03 9.231713806663123023e+02 6.164163731056534061e+02 4.366699710444571565e+02
+2.838271755294170362e+03 1.691351911350992168e+03 1.054863608243006183e+03 7.043557472081972719e+02 4.989691621382403923e+02
+3.241261652491735731e+03 1.931545229836732233e+03 1.204687357548991486e+03 8.044047201798651940e+02 5.698481021824939035e+02
+3.698919499867241484e+03 2.204337311245250021e+03 1.374851283780088579e+03 9.180390585854337360e+02 6.503526800891851281e+02
+4.217566938798318006e+03 2.513502745125577349e+03 1.567712628083412710e+03 1.046834056480774507e+03 7.415994313072965269e+02
+4.803810144315382786e+03 2.862987935117602774e+03 1.785736731212292170e+03 1.192437588170634854e+03 8.447564870058025690e+02
+5.464365955738852790e+03 3.256808076178578176e+03 2.031433026662544535e+03 1.356527474331028998e+03 9.610134189625468935e+02
+6.205808642458262511e+03 3.698896948499309474e+03 2.307261652987914658e+03 1.540749249702308362e+03 1.091537209422325077e+03
+7.034221971411966479e+03 4.192900392220923095e+03 2.615504987415869891e+03 1.746630527531652660e+03 1.237411650127502071e+03
+7.954743847440484387e+03 4.741905869734218868e+03 2.958099360151757537e+03 1.975468792708408728e+03 1.399557924393697476e+03
+8.970996083303058185e+03 5.348103660024029523e+03 3.336424158818431351e+03 2.228190754010133787e+03 1.578635043721100374e+03
+1.008439999801260819e+04 6.012380068318095255e+03 3.751048541559980549e+03 2.505183390041592247e+03 1.774920226860842604e+03
+1.129338911721163640e+04 6.733849325518218393e+03 4.201439890784090494e+03 2.806099429823723312e+03 1.988171150820222920e+03
+1.259254205705160712e+04 7.509337885350612851e+03 4.685642515255811304e+03 3.129642922206254298e+03 2.217474060291238402e+03
+1.397166969722000249e+04 8.332841407389925735e+03 5.199939201651379335e+03 3.473343270895439218e+03 2.461083641493130017e+03
+1.541489830298934248e+04 9.194979243404755834e+03 5.738511031411903787e+03 3.833327978188506677e+03 2.716261876279684657e+03
+1.689979131369342213e+04 1.008247191063525679e+04 6.293111281599033646e+03 4.204104592793131815e+03 2.979123255485607842e+03
+1.839654428798639492e+04 1.097766213846122446e+04 6.852766148448641616e+03 4.578360278012604795e+03 3.244492239146854445e+03
+1.986726871873374694e+04 1.185808875572474244e+04 7.403507907234705272e+03 4.946782626300369884e+03 3.505775438935838338e+03
+2.126535483812315579e+04 1.269610694168860209e+04 7.928136141482349558e+03 5.297898631614168153e+03 3.754846229744550783e+03
+2.253488905730105034e+04 1.345853844428342018e+04 8.405996130777855797e+03 5.617924284254152553e+03 3.981936360456334569e+03
+2.361015159935536576e+04 1.410636233094699310e+04 8.812779604219087560e+03 5.890627909040604209e+03 4.175536760149389011e+03
+2.441546172541224223e+04 1.459459594429773097e+04 9.120438683067710372e+03 6.097267441977914132e+03 4.322350385863453084e+03
+2.486631541117378219e+04 1.487291260787819738e+04 9.297550061366824593e+03 6.216826347229060957e+03 4.407456977112778986e+03
+2.487417383802523545e+04 1.488838151935294627e+04 9.310989869241813722e+03 6.227123142119775366e+03 4.415098560019019715e+03
+2.435928017612599069e+04 1.459293565766150823e+04 9.130547112630281845e+03 6.107884350493817692e+03 4.330860250959804944e+03
+2.327655061839192058e+04 1.395864108315190788e+04 8.738414923747541252e+03 5.847083336827551648e+03 4.146171405217351094e+03
+2.165361805442990226e+04 1.300041277017523316e+04 8.143392422562437787e+03 5.450445496112046385e+03 3.865055252057541111e+03
+1.962283556616375063e+04 1.179558622742311491e+04 7.393251582426176356e+03 4.949755702844156986e+03 3.510026244985114317e+03
+1.741230059613273625e+04 1.047948904778120777e+04 6.572233696912924643e+03 4.401245211635934538e+03 3.120942499177726404e+03
+1.527905863525586574e+04 9.206410480489948895e+03 5.776897900315601873e+03 3.869489260814816589e+03 2.743574247525914870e+03
+1.342366198447084207e+04 8.098792878366159130e+03 5.084430169154232317e+03 3.406217264347990749e+03 2.414562673628659468e+03
+1.193896959892624000e+04 7.216250232059411246e+03 4.533178560788861432e+03 3.037259836327594257e+03 2.152150430956434775e+03
+1.077269347091320378e+04 6.531271458645319399e+03 4.106969054172840515e+03 2.751949166685053115e+03 1.948676758735185331e+03
+9.669380723427724661e+03 5.887313135566280835e+03 3.706961866080707296e+03 2.483945655575433193e+03 1.757131469621372162e+03
+8.265749528105183344e+03 5.046433552770399729e+03 3.178737492817685506e+03 2.128930625051486004e+03 1.504008597322270816e+03
+6.570931177289904554e+03 3.997547216703016602e+03 2.510596357717497085e+03 1.678252127553695345e+03 1.183667913587031308e+03
+5.197453799547990457e+03 3.139561900391413019e+03 1.961277083060902214e+03 1.306741056368453656e+03 9.194472054789081312e+02
+4.466210302796373981e+03 2.704380832301299506e+03 1.688187881683597425e+03 1.122176256201643810e+03 7.869241121442331632e+02
+3.772152735520938222e+03 2.285511303808846606e+03 1.424385605999264271e+03 9.437320696721025115e+02 6.589099940404860263e+02
+2.938908440860989231e+03 1.743271670977121630e+03 1.071146764640740230e+03 7.032337126683634096e+02 4.880480025843961585e+02
+2.474669128531984825e+03 1.459394622274818175e+03 8.923375464071239094e+02 5.822596297134774659e+02 4.012149126720584604e+02
+2.025642891775987891e+03 1.169929166911697166e+03 7.054619066893744730e+02 4.552918270922349961e+02 3.107803446117438853e+02
+1.686382479470304588e+03 9.527472197269701155e+02 5.663252623211387800e+02 3.611283546374926345e+02 2.437404219017894889e+02
+1.406286320224776546e+03 7.697754348222712224e+02 4.479988244488304190e+02 2.810376970202713665e+02 1.870263876458986942e+02
+1.195782657322279420e+03 6.356608109143477350e+02 3.628761365821521849e+02 2.240052880611867749e+02 1.467616270460216015e+02
+1.022270971493611114e+03 5.242121203221487349e+02 2.917039754964362714e+02 1.764130995204149031e+02 1.134377959578459638e+02
+8.828291567488212195e+02 4.363778885378634982e+02 2.361709650221392849e+02 1.395980508657663677e+02 8.788478427270899829e+01
+7.688408083713314909e+02 3.668417746739735321e+02 1.929258272383900135e+02 1.112753819475748429e+02 6.844225891513558224e+01
+6.734167349371214186e+02 3.110104485809366111e+02 1.589460242856839614e+02 8.935720349086699343e+01 5.360182254377985345e+01
+5.916586916884594984e+02 2.655837846866302812e+02 1.320907989079396145e+02 7.237526338827024119e+01 4.229714418071976922e+01
+5.199976980896733494e+02 2.280131925622416986e+02 1.106787982124160834e+02 5.917406451819297075e+01 3.369061053189702903e+01
+4.559135133833511873e+02 1.963426923006732352e+02 9.337498505863452181e+01 4.882703002251533775e+01 2.711270039021696476e+01
+3.977322815435029497e+02 1.691463525221310249e+02 7.918060640330755007e+01 4.063717196442842550e+01 2.205990053825261654e+01
+3.444118677656650789e+02 1.453936467006655846e+02 6.733876416561122369e+01 3.406832230293183983e+01 1.814497057429624149e+01
+2.953861350555572471e+02 1.243682539025089540e+02 5.728985466910523172e+01 2.871574675831018553e+01 1.507487471569938897e+01
+2.504326543522320776e+02 1.055945966000173399e+02 4.862868149996033651e+01 2.427702740314572338e+01 1.262925862195758420e+01
+2.095555439216587104e+02 8.877730754612444741e+01 4.107133534394322538e+01 2.053077514630150802e+01 1.064476314913351018e+01
+1.728730507604634283e+02 7.374868082728224294e+01 3.442608262145343900e+01 1.731819652545134858e+01 9.001623920025169312e+00
+1.405102565461263850e+02 6.042350662820458496e+01 2.856916059923916862e+01 1.452889839044627784e+01 7.613624062187170694e+00
+1.125098265927821473e+02 4.875937518261158488e+01 2.342358364769205181e+01 1.208912100010555157e+01 6.420184437960062773e+00
+8.877878963069832707e+01 3.872216598544438426e+01 1.894083763650656138e+01 9.951830780880669636e+00 5.380239579486063128e+00
+6.907873568814957821e+01 3.025816793225992996e+01 1.508572283763530741e+01 8.088012260198567560e+00 4.467322605073089647e+00
+5.305007979037982579e+01 2.327636888915649038e+01 1.182496820578950825e+01 6.479003691266574272e+00 3.665431125293586945e+00
+4.025348430063843352e+01 1.764434703487938094e+01 9.119917918658297040e+00 5.110166876342798759e+00 2.965418340465647340e+00
+3.021446068580046074e+01 1.319722319072422501e+01 6.923010817939688089e+00 3.966349446692774894e+00 2.361806499356021050e+00
+2.246248982072604150e+01 9.754045565665814266e+00 5.177532304073872105e+00 3.029463047482390259e+00 1.850151783932875826e+00
+1.656015298985475681e+01 7.134592581918813181e+00 3.820131567781743787e+00 2.278010983876620710e+00 1.425187108895539900e+00
+1.212104196316129467e+01 5.172192912078578786e+00 2.785263161702906221e+00 1.687939408797406227e+00 1.079909946057611148e+00
+8.817609251253863079e+00 3.721322948950293696e+00 2.010058906742148377e+00 1.234079979208950961e+00 8.055682003949958814e-01
+6.381396580455243495e+00 2.660571015263709427e+00 1.438114244220764171e+00 8.916904573179076365e-01 5.922611037834141223e-01
+4.598359600549411397e+00 1.892255194133234397e+00 1.021516989930042918e+00 6.378379042000109633e-01 4.297672118214306280e-01
+3.301649435334715221e+00 1.340042007465594542e+00 7.213014528012988702e-01 4.524207196726385272e-01 3.082911623010851088e-01
+2.363586489249736466e+00 9.456596298715985727e-01 5.068520600950924271e-01 3.186771611514723213e-01 2.189939025734843892e-01
+1.687927183687062849e+00 6.654509581220939829e-01 3.547633630385326198e-01 2.231989529683754969e-01 1.542969824575534943e-01
+1.203009738511493065e+00 4.671959996503354251e-01 2.475264780853942415e-01 1.556102158772473543e-01 1.079887483285981026e-01
+8.560059531933452703e-01 3.273996768213129349e-01 1.722672032410733634e-01 1.080890842578590694e-01 7.517055853999345116e-02
+6.082859937534358385e-01 2.290928403394646151e-01 1.196474241551674922e-01 7.485934696730291160e-02 5.209894317475911862e-02
+4.317874232116069577e-01 1.601131243797833392e-01 8.296654149057455796e-02 5.172407378999929056e-02 3.598356435433126138e-02
+3.062326423160630084e-01 1.117963823270008705e-01 5.745731268654837021e-02 3.567244573924009676e-02 2.478475128904975705e-02
+2.170322408451179630e-01 7.800043332819341091e-02 3.975074996509905118e-02 2.456604917794153950e-02 1.703415184231726540e-02
+1.537258462344259224e-01 5.438778394891596868e-02 2.747860719089641537e-02 1.689796459832801356e-02 1.168724536889349623e-02
+1.088346057088414032e-01 3.790479668540509134e-02 1.898306731580501686e-02 1.161279382077663215e-02 8.007897514648740223e-03
+7.702349878025624430e-02 2.640694362177795768e-02 1.310745045369341409e-02 7.974924767301149256e-03 5.481069532485032501e-03
+5.449377824405470666e-02 1.839108656400300496e-02 9.046823515999731502e-03 5.473569032761559268e-03 3.748450071894476442e-03
+3.854458849543985349e-02 1.280528281560912307e-02 6.242181881462068559e-03 3.755097378574730367e-03 2.561862103790463890e-03
+2.725795436662901972e-02 8.914259017347641451e-03 4.305939266274396576e-03 2.575251966350863668e-03 1.750002219125025267e-03
diff --git a/skypy/power_spectrum/tests/data/truth_takahashi.txt b/skypy/power_spectrum/tests/data/truth_takahashi.txt
new file mode 100644
index 0000000..3821b05
--- /dev/null
+++ b/skypy/power_spectrum/tests/data/truth_takahashi.txt
@@ -0,0 +1,100 @@
+4.307265640670998437e+02 2.566374549793677602e+02 1.600448095248837319e+02 1.068590681396608062e+02 7.569661560088660224e+01
+4.930894566634436842e+02 2.937959381880738192e+02 1.832181140972656692e+02 1.223316460795109890e+02 8.665712412121320085e+01
+5.644699826749822478e+02 3.363278747588973374e+02 2.097426306184939904e+02 1.400418491866120689e+02 9.920275132448260536e+01
+6.461664340624427041e+02 3.850070089716037955e+02 2.401009579590414091e+02 1.603119292089488965e+02 1.135617855914026677e+02
+7.396612677463605223e+02 4.407168784981828367e+02 2.748441894846869218e+02 1.835098801244325557e+02 1.299949221925355118e+02
+8.466458975703293390e+02 5.044656064779655367e+02 3.146011457278915486e+02 2.100556057382765687e+02 1.487996335945859983e+02
+9.690481844025078999e+02 5.774023076434120867e+02 3.600886161341001639e+02 2.404277619971090587e+02 1.703150181339045730e+02
+1.109062606579969952e+03 6.608350998717271523e+02 4.121226052757016305e+02 2.751712712416614863e+02 1.949271252150973908e+02
+1.269182914147416795e+03 7.562506066128376006e+02 4.716305130946259396e+02 3.149054617516602548e+02 2.230747241537352750e+02
+1.452236797473573006e+03 8.653346737965007378e+02 5.396640780864727276e+02 3.603327188442603983e+02 2.552554363010440284e+02
+1.661421699195238716e+03 9.899937864338784266e+02 6.174127640282739549e+02 4.122474348974250233e+02 2.920320800933119472e+02
+1.900340325677399733e+03 1.132376329987141844e+03 7.062170591633214372e+02 4.715449044924264399e+02 3.340389787300423450e+02
+2.173033621694780322e+03 1.294892370748510075e+03 8.075808636499572231e+02 5.392296153613460774e+02 3.819878417713579211e+02
+2.484007909367616776e+03 1.480229997873758066e+03 9.231817477986957101e+02 6.164221234591439043e+02 4.366726461815823086e+02
+2.838251516047000223e+03 1.691365451408511490e+03 1.054877353964017402e+03 7.043633604304251321e+02 4.989727015596757838e+02
+3.241234504552677208e+03 1.931563242835537039e+03 1.204705580900979839e+03 8.044147986324705926e+02 5.698527846710610447e+02
+3.698883096762272544e+03 2.204361271353182019e+03 1.374875439586798393e+03 9.180523984450588841e+02 6.503588739773073257e+02
+4.217518147641132600e+03 2.513534609252618793e+03 1.567744640587978438e+03 1.046851709254309981e+03 7.416076229167205156e+02
+4.803744791802210784e+03 2.863030298186096843e+03 1.785779142634125719e+03 1.192460940976926395e+03 8.447673178312820710e+02
+5.464278500806233751e+03 3.256864373798410270e+03 2.031489190166658545e+03 1.356558353994014624e+03 9.610277340316514483e+02
+6.205691762442397703e+03 3.698971719254930576e+03 2.307335981025174988e+03 1.540790056441992192e+03 1.091556119711737210e+03
+7.034066054108157914e+03 4.192999612882504152e+03 2.615603266999501557e+03 1.746684404288879477e+03 1.237436612233084588e+03
+7.954536396847890501e+03 4.742037375859893473e+03 2.958229145099687685e+03 1.975539835186776145e+03 1.399590840587212597e+03
+8.970721080979541512e+03 5.348277659340700666e+03 3.336595242958679137e+03 2.228284263066102540e+03 1.578678384615464438e+03
+1.008403732998496889e+04 6.012609740972447980e+03 3.751273502290708166e+03 2.505306159859875152e+03 1.774977176334740534e+03
+1.129291430269161174e+04 6.734151477224823793e+03 4.201734662523469524e+03 2.806260048712626030e+03 1.988245767281655617e+03
+1.259192673690367155e+04 7.509733566524773778e+03 4.686026896938557911e+03 3.129852032203881663e+03 2.217571437719482674e+03
+1.397088370933270562e+04 8.333356319195196193e+03 5.200437106962725011e+03 3.473613679713103011e+03 2.461210035050604347e+03
+1.541391475313140108e+04 9.195643602341226142e+03 5.739150136650830973e+03 3.833674432349369454e+03 2.716424726947648196e+03
+1.689859690651369237e+04 1.008331921959524152e+04 6.293921496163569827e+03 4.204542894450379208e+03 2.979331002578181142e+03
+1.839515833130610190e+04 1.097872600987671285e+04 6.853776021736013718e+03 4.578905257056580922e+03 3.244753747706088689e+03
+1.986577553125675331e+04 1.185939658908412821e+04 7.404737728671934747e+03 4.947444283459657527e+03 3.506098798232423633e+03
+2.126395531349316661e+04 1.269766901151056118e+04 7.929586221012993519e+03 5.298675620532538233e+03 3.755236626800945032e+03
+2.253397670315176583e+04 1.346033115230911244e+04 8.407628902935895894e+03 5.618793985877475279e+03 3.982392767788485344e+03
+2.361041404202426929e+04 1.410830573953881685e+04 8.814495487246986158e+03 5.891533057808501326e+03 4.176047444709057345e+03
+2.441799611533794450e+04 1.459652949186358273e+04 9.122049291480454485e+03 6.098101275102925683e+03 4.322888002467423576e+03
+2.487271952444912313e+04 1.487458068934260518e+04 9.298760039602373581e+03 6.217422465271039982e+03 4.407975590894411653e+03
+2.488653151181447174e+04 1.488945259512788107e+04 9.311410718664987144e+03 6.227262960123927769e+03 4.415537449346890753e+03
+2.437991796078946936e+04 1.459308833111326385e+04 9.129777116453391500e+03 6.107341069922797033e+03 4.331161608411184716e+03
+2.330747132843887084e+04 1.395773696546067367e+04 8.736208110460160242e+03 5.845715592169390220e+03 4.146316883102971588e+03
+2.169573485915516358e+04 1.299870772973169369e+04 8.139874065983102810e+03 5.448318296947064482e+03 3.865112942192857190e+03
+1.967554028770895457e+04 1.179382075265963249e+04 7.389024186377510887e+03 4.947203649151039826e+03 3.510176054140917131e+03
+1.747410093751401655e+04 1.047867168683310047e+04 6.568176692569712031e+03 4.398768771789787934e+03 3.121438484103347946e+03
+1.534950196352905368e+04 9.207292240966866302e+03 5.773630852942241290e+03 3.867463760089305651e+03 2.744635357564802234e+03
+1.350601701191330540e+04 8.101260743527091108e+03 5.081629919950226395e+03 3.404513382538053065e+03 2.416227704959256698e+03
+1.204305813980304629e+04 7.218916151502538014e+03 4.528974775694330674e+03 3.034890456357917628e+03 2.154138909412273733e+03
+1.091575058790722323e+04 6.531817883374426856e+03 4.097988791913282512e+03 2.747053491836332796e+03 1.950371969309190263e+03
+9.865142370597644913e+03 5.884961397291072899e+03 3.691026471389237486e+03 2.475282946129894754e+03 1.758130989010129269e+03
+8.492297563328149408e+03 5.045774792120902930e+03 3.161081404978128376e+03 2.119565129707965298e+03 1.505512761503495085e+03
+6.770065873078516233e+03 4.005368435461730314e+03 2.502323773652543423e+03 1.674903607979238132e+03 1.188238273359719187e+03
+5.364504445805525393e+03 3.154382033091373614e+03 1.961915175291856940e+03 1.309327874928307665e+03 9.270201331461443033e+02
+4.672297731354738971e+03 2.719093536384417803e+03 1.683822662900574414e+03 1.122151540948170350e+03 7.941443444678848209e+02
+4.005591448272348316e+03 2.301963040196355450e+03 1.416840122726524442e+03 9.419469237429468649e+02 6.659561129139799505e+02
+3.111675403075856593e+03 1.764399557270857940e+03 1.073751009408775417e+03 7.082216812562309087e+02 4.980278665293651557e+02
+2.660440224330383899e+03 1.482414913255337069e+03 8.927389887259163288e+02 5.856906842304076690e+02 4.107220714589107047e+02
+2.187252619884640353e+03 1.194975088935287204e+03 7.088238750199743663e+02 4.604666849814812508e+02 3.208873586949387686e+02
+1.832569945036744002e+03 9.793745005835763777e+02 5.710298145089752779e+02 3.667762738000701574e+02 2.537687582431594251e+02
+1.528529210865050118e+03 7.970833505947541653e+02 4.549951789413874508e+02 2.878046976019009549e+02 1.970726139392105836e+02
+1.304979309951210780e+03 6.635677861633905650e+02 3.705551773578180814e+02 2.306611573423447794e+02 1.562331264281119161e+02
+1.114433278860039763e+03 5.517910706982075908e+02 3.005005603741109894e+02 1.833661610952427452e+02 1.224233980805752253e+02
+9.605831502320733080e+02 4.631059936848866982e+02 2.456604652292004687e+02 1.466232123520373989e+02 9.626528239465909564e+01
+8.349058236137399263e+02 3.922993796007798437e+02 2.026827863801484284e+02 1.181545763329396266e+02 7.613177073125643801e+01
+7.299355661379674984e+02 3.348336471002563712e+02 1.686268673530603905e+02 9.593729183286072271e+01 6.056137224592987423e+01
+6.404680351628857125e+02 2.875129578959206356e+02 1.414019129497345375e+02 7.852766078851192333e+01 4.851087143171739768e+01
+5.625711504996520489e+02 2.478972936834242660e+02 1.193910594128699501e+02 6.479902201675587037e+01 3.916134230936003746e+01
+4.933366579403630681e+02 2.141287508339894146e+02 1.013364925748184078e+02 5.386322253489907297e+01 3.186156926690134128e+01
+4.307905543571280873e+02 1.848789412958264791e+02 8.631154429392528016e+01 4.505697602785391354e+01 2.612198311342227086e+01
+3.736536959105059736e+02 1.592007831461585283e+02 7.362613556984116769e+01 3.787693955337223173e+01 2.156755717551892459e+01
+3.211923679700412322e+02 1.364423121111404953e+02 6.277633101503271718e+01 3.194694029745793173e+01 1.791514443325376504e+01
+2.730795860858679021e+02 1.161666881512263814e+02 5.339811725725967761e+01 2.698746083390275885e+01 1.495185484128012021e+01
+2.292736588730092819e+02 9.808803991082135099e+01 4.523195745204996854e+01 2.279283364593328542e+01 1.251903517860096748e+01
+1.898969589949338683e+02 8.201923349032446708e+01 3.809331872034308475e+01 1.921228478206160162e+01 1.049878310205313703e+01
+1.551079350224469238e+02 6.783307957493508411e+01 3.184995996128871809e+01 1.613560476168447977e+01 8.803820804141428980e+00
+1.249802049542186353e+02 5.543410218709757231e+01 2.640434535818594597e+01 1.348198408632537415e+01 7.369623183239951913e+00
+9.942371664277064269e+01 4.473734432675032480e+01 2.168067072424146247e+01 1.119148718313602586e+01 6.148461532948975794e+00
+7.817107322232011768e+01 3.565102318682105675e+01 1.761580319753583623e+01 9.218543801688994677e+00 5.104872907153407802e+00
+6.081627046638685385e+01 2.806332105640140284e+01 1.415335943983063416e+01 7.527066551513696524e+00 4.212206016181656132e+00
+4.687345309139724492e+01 2.183681350676216226e+01 1.123992655623993464e+01 6.086945017049108841e+00 3.450004256264182168e+00
+3.583166773540314409e+01 1.681260303272659229e+01 8.822500250636153396e+00 4.871691301408283437e+00 2.802025017713299704e+00
+2.719624674727603164e+01 1.282119760432201971e+01 6.846834696742503112e+00 3.857009779398825167e+00 2.254783410194939997e+00
+2.051551794188647548e+01 9.694607637571394321e+00 5.257073823785801459e+00 3.020003398631996738e+00 1.796540437689756686e+00
+1.539478157869204722e+01 7.275926284221493567e+00 3.996951618779873261e+00 2.338743865728087457e+00 1.416669669894781380e+00
+1.150067444575264375e+01 5.425334510803968335e+00 3.012031247656790534e+00 1.792069864967342774e+00 1.105320997942948580e+00
+8.559129309399482466e+00 4.022865551535909745e+00 2.251961027604939325e+00 1.359639806457449751e+00 8.532792911082427434e-01
+6.349646757002925135e+00 2.968711141551550803e+00 1.672049916213899090e+00 1.022265793735524397e+00 6.519219579007310417e-01
+4.697898079749368350e+00 2.181910008671726242e+00 1.234011436985801069e+00 7.623959016271072420e-01 4.932240533609070776e-01
+3.468001037648732687e+00 1.598145100810399732e+00 9.060148386309134771e-01 5.645245500138303951e-01 3.698071903194494192e-01
+2.555261087211646132e+00 1.167194355345001489e+00 6.622582007600448240e-01 4.153990885317878634e-01 2.750290614150741053e-01
+1.879774486682399326e+00 8.503956334427152930e-01 4.822677625709745897e-01 3.040175786648222633e-01 2.030753181929662032e-01
+1.381030541355414698e+00 6.183333577850390617e-01 3.500857586925881226e-01 2.214729288904968285e-01 1.490062378801289000e-01
+1.013496806721725596e+00 4.488429095138153913e-01 2.534590599481115758e-01 1.607069213399734409e-01 1.087404284827924450e-01
+7.430913291225851314e-01 3.253562259588215766e-01 1.830957832490689163e-01 1.162271691412471442e-01 7.898722057050032441e-02
+5.444135032868325785e-01 2.355700215106088236e-01 1.320223301792243231e-01 8.382471578077654861e-02 5.714879560942737885e-02
+3.986004224003147911e-01 1.703974818020464466e-01 9.504978707413792860e-02 6.031528806613471738e-02 4.121080934123119016e-02
+2.916855683919730713e-01 1.231573421744894536e-01 6.834455013297406623e-02 4.331551504592954377e-02 2.963488674184570904e-02
+2.133530995401369534e-01 8.895514436898650790e-02 4.909091244956988870e-02 3.105730987187258971e-02 2.126105368981827046e-02
+1.559990349234907092e-01 6.421625290177684908e-02 3.523078280797605627e-02 2.223867755630027504e-02 1.522393805505509526e-02
+1.140277578489452825e-01 4.633647823629277740e-02 2.526582312348636325e-02 1.590667844556230281e-02 1.088365043061141277e-02
+8.332729811337266645e-02 3.342252399546118830e-02 1.810878192078373139e-02 1.136734901306653972e-02 7.770497516601956867e-03
+6.087944257146948174e-02 2.410026124380630283e-02 1.297283334788827160e-02 8.117409412399672480e-03 5.541801156290020701e-03
diff --git a/skypy/power_spectrum/tests/test_halofit.py b/skypy/power_spectrum/tests/test_halofit.py
index 6435fcf..c81f417 100644
--- a/skypy/power_spectrum/tests/test_halofit.py
+++ b/skypy/power_spectrum/tests/test_halofit.py
@@ -1,34 +1,30 @@
 import numpy as np
 from astropy.cosmology import Planck15
 from astropy.units import allclose
+from astropy.utils.data import get_pkg_data_filename
 import pytest
 from skypy.power_spectrum import halofit_smith
 from skypy.power_spectrum import halofit_takahashi
 from skypy.power_spectrum import halofit_bird
 
 
+# Power spectrum data for tests
+linear_power_filename = get_pkg_data_filename('data/linear_power.txt')
+truth_smith_filename = get_pkg_data_filename('data/truth_smith.txt')
+truth_takahashi_filename = get_pkg_data_filename('data/truth_takahashi.txt')
+truth_bird_filename = get_pkg_data_filename('data/truth_bird.txt')
+linear_power = np.loadtxt(linear_power_filename)
+truth_smith = np.loadtxt(truth_smith_filename)
+truth_takahashi = np.loadtxt(truth_takahashi_filename)
+truth_bird = np.loadtxt(truth_bird_filename)
+
+
 def test_halofit():
     """Test Smith, Takahashi and Bird Halofit models with Planck15 cosmology"""
 
-    # Data for tests
-    k = np.logspace(-4.0, 0.0, 5)
-    z = np.linspace(0.0, 1.0, 2)
-    p = [[705.54997046, 262.14967329], [6474.60158058, 2405.66190924],
-         [37161.00990355, 13807.30920991], [9657.02613688, 3588.10339832],
-         [114.60445565, 42.58170486]]
-    ts = [[705.49027968, 262.13980368], [6469.19607307, 2404.75754883],
-          [36849.24061946, 13757.68241714], [9028.01112208, 3628.67740715],
-          [596.91685425, 110.08074646]]
-    tt = [[705.48895748, 262.14055831], [6469.02581579, 2404.83678008],
-          [36827.71983838, 13751.52554662], [9143.97447325, 3050.69467676],
-          [662.31133378, 60.66609697]]
-    tb = [[705.4903004, 262.13980169], [6469.19940132, 2404.75760398],
-          [36849.2113973, 13757.8052238], [9010.83583125, 3630.48463588],
-          [601.45212141, 111.52139435]]
-    linear_power = np.array(p)
-    truth_smith = np.array(ts)
-    truth_takahashi = np.array(tt)
-    truth_bird = np.array(tb)
+    # Wavenumbers and redshifts for tests
+    k = np.logspace(-4, 2, 100, base=10)
+    z = np.linspace(0, 2, 5)
 
     # Non-linear power spectra from Smith, Takahashi and Bird models
     nl_power_smith = halofit_smith(k, z, linear_power, Planck15)
@@ -64,9 +60,9 @@ def test_halofit():
     with pytest.raises(ValueError):
         halofit_smith(k_wrong_size, z, linear_power, Planck15)
 
-    # Test for failure when redshift arry is the wrong size
+    # Test for failure when redshift array is the wrong size
     z_wrong_size = np.linspace(0.0, 2.0, 3)
-    with pytest.raises(TypeError):
+    with pytest.raises(ValueError):
         halofit_smith(k, z_wrong_size, linear_power, Planck15)
 
     # Test for failure when wavenumber is negative