Salman Habib's project solution

We start importing libraries and making the plots look awesome


In [1]:
import matplotlib
matplotlib.use('nbagg')
import matplotlib.pyplot as plt
import pandas as pd
from matplotlib import rc

rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
## for Palatino and other serif fonts use:
#rc('font',**{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)

#LaTeX
plt.rc('text', usetex=True)
plt.rc('font', family='serif')

Using the g derived from CMB constraints

We read the data using Pandas


In [2]:
df = pd.read_table("wmap7", skiprows=5,header = None, sep=" ")
df.drop(df.columns[[2]],axis=1, inplace=True)
df1 = pd.read_table("wmap9", skiprows=5,header = None, sep=" ")
df1.drop(df1.columns[[2]],axis=1, inplace=True)
df2 = pd.read_table("planck", skiprows=5,header = None, sep=" ")
df2.drop(df2.columns[[2]],axis=1, inplace=True)

Modify the column's name


In [3]:
df.columns = ['a', 'b']
df1.columns = ['a', 'b']
df2.columns = ['a', 'b']

Plot the data using Matplotlib


In [4]:
plt.loglog(df["a"],df["b"],label=r'WMAP7')
plt.loglog(df1["a"],df1["b"],label=r'WMAP9')
plt.loglog(df2["a"],df2["b"],label=r'PLANCK')
plt.xlabel(r'$k$')
plt.ylabel(r'$P(k)$')
plt.legend()
plt.show()


Without using the h derived from CMB constraints

We read the data using Pandas


In [6]:
df3 = pd.read_table("wmap7h", skiprows=5,header = None, sep=" ")
df3.drop(df3.columns[[2]],axis=1, inplace=True)
df4 = pd.read_table("wmap9h", skiprows=5,header = None, sep=" ")
df4.drop(df4.columns[[2]],axis=1, inplace=True)
df5 = pd.read_table("planckh", skiprows=5,header = None, sep=" ")
df5.drop(df5.columns[[2]],axis=1, inplace=True)

Modify the column's name


In [7]:
df3.columns = ['a', 'b']
df4.columns = ['a', 'b']
df5.columns = ['a', 'b']

Plot the data using Matplotlib


In [5]:
plt.loglog(df3["a"],df["b"],label=r'WMAP7')
plt.loglog(df4["a"],df1["b"],label=r'WMAP9')
plt.loglog(df5["a"],df2["b"],label=r'PLANCK')
plt.xlabel(r'$k$')
plt.ylabel(r'$P(k)$')
plt.legend()
plt.show()


--------------------------------------------------------------------------
NameError                                Traceback (most recent call last)
<ipython-input-5-beb8215e017d> in <module>()
----> 1 plt.loglog(df3["a"],df["b"],label=r'WMAP7')
      2 plt.loglog(df4["a"],df1["b"],label=r'WMAP9')
      3 plt.loglog(df5["a"],df2["b"],label=r'PLANCK')
      4 plt.xlabel(r'$k$')
      5 plt.ylabel(r'$P(k)$')

NameError: name 'df3' is not defined