In [2]:
%pylab inline
from scipy import integrate


Populating the interactive namespace from numpy and matplotlib

In [3]:
def func(z, omega_m=0.3, omega_l=0.7, omega_k=0.0):
    return sqrt(omega_m * (z+1)**3 + omega_k * (z+1)**2 + omega_l)

In [4]:
n_points = 1000
z_range = linspace(0,6.0, n_points)
hubble_0 = 70.0
hubble = hubble_0 * func(z_range)

In [5]:
fig = plt.figure(figsize=(10, 8.0))
plot(z_range, hubble)
xlabel("redshift")
ylabel("Hubble (km/s/Mpc)")


Out[5]:
<matplotlib.text.Text at 0x7fe612253490>

In [6]:
fig = plt.figure(figsize=(10, 8.0))
omega_m = array([0.3,0.4,0.5,1.0])
omega_l = 1.0 - omega_m
omega_k = 1.0 - (omega_m + omega_l)

for o_m, o_l, o_k in zip(omega_m, omega_l, omega_k):
    hubble = hubble_0 * func(z_range, omega_m = o_m, omega_l=o_l, omega_k=o_k)
    plot(z_range, hubble, label=" o_m={} o_l={}".format(o_m,o_l))

xlabel("redshift")
ylabel("Hubble (km/s/Mpc)")
legend(loc=2)


Out[6]:
<matplotlib.legend.Legend at 0x7fe612249c10>

In [ ]: