Skip to content

Commit 9192413

Browse files
author
Louis Thibaut
committed
add script to deconvolve the transfer function
1 parent 79b7532 commit 9192413

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import pylab as plt
2+
import numpy as np
3+
import sys
4+
from copy import deepcopy
5+
6+
from pspy import pspy_utils, so_dict, so_mcm, so_spectra
7+
from pspipe_utils import log, pspipe_list
8+
9+
10+
d = so_dict.so_dict()
11+
d.read_from_file(sys.argv[1])
12+
log = log.get_logger(**d)
13+
14+
15+
spec_dir = "spectra"
16+
spec_corr_dir = "spectra_corrected_pspipe"
17+
tf_dir = "transfer_functions"
18+
19+
pspy_utils.create_directory(spec_corr_dir)
20+
21+
type = d["type"]
22+
23+
24+
spectra = ["TT", "TE", "TB", "ET", "BT", "EE", "EB", "BE", "BB"]
25+
spec_name_list = pspipe_list.get_spec_name_list(d, delimiter="_")
26+
27+
spin_pairs = ["spin0xspin0", "spin0xspin2", "spin2xspin0", "spin2xspin2"]
28+
29+
for spec_name in spec_name_list:
30+
31+
tf = {}
32+
for spec in ["TT", "EE", "BB"]:
33+
lb_tf, tf[spec], sigma_tf = np.loadtxt(f"{tf_dir}/transfer_function_filter_masking_yes_alm_mask_{spec}_{spec_name}.dat", unpack=True)
34+
35+
for spec in spectra:
36+
a, b = spec
37+
if a != b:
38+
print(a, b, "ok")
39+
tf[spec] = np.sqrt(tf[a + a] * tf[b + b])
40+
41+
for spec_type in ["auto", "noise", "cross"]:
42+
43+
lb, Db_dict = so_spectra.read_ps(f"spectra/{type}_{spec_name}_{spec_type}.dat", spectra=spectra)
44+
id = np.where(lb >= lb_tf[0]) # use the same lmin
45+
46+
ps_dict = {}
47+
for spec in spectra:
48+
ps_dict[spec] = Db_dict[spec][id] / tf[spec]
49+
50+
so_spectra.write_ps(spec_corr_dir + f"/{type}_{spec_name}_{spec_type}.dat", lb[id], ps_dict, type, spectra=spectra)

0 commit comments

Comments
 (0)