PowerSpectrum module

Handles tabulated power sepctrum file; k P(k).

ps = PowerSpectrum(filename)

Operation Result
len(ps) length of the power spectrum data
ps[i] ith data (k, P(k))
ps.sigma(R) rms fluctuation smoothed on scale $R \,h^{-1} \mathrm{Mpc}$; sigma8 for R = 8

Examples

In [5]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import mockgallib as mock

ps = mock.PowerSpectrum('../data/planck1_matterpower.dat')
ps
Out[5]:
PowerSpectrum
 1.000e-04  4.520e+02
 1.020e-04  4.607e+02
 1.041e-04  4.697e+02
 1.062e-04  4.788e+02
 1.083e-04  4.880e+02
......
 7.403e+03  7.967e-10
In [8]:
print(len(ps))       # number of data points
print(ps[0])         # first element of ps
print(ps.sigma(8.0)) # rms fluctuation smoothed on scale R; sigma(8.0) = sigma_8
907
(0.0001, 451.97)
0.8202842645783278
In [7]:
plt.plot(ps.k, ps.P, 'r-') # ps.k and ps.P return arrays
plt.xscale('log')
plt.yscale('log')
plt.xlabel('$k$')
plt.ylabel('$P$')
plt.show();
In [1]:
%%html
<style>
table {float:left}
</style>