In [1]:
%matplotlib inline
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
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)
In [2]:
%pwd
Out[2]:
In [3]:
cd downloads
In [4]:
cd class_public-master
In [5]:
#run CPU.py -h
In [6]:
#run CPU.py output/explanatory200_cl.dat
In [7]:
#run output/explanatory200_cl.py
In [8]:
#run output/cl_test1.py
In [9]:
import classy
In [10]:
from classy import Class
In [11]:
from math import *
import sys
from classy import Class
from numpy.polynomial.legendre import legval
cosmo = Class()
cosmo.set({'output':'lCl, tCl','lensing':'no'})
cosmo.compute()
cls = cosmo.raw_cl()
print 'cls = ', cls
ntot = len(cls)
print 'number of cls = ', ntot
In [12]:
def legpols(n, t):
pols = np.zeros(n+1)
pols[0] = 1.0
pols[1] = t
for i in range(1,n):
pols[i+1] = ((i*2.0+1)*t*pols[i] - i*pols[i-1])/(i+1.0)
return pols
In [13]:
n = 2000
alphas = np.exp(np.linspace(np.log(pi/18000), np.log(pi), num=n, endpoint=False))
print 'alphas = ', alphas
In [14]:
val = np.zeros(n)
In [15]:
for i in range(n):
t = cos(alphas[i])
pols = legpols(ntot+10, t)
val[i] = 0
for j in range(ntot):
val[i] = val[i] + (2.0*j+1)*cls[j]*pols[j]
In [ ]: