|
1 | 1 | # Standard imports |
2 | 2 | import sys |
| 3 | + |
| 4 | +# Third-part imports |
3 | 5 | import numpy as np |
4 | 6 | import matplotlib.pyplot as plt |
5 | 7 |
|
6 | 8 | # Project imports |
7 | | -sys.path.append('../') |
8 | | - |
9 | 9 | import hmcode |
10 | 10 | import hmcode.camb_stuff as camb_stuff |
11 | 11 | import hmcode.utility as util |
12 | 12 |
|
13 | | -plotting=True |
| 13 | +# Make plots or not |
| 14 | +plotting = False |
14 | 15 |
|
15 | 16 | # Vary these parameters |
16 | 17 | vary_Omega_k = True |
|
30 | 31 | m_nu_min, m_nu_max = 0., 1. |
31 | 32 | log10T_AGN_min, log10T_AGN_max = 7.6, 8.3 |
32 | 33 |
|
33 | | - |
34 | 34 | # Number of cosmological models to test |
35 | 35 | try: |
36 | 36 | ncos = int(sys.argv[1]) |
|
69 | 69 | if w0+wa < 0.: break |
70 | 70 | m_nu = rng.uniform(m_nu_min, m_nu_max) if vary_m_nu else 0. |
71 | 71 |
|
72 | | - #Gravity only spectra |
| 72 | + ### Gravity only spectra ### |
73 | 73 |
|
74 | 74 | # Get stuff from CAMB |
75 | 75 | _, results_gravity, _, _, _ = camb_stuff.run(zs, Omega_c, Omega_b, Omega_k, h, ns, sigma_8, m_nu, w0, wa) |
|
83 | 83 | # Get the new pyHMcode spectrum |
84 | 84 | Pk_HMcode_gravity = hmcode.power(k, zs, results_gravity, verbose=verbose) |
85 | 85 |
|
| 86 | + ### ### |
86 | 87 |
|
87 | | - # Spectra with feedback |
| 88 | + ### Spectra with feedback ### |
88 | 89 |
|
89 | 90 | # Get stuff from CAMB |
90 | 91 | _, results_feedback, _, _, _ = camb_stuff.run(zs, Omega_c, Omega_b, Omega_k, h, ns, sigma_8, m_nu, w0, wa, log10_T_AGN=log10T_AGN) |
|
98 | 99 | # Get the new pyHMcode spectrum |
99 | 100 | Pk_HMcode_feedback = hmcode.power(k, zs, results_gravity, verbose=verbose, T_AGN=np.power(10, log10T_AGN)) |
100 | 101 |
|
101 | | - # Calculate suppressions |
| 102 | + ### ### |
102 | 103 |
|
| 104 | + # Calculate suppressions |
103 | 105 | Rk_CAMB=Pk_CAMB_feedback/Pk_CAMB_gravity |
104 | 106 | Rk_HMcode=Pk_HMcode_feedback/Pk_HMcode_gravity |
105 | 107 |
|
| 108 | + # Plotting |
106 | 109 | if plotting: |
107 | 110 | fig, axs=plt.subplots(nrows=2, sharex=True, figsize=(10,7)) |
108 | 111 | plt.subplots_adjust(hspace=0.001, bottom=0.2) |
|
119 | 122 | for i,z in enumerate(zs): |
120 | 123 | axs[0].plot(k, Rk_CAMB[i], label=f"CAMB, z={z}", color=f"C{i}", ls='--') |
121 | 124 | axs[0].plot(k, Rk_HMcode[i], label=f"HMcode-Python, z={z}", color=f"C{i}") |
122 | | - |
123 | 125 | axs[1].plot(k, 1-(Rk_CAMB[i]/Rk_HMcode[i]), label=f"z={z}", color=f"C{i}") |
124 | 126 |
|
125 | 127 | axs[0].legend() |
126 | 128 | axs[1].legend() |
127 | | - plt.savefig(f"Feedback_Cosmology_{icos}.png") |
| 129 | + plt.savefig(f"plots/Feedback_Cosmology_{icos}.png") |
| 130 | + plt.close() |
128 | 131 |
|
129 | | - |
130 | 132 | # Calculate maximum deviation between pyHMcode and the version in CAMB |
131 | 133 | max_error = np.max(np.abs(-1.+Rk_HMcode/Rk_CAMB)) |
132 | 134 | max_errors.append(max_error) |
|
0 commit comments