Skip to content

Commit

Permalink
restore get_bestfit functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
xzackli committed Dec 13, 2023
1 parent 3378ac8 commit 898e272
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions project/ana_cov_comp/python/get_best_fit_mflike.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import pylab as plt
from pspipe_utils import best_fits, log, pspipe_list
from pspy import pspy_utils, so_dict, so_spectra
from itertools import combinations_with_replacement

d = so_dict.so_dict()
d.read_from_file(sys.argv[1])
Expand Down Expand Up @@ -47,7 +48,20 @@
if do_bandpass_integration:
log.info("Doing bandpass integration")

narrays, sv_list, ar_list = pspipe_list.get_arrays_list(d)
# compatibility with data_analysis, should be industrialized #FIXME
def get_arrays_list(d):
surveys = d['surveys']
arrays = {sv: d[f'arrays_{sv}'] for sv in surveys}
sv_list, ar_list = [], []
for sv1 in surveys:
for ar1 in arrays[sv1]:
for chan1 in arrays[sv1][ar1]:
sv_list.append(sv1)
ar_list.append(f"{ar1}_{chan1}")
return len(sv_list), sv_list, ar_list

narrays, sv_list, ar_list = get_arrays_list(d)

for sv, ar in zip(sv_list, ar_list):

freq_info = d[f"freq_info_{sv}_{ar}"]
Expand All @@ -58,6 +72,7 @@

passbands[f"{sv}_{ar}"] = [nu_ghz, pb]


log.info("Getting foregrounds contribution")
fg_dict = best_fits.get_foreground_dict(l_th, passbands, fg_components, fg_params, fg_norm)

Expand All @@ -71,7 +86,7 @@
so_spectra.write_ps(f"{bestfit_dir}/fg_{name1}x{name2}.dat", l_th, fg, type, spectra=spectra)

log.info("Writing best fit spectra")
spectra_list = pspipe_list.get_spec_name_list(d, char = "_")
spectra_list = ([f"{a}x{b}" for a,b in combinations_with_replacement(passbands.keys(), 2)])
best_fit_dict = {}
for ps_name in spectra_list:
best_fit_dict[ps_name] = {}
Expand Down

0 comments on commit 898e272

Please sign in to comment.