|
18 | 18 | apo_radius_degree = 2
|
19 | 19 | niter = 0
|
20 | 20 | lmax = 2000
|
21 |
| -nsims = 4 |
| 21 | +nsims = 30 |
22 | 22 |
|
23 |
| -vk_mask = [-90, 90] |
24 |
| -hk_mask = [-50, 50] |
25 | 23 |
|
26 | 24 | test_dir = "result_kspace"
|
27 | 25 | try:
|
|
45 | 43 | window = (window,window)
|
46 | 44 | mbb_inv, Bbl = so_mcm.mcm_and_bbl_spin0and2(window, binning_file, lmax=lmax, type="Dl", niter=niter)
|
47 | 45 |
|
| 46 | +# we build two different filters and compute the analytical 1d binned spectra they correspond to |
| 47 | + |
| 48 | +vk_mask = [-90, 90] |
| 49 | +hk_mask = [-50, 50] |
| 50 | +filter_std = so_map_preprocessing.build_std_filter(template.data.shape, template.data.wcs, vk_mask, hk_mask, dtype=np.float64) |
| 51 | + |
| 52 | +lbounds = [4000, 5] |
| 53 | +filter_sig = so_map_preprocessing.build_sigurd_filter(template.data.shape, template.data.wcs, lbounds, dtype=np.float64) |
| 54 | + |
| 55 | + |
| 56 | +lb, analytic_tf_std = so_map_preprocessing.analytical_tf(template, filter_std, binning_file, lmax) |
| 57 | +lb, analytic_tf_sig = so_map_preprocessing.analytical_tf(template, filter_sig, binning_file, lmax) |
| 58 | + |
| 59 | + |
| 60 | + |
48 | 61 |
|
49 | 62 | # Let's run nsims, and apply the transfer function, we will compute both the SPHT and the FFT of the initial and filtered maps.
|
50 | 63 | # Then we compute the associated 1d and 2d power spectra, we will store the value of the resulting
|
|
56 | 69 | spectra_2d = ["II", "IQ", "IU", "QI", "QQ", "QU", "UI", "UQ", "UU"]
|
57 | 70 | Db_list = {}
|
58 | 71 | p2d_list = {}
|
59 |
| -for spec in spectra: |
60 |
| - Db_list["standard", spec] = [] |
61 |
| - Db_list["filtered", spec] = [] |
62 |
| -for spec in spectra_2d: |
63 |
| - p2d_list["standard", spec] = [] |
64 |
| - p2d_list["filtered", spec] = [] |
65 |
| - |
| 72 | + |
| 73 | +runs = ["sig_filtered", "std_filtered", "no_filter"] |
| 74 | + |
| 75 | +for run in runs: |
| 76 | + for (spec, spec2d) in zip(spectra, spectra_2d): |
| 77 | + Db_list[run, spec] = [] |
| 78 | + p2d_list[run, spec2d] = [] |
| 79 | + |
66 | 80 |
|
67 | 81 | for iii in range(nsims):
|
68 | 82 | print("sim number %03d" % iii)
|
69 |
| - for run in ["standard", "filtered"]: |
| 83 | + for run in runs: |
70 | 84 | cmb = template.synfast(clfile)
|
71 | 85 |
|
72 | 86 | if iii == 0: cmb.plot(file_name="%s/cmb"%(test_dir))
|
73 |
| - if run == "filtered": |
74 |
| - cmb = so_map_preprocessing.kspace_filter(cmb, vk_mask=vk_mask, hk_mask=hk_mask, normalize="phys") |
| 87 | + if run == "std_filtered": |
| 88 | + cmb = so_map_preprocessing.apply_std_filter(cmb, filter_std) |
75 | 89 | if iii == 0: cmb.plot(file_name="%s/cmb_filter"%(test_dir))
|
| 90 | + elif run == "sig_filtered": |
| 91 | + cmb = so_map_preprocessing.apply_sigurd_filter(cmb, binary.data, filter_sig, tol=1e-4, ref=0.9) |
| 92 | + if iii == 0: cmb.plot(file_name="%s/cmb_sigurd_filter"%(test_dir)) |
76 | 93 |
|
77 | 94 | alm_cmb = sph_tools.get_alms(cmb, window, niter, lmax)
|
78 | 95 | fft_cmb = flat_tools.get_ffts(cmb, window, lmax)
|
|
97 | 114 |
|
98 | 115 |
|
99 | 116 | # First the 1d part with the associated transfer functions
|
100 |
| -# we also compute a simple analytical version of the transfer function |
101 | 117 |
|
102 |
| -lb, analytic_tf = so_map_preprocessing.analytical_tf(cmb, binning_file, lmax, vk_mask=vk_mask, hk_mask=hk_mask) |
103 | 118 |
|
104 | 119 | mean = {}
|
105 | 120 | std = {}
|
106 | 121 | for spec in spectra:
|
107 |
| - |
108 |
| - mean["standard", spec]= np.mean(Db_list["standard", spec], axis=0) |
109 |
| - mean["filtered", spec]= np.mean(Db_list["filtered", spec], axis=0) |
110 |
| - std["standard", spec]= np.std(Db_list["standard", spec], axis=0) |
111 |
| - std["filtered", spec]= np.std(Db_list["filtered", spec], axis=0) |
112 |
| - |
113 |
| - plt.errorbar(lb, mean["standard", spec], std["standard", spec], fmt=".", label="standard") |
114 |
| - plt.errorbar(lb, mean["filtered", spec], std["filtered", spec], fmt=".", label="filtered") |
| 122 | + for run in runs: |
| 123 | + mean[run, spec]= np.mean(Db_list[run, spec], axis=0) |
| 124 | + std[run, spec]= np.std(Db_list[run, spec], axis=0) |
| 125 | + plt.errorbar(lb, mean[run, spec], std[run, spec], fmt=".", label=run) |
| 126 | + |
115 | 127 | plt.legend()
|
116 | 128 | plt.savefig("%s/spectra_%s.png" % (test_dir, spec))
|
117 | 129 | plt.clf()
|
118 | 130 | plt.close()
|
119 | 131 |
|
120 | 132 |
|
121 | 133 | if spec in ["TT", "EE", "TE", "BB"] :
|
122 |
| - plt.plot(lb, analytic_tf) |
123 |
| - plt.plot(lb, mean["filtered", spec]/mean["standard", spec], ".") |
| 134 | + plt.plot(lb, analytic_tf_std, label = "std analytic") |
| 135 | + plt.plot(lb, analytic_tf_sig, label = "sigurd analytic") |
| 136 | + |
| 137 | + plt.errorbar(lb, mean["std_filtered", spec]/mean["no_filter", spec], label="std filter", fmt=".") |
| 138 | + plt.errorbar(lb, mean["sig_filtered", spec]/mean["no_filter", spec], label="sigurd filter", fmt=".") |
| 139 | + |
| 140 | + plt.legend() |
124 | 141 | plt.savefig("%s/tf_%s.png" % (test_dir, spec))
|
125 | 142 | plt.clf()
|
126 | 143 | plt.close()
|
127 | 144 |
|
128 | 145 |
|
129 |
| -plt.plot(lb, analytic_tf) |
| 146 | +plt.plot(lb, analytic_tf_std, label = "std analytic") |
| 147 | +plt.plot(lb, analytic_tf_sig, label = "sigurd analytic") |
| 148 | + |
130 | 149 | for spec in ["TT", "EE"] :
|
131 |
| - plt.plot(lb, mean["filtered", spec]/mean["standard", spec], ".", label = spec) |
| 150 | + plt.plot(lb, mean["std_filtered", spec]/mean["no_filter", spec], ".", label = spec + "std") |
| 151 | + plt.plot(lb, mean["sig_filtered", spec]/mean["no_filter", spec], ".", label = spec + "sigurd") |
| 152 | + |
| 153 | +plt.legend() |
132 | 154 | plt.savefig("%s/tf_TT_and_EE.png" % (test_dir))
|
133 | 155 | plt.clf()
|
134 | 156 | plt.close()
|
135 | 157 |
|
136 | 158 | # Now the 2d part with the plot of the effect of the filter
|
137 | 159 |
|
138 |
| -mean["standard"] = p2d_dict.copy() |
139 |
| -mean["filtered"] = p2d_dict.copy() |
| 160 | + |
| 161 | +for run in runs: |
| 162 | + mean[run] = p2d_dict.copy() |
140 | 163 | for spec in spectra_2d:
|
141 |
| - for run in ["standard", "filtered"]: |
| 164 | + for run in runs: |
142 | 165 | mean[run].powermap[spec] = np.mean(p2d_list[run, spec], axis=0)
|
143 |
| -for run in ["standard", "filtered"]: |
| 166 | +for run in runs: |
144 | 167 | mean[run].plot(power_of_ell=2, png_file="%s/%s" % (test_dir, run))
|
0 commit comments