-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLOG_HT_cosmo_test.py
55 lines (39 loc) · 1.15 KB
/
LOG_HT_cosmo_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'''
Small example script used to convert a cosmological power spectrum into
a correlation funciton using LOG_HT.py.
Joseph E. McEwen
McEwen Laboratories (c) 2016
email: [email protected]
'''
from __future__ import division
import numpy as np
from LOG_HT import r_to_k, k_to_r
# load power spectrum data
data=np.loadtxt('Pk_test.dat')
k=data[:,0]
P=data[:,1]
# get correlation function from power spectrum
r,xi=k_to_r(k,P)
# get power spectrum from correlation function (this is the roundtrip power spectrum)
k2,P2=r_to_k(r,xi)
import matplotlib.pyplot as plt
fig=plt.figure()
ax=fig.add_subplot(121)
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel(r'$r$', size=30)
ax.set_ylabel(r'$\xi(r)$', size=30)
ax.plot(r,xi, color='black', label='fftlog-python' )
ax.legend()
ax.grid()
ax=fig.add_subplot(122)
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel(r'$k$', size=30)
ax.set_ylabel(r'$P(k)$', size=30)
ax.plot(k,P,color='black',label='original power spectrum')
ax.plot(k2,P2,'--', color='red',label='round trip fftlog-python power spectrum')
ax.legend(loc=3,fontsize=10)
ax.grid()
plt.show()
fig.savefig('HT_example_plot.pdf')