This repository was archived by the owner on Feb 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_correlations.py
More file actions
49 lines (34 loc) · 1.47 KB
/
plot_correlations.py
File metadata and controls
49 lines (34 loc) · 1.47 KB
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
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap, Normalize
from glass.matter import effective_redshifts
from _plotting import split_bins, symlog_no_zero
from _config import *
cls = np.load(spec_path/'matter.npy')
nshell = len(shells)-1
zeff = effective_redshifts(weights)
l = np.arange(cls.shape[-1])
cls = split_bins(cls)
cmap = LinearSegmentedColormap.from_list('C0-C6-C2', ['C0', 'C6', 'C2'])
fig, axes = plt.subplots(4, 2, figsize=(8, 4), sharex=True, sharey=True)
for k, ax in enumerate(axes.T.flat):
for i in range(nshell):
if len(cls[i]) > k+1:
r = cls[i][k+1, 1:]/(cls[i][0, 1:]*cls[i-k-1][0, 1:])**0.5
ax.plot(l[1:], r, c=cmap(zeff[i]/zend), ls='-', lw=0.5)
ax.grid(which='major', axis='y')
ax.set_ylabel(f'$R_l^{{i,i-{k+1}}}$')
axes[0, 0].set_ylim(-0.5, 0.5)
axes[0, 0].set_xscale('log')
axes[0, 0].set_yscale('symlog', linthresh=1e-2, linscale=0.45, subs=None)
axes[-1, 0].set_xlabel('angular mode number $l$')
axes[-1, 1].set_xlabel('angular mode number $l$')
symlog_no_zero(axes)
fig.tight_layout()
cbar = fig.colorbar(plt.cm.ScalarMappable(norm=Normalize(vmin=0, vmax=zend), cmap=cmap),
ax=axes, orientation='vertical',
label='effective redshift $\\bar{z}_i$',
fraction=0.04, shrink=0.5, pad=0.03)
cbar.ax.tick_params(rotation=90)
fig.savefig(plot_path/'correlations.pdf', dpi=300, bbox_inches='tight')
plt.close()