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 |
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import mockgallib as mock
ps = mock.PowerSpectrum('../data/planck1_matterpower.dat')
ps
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
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();
%%html
<style>
table {float:left}
</style>