def __init__( self, name="Corr Beutler 2017", fix_params=("om",), smooth_type="hinton2017", recon=None, smooth=False, correction=None, isotropic=True, poly_poles=(0, 2), marg=None, ): self.recon_smoothing_scale = None if isotropic: poly_poles = [0] if marg is not None: fix_params = list(fix_params) for pole in poly_poles: fix_params.extend([f"b{{{pole}}}"]) fix_params.extend([f"a{{{pole}}}_1", f"a{{{pole}}}_2", f"a{{{pole}}}_3"]) super().__init__( name=name, fix_params=fix_params, smooth_type=smooth_type, smooth=smooth, correction=correction, isotropic=isotropic, poly_poles=poly_poles, marg=marg, ) self.parent = PowerBeutler2017( fix_params=fix_params, smooth_type=smooth_type, recon=recon, smooth=smooth, correction=correction, isotropic=isotropic, marg=marg, ) if self.marg: for pole in self.poly_poles: self.set_default(f"b{{{pole}}}", 1.0) self.set_default(f"a{{{pole}}}_1", 0.0) self.set_default(f"a{{{pole}}}_2", 0.0) self.set_default(f"a{{{pole}}}_3", 0.0)
c = getCambGenerator() r_s = c.get_data()["r_s"] fitter = Fitter(dir_name) p = BAOExtractor(r_s) cs = ["#262232", "#116A71", "#48AB75", "#b7c742"] for r in [True]: t = "Recon" if r else "Prerecon" datae = PowerSpectrum_SDSS_DR12_Z061_NGC(recon=r, min_k=0.03, max_k=0.30, postprocess=p) for ls, n in zip(["-", ":"], ["", " (No Poly)"]): if n: fix = ["om", "f", "a1", "a2", "a3", "a4", "a5"] else: fix = ["om", "f"] fitter.add_model_and_dataset(PowerBeutler2017(postprocess=p, recon=r, fix_params=fix), datae, name=f"Beutler 2017{n}", linestyle=ls, color=cs[0]) fitter.add_model_and_dataset(PowerSeo2016(postprocess=p, recon=r, fix_params=fix), datae, name=f"Seo 2016{n}", linestyle=ls, color=cs[1]) fitter.add_model_and_dataset(PowerDing2018(postprocess=p, recon=r, fix_params=fix), datae, name=f"Ding 2018{n}", linestyle=ls, color=cs[2]) fitter.add_model_and_dataset(PowerNoda2019(postprocess=p, recon=r), datae, name=f"Noda 2019", color=cs[3]) sampler = DynestySampler(temp_dir=dir_name, nlive=300) fitter.set_sampler(sampler) fitter.set_num_walkers(10) fitter.fit(file) if fitter.should_plot(): from chainconsumer import ChainConsumer c = ChainConsumer() for posterior, weight, chain, evidence, model, data, extra in fitter.load(): c.add_chain(chain, weights=weight, parameters=model.get_labels(), **extra)
import logging from barry.models import PowerBeutler2017 if __name__ == "__main__": logging.basicConfig( level=logging.DEBUG, format="[%(levelname)7s |%(funcName)20s] %(message)s") logging.getLogger("matplotlib").setLevel(logging.ERROR) from barry.datasets import PowerSpectrum_SDSS_DR12_Z061_NGC for recon in [True, False]: dataset1 = PowerSpectrum_SDSS_DR12_Z061_NGC(recon=recon) data1 = dataset1.get_data() # Run on mean model = PowerBeutler2017(recon=recon, name=f"Beutler2017, recon={recon}") model.set_data(data1) p, minv = model.optimize(maxiter=2000, niter=200) sigma_nl = p["sigma_nl"] print( f"recon={recon}, Sigma_nl found to be {sigma_nl:0.3f} with prob {minv:0.3f}" ) model.set_default("sigma_nl", sigma_nl) model.set_fix_params(["om", "sigma_nl"]) # Recon 6.0 # Prerecon 9.3
min_k=0.0, max_k=0.30, num_mocks=999), PowerSpectrum_eBOSS_LRGpCMASS(galactic_cap="sgc", recon=None, isotropic=False, fit_poles=[0, 2, 4], min_k=0.0, max_k=0.30, num_mocks=999), ] # Standard Beutler Model model = PowerBeutler2017(recon="iso", isotropic=False, fix_params=["om"], poly_poles=[0, 2], correction=Correction.HARTLAP, marg="full") model4 = PowerBeutler2017(recon="iso", isotropic=False, fix_params=["om"], poly_poles=[0, 2, 4], correction=Correction.HARTLAP, marg="full") for d in datasets: for i in range(999): d.set_realisation(i) if 4 in d.fit_poles: fitter.add_model_and_dataset(model4, d,
sampler = DynestySampler(temp_dir=dir_name, nlive=500) # sampler = EnsembleSampler(temp_dir=dir_name, num_steps=5000) fitter = Fitter(dir_name) cs = ["#262232", "#294D5F", "#197D7A", "#48AC7C"] for r in [False]: t = "Recon" if r else "Prerecon" ls = "-" # if r else "--" d = PowerSpectrum_Beutler2019(recon=r, isotropic=True, reduce_cov_factor=np.sqrt(2000.0)) # Fix sigma_nl for one of the Beutler models model = PowerBeutler2017(recon=r, isotropic=d.isotropic, fix_params=["om"], correction=Correction.HARTLAP) model_marg_full = PowerBeutler2017(recon=r, isotropic=d.isotropic, fix_params=["om"], correction=Correction.HARTLAP, marg="full") model_marg_partial = PowerBeutler2017(recon=r, isotropic=d.isotropic, fix_params=["om"], correction=Correction.HARTLAP, marg="partial") model_fixed = PowerBeutler2017( recon=r, isotropic=d.isotropic, fix_params=[
pfn, dir_name, file = setup(__file__) c = getCambGenerator() r_s = c.get_data()["r_s"] p = BAOExtractor(r_s) sampler = DynestySampler(temp_dir=dir_name, nlive=1000) fitter = Fitter(dir_name) cs = ["#262232", "#116A71", "#48AB75", "#D1E05B"] for r in [False]: t = "Recon" if r else "Prerecon" # Fix sigma_nl for one of the Beutler models model = PowerBeutler2017(recon=r, isotropic=False, correction=Correction.NONE) model.set_default("sigma_nl_par", 10.9) model.set_default("sigma_nl_perp", 5.98) model.set_fix_params(["om", "sigma_nl_par", "sigma_nl_perp"]) for mink, maxk in [(0.02, 0.3), (0.02, 0.4), (0.02, 0.5), (0.03, 0.3), (0.03, 0.5), (0.03, 0.4), (0.04, 0.3), (0.04, 0.4), (0.04, 0.5)]: d = PowerSpectrum_DESIMockChallenge0_Z01(recon=r, isotropic=False, realisation="data", min_k=mink, max_k=maxk) fitter.add_model_and_dataset(model, d, name=f"B17 Fixed {t}, k = ({mink:0.2f}, {maxk:0.2f})") fitter.set_sampler(sampler) fitter.set_num_walkers(10) fitter.fit(file) if fitter.should_plot(): import logging
import logging if __name__ == "__main__": logging.basicConfig(level=logging.DEBUG, format="[%(levelname)7s |%(funcName)20s] %(message)s") logging.getLogger("matplotlib").setLevel(logging.ERROR) from barry.datasets.dataset_power_spectrum import PowerSpectrum_DESIMockChallenge0_Z01 from barry.models import PowerBeutler2017 from barry.models.model import Correction model = PowerBeutler2017(recon=False, isotropic=False, correction=Correction.NONE, fix_params=["om"]) dataset = PowerSpectrum_DESIMockChallenge0_Z01(recon=False, isotropic=False, realisation="data") data = dataset.get_data() for i in range(20): model.sanity_check(dataset, figname="desi_mock0_optimised_bestfit.png", niter=100) # print(likelihood) # # model.plot_default(dataset)
def __init__(self, name="Corr Beutler 2017", smooth_type="hinton2017", fix_params=("om"), smooth=False, correction=None): super().__init__(name, smooth_type, fix_params, smooth, correction=correction) self.parent = PowerBeutler2017(fix_params=fix_params, smooth_type=smooth_type, recon=True, smooth=smooth, correction=correction)
import logging from barry.models import PowerBeutler2017 if __name__ == "__main__": logging.basicConfig(level=logging.DEBUG, format="[%(levelname)7s |%(funcName)20s] %(message)s") logging.getLogger("matplotlib").setLevel(logging.ERROR) from barry.datasets import PowerSpectrum_SDSS_DR12_Z051 for recon in [True, False]: model = PowerBeutler2017(recon=recon, name=f"Beutler2017, recon={recon}") model_smooth = PowerBeutler2017(recon=recon, name=f"Beutler2017, recon={recon}", smooth=True) model.set_default("om", 0.31) model_smooth.set_default("om", 0.31) # Assuming the change from 0.675 to 0.68 is something we can ignore, or we can add h0 to the default parameters. dataset1 = PowerSpectrum_SDSS_DR12_Z051(name=f"SDSS recon={recon}", recon=recon) data1 = dataset1.get_data() # First comparison - the actual recon data model.set_data(data1) p, minv = model.optimize() model_smooth.set_data(data1) p2, minv2 = model_smooth.optimize() print(p) print(minv) model.plot(p, smooth_params=p2) # FINDINGS # Yes, no issue recovering SDSS mean to alpha=0.998
names = ["PreRecon", "PostRecon Julian RecIso", "PostRecon Julian RecSym", "PostRecon Martin RecIso", "PostRecon Martin RecSym"] # colors = ["#CAF270", "#CAF270", "#4AB482", "#1A6E73", "#232C3B"] colors = ["#CAF270", "#66C57F", "#219180", "#205C68", "#232C3B"] types = ["julian_reciso", "julian_reciso", "julian_recsym", "martin_reciso", "martin_recsym"] recons = [False, True, True, True, True] recon_types = ["None", "iso", "ani", "iso", "ani"] realisations = ["data", "data", "data", "data", "data"] for i, (name, type, recon, recon_type, realisation, color) in enumerate(zip(names, types, recons, recon_types, realisations, colors)): print(i, name, type, recon, recon_type, realisation) data = PowerSpectrum_DESILightcone_Mocks_Recon( isotropic=False, recon=recon, realisation=realisation, fit_poles=[0, 2], min_k=0.02, max_k=0.30, type=type ) model = PowerBeutler2017( recon=recon_type, isotropic=False, fix_params=["om"], poly_poles=[0, 2], correction=Correction.NONE, marg="full" ) fitter.add_model_and_dataset(model, data, name=name, color=color) fitter.set_sampler(sampler) fitter.set_num_walkers(5) fitter.fit(file) # Everything below is nasty plotting code ########################################################### if fitter.should_plot(): import logging logging.info("Creating plots") from chainconsumer import ChainConsumer
c = getCambGenerator() r_s = c.get_data()["r_s"] p = BAOExtractor(r_s) sampler = DynestySampler(temp_dir=dir_name, nlive=1000) fitter = Fitter(dir_name) cs = ["#262232", "#116A71", "#48AB75", "#D1E05B"] for r in [False]: t = "Recon" if r else "Prerecon" d = PowerSpectrum_DESIMockChallenge0_Z01(recon=r, isotropic=False, realisation="data") # Fix sigma_nl for one of the Beutler models model = PowerBeutler2017(recon=r, isotropic=False, correction=Correction.NONE) model.set_default("sigma_nl_par", 10.9) model.set_default("sigma_nl_perp", 5.98) model.set_fix_params(["om", "sigma_nl_par", "sigma_nl_perp"]) fitter.add_model_and_dataset(PowerBeutler2017(recon=r, isotropic=False, correction=Correction.NONE, fix_params=["om"]), d, name=f"Beutler 2017 {t}") fitter.add_model_and_dataset(model, d, name=f"Beutler 2017 Fixed $\\Sigma_{{nl}}$ {t}") # fitter.add_model_and_dataset(PowerSeo2016(recon=r, isotropic=False), d, name=f"Seo 2016 {t}", linestyle=ls, color=cs[1]) # fitter.add_model_and_dataset(PowerDing2018(recon=r, isotropic=False), d, name=f"Ding 2018 {t}", linestyle=ls, color=cs[2]) fitter.set_sampler(sampler) fitter.set_num_walkers(10) fitter.fit(file) if fitter.should_plot(): import logging
isotropic=False, fit_poles=[0, 1, 2], reduce_cov_factor=np.sqrt(2000.0)) d_hexa = PowerSpectrum_Beutler2019(recon=r, isotropic=False, fit_poles=[0, 2, 4], reduce_cov_factor=np.sqrt(2000.0)) d_all = PowerSpectrum_Beutler2019(recon=r, isotropic=False, fit_poles=[0, 1, 2, 3, 4], reduce_cov_factor=np.sqrt(2000.0)) # Fix sigma_nl for one of the Beutler models model_quad = PowerBeutler2017(recon=r, isotropic=False, fix_params=["om"], poly_poles=[0, 2], correction=Correction.HARTLAP, marg="full") model_odd = PowerBeutler2017(recon=r, isotropic=False, fix_params=["om"], poly_poles=[0, 1, 2], correction=Correction.HARTLAP, marg="full") model_hexa = PowerBeutler2017(recon=r, isotropic=False, fix_params=["om"], poly_poles=[0, 2, 4], correction=Correction.HARTLAP, marg="full") model_all = PowerBeutler2017(recon=r,
p = BAOExtractor(r_s) cs = ["#262232", "#116A71", "#48AB75", "#b7c742"] for r in [True]: t = "Recon" if r else "Prerecon" datae = PowerSpectrum_SDSS_DR12_Z061_NGC(recon=r, min_k=0.03, max_k=0.30, postprocess=p) for ls, n in zip(["-", ":"], ["", " (No Poly)"]): if n: fix = ["om", "f", "a1", "a2", "a3", "a4", "a5"] else: fix = ["om", "f"] fitter.add_model_and_dataset(PowerBeutler2017(postprocess=p, recon=r, fix_params=fix), datae, name=f"Beutler 2017{n}", linestyle=ls, color=cs[0]) fitter.add_model_and_dataset(PowerSeo2016(postprocess=p, recon=r, fix_params=fix), datae, name=f"Seo 2016{n}", linestyle=ls, color=cs[1]) fitter.add_model_and_dataset(PowerDing2018(postprocess=p, recon=r, fix_params=fix),
if __name__ == "__main__": pfn, dir_name, file = setup(__file__) sampler = DynestySampler(temp_dir=dir_name, nlive=1000) fitter = Fitter(dir_name) cs = ["#262232", "#116A71", "#48AB75", "#D1E05B"] d = PowerSpectrum_DESIMockChallenge_Handshake(min_k=0.005, max_k=0.3, isotropic=False, realisation="data", fit_poles=[0, 2]) fitter.add_model_and_dataset(PowerBeutler2017(isotropic=False), d, name=f"Cullan's Pk", color=cs[0]) # Re-do the desi fits, but now using the linear pk provided for the UNIT sim pklin = np.array( pd.read_csv( "../barry/data/desi_mock_challenge_post_recon/Pk_Planck15_Table4.txt", delim_whitespace=True, header=None)) model = PowerBeutler2017(isotropic=False) model.set_fix_params(["om"]) model.set_data(d.get_data()) model.kvals = pklin[:, 0] model.pksmooth = smooth(model.kvals, pklin[:, 1])
c = getCambGenerator() r_s = c.get_data()["r_s"] p = BAOExtractor(r_s) sampler = DynestySampler(temp_dir=dir_name, nlive=1000) fitter = Fitter(dir_name) cs = ["#262232", "#116A71", "#48AB75", "#D1E05B"] for r in [False]: t = "Recon" if r else "Prerecon" ls = "-" # if r else "--" d = PowerSpectrum_DESIMockChallenge0_Z01(recon=r, isotropic=False) # Fix sigma_nl for one of the Beutler models model = PowerBeutler2017(recon=r, isotropic=False) sigma_nl = 6.0 if r else 9.3 model.set_default("sigma_nl_par", 14.1) model.set_default("sigma_nl_perp", 2.64) model.set_fix_params(["om", "f", "sigma_nl_par", "sigma_nl_perp"]) fitter.add_model_and_dataset(PowerBeutler2017(recon=r, isotropic=False), d, name=f"Beutler 2017 {t}", linestyle=ls, color=cs[0]) fitter.add_model_and_dataset( model, d, name=f"Beutler 2017 Fixed $\\Sigma_{{nl}}$ {t}",
fitter = Fitter(dir_name) cs = ["#262232", "#116A71", "#48AB75", "#D1E05B"] d = PowerSpectrum_DESIMockChallenge_Handshake(min_k=0.005, max_k=0.3, isotropic=False, realisation="data", fit_poles=[0, 2]) d2 = PowerSpectrum_DESIMockChallenge_Handshake(min_k=0.005, max_k=0.3, isotropic=False, realisation="data", fit_poles=[0, 2, 4]) fitter.add_model_and_dataset(PowerBeutler2017(isotropic=False), d, name=r"$P_{0}$+P_{2}$", color=cs[0]) fitter.add_model_and_dataset( PowerBeutler2017(isotropic=False), d2, name=r"$P_{0}$+P_{2}+P_{4},\,No\,a_{4}\,poly$", color=cs[1]) fitter.add_model_and_dataset(PowerBeutler2017(isotropic=False, poly_poles=[0, 2, 4]), d2, name=r"$P_{0}$+P_{2}+P_{4}$", color=cs[2]) fitter.set_sampler(sampler)
isotropic=False, recon=recon, realisation="data", fit_poles=fit_poles, min_k=0.0075, max_k=kmax, num_mocks=998, smoothtype=smoothtype, covtype="analytic", tracer=tracer, ) model = PowerBeutler2017( recon=data.recon, isotropic=data.isotropic, marg="full", fix_params=["om", "beta"], poly_poles=fit_poles, correction=Correction.NONE, n_poly=n_poly, ) smoothnames = [" 5", " 10", " 15", " 20"] hexname = " Hexa " if 4 in fit_poles else " No-Hexa " polyname = "3-Poly " if n_poly == 3 else "5-Poly " name = (names[i] + recon + smoothnames[smoothtype - 1] + hexname + polyname + tracer + " " + str(r"$k_{max}=%3.2lf$" % kmax)) print(name) fitter.add_model_and_dataset(model, data, name=name) allnames.append(name) counter += 1
c = getCambGenerator() r_s = c.get_data()["r_s"] p = BAOExtractor(r_s) sampler = DynestySampler(temp_dir=dir_name, nlive=1000) fitter = Fitter(dir_name) cs = ["#262232", "#116A71", "#48AB75", "#D1E05B"] for r in [False]: t = "Recon" if r else "Prerecon" ls = "-" # if r else "--" d = PowerSpectrum_Beutler2019_Z061_SGC(recon=r, isotropic=False) # Fix sigma_nl for one of the Beutler models model = PowerBeutler2017(recon=r, isotropic=False) sigma_nl = 6.0 if r else 9.3 model.set_default("sigma_nl_par", 14.1) model.set_default("sigma_nl_perp", 2.64) model.set_fix_params(["om", "f", "sigma_nl_par", "sigma_nl_perp"]) fitter.add_model_and_dataset(PowerBeutler2017(recon=r, isotropic=False), d, name=f"Beutler 2017 {t}", linestyle=ls, color=cs[0]) fitter.add_model_and_dataset(model, d, name=f"Beutler 2017 Fixed $\\Sigma_{{nl}}$ {t}", linestyle=ls, color=cs[0]) fitter.add_model_and_dataset(PowerSeo2016(recon=r, isotropic=False), d, name=f"Seo 2016 {t}", linestyle=ls, color=cs[1]) fitter.add_model_and_dataset(PowerDing2018(recon=r, isotropic=False), d, name=f"Ding 2018 {t}", linestyle=ls, color=cs[2]) fitter.set_sampler(sampler) fitter.set_num_walkers(10) fitter.fit(file) if fitter.should_plot():
c = getCambGenerator() r_s = c.get_data()[0] p = BAOExtractor(r_s) sampler = DynestySampler(temp_dir=dir_name, nlive=200) for r in [True, False]: t = "Recon" if r else "Prerecon" ls = "-" if r else "--" d = PowerSpectrum_SDSS_DR12_Z061_NGC(recon=r, realisation=0) de = PowerSpectrum_SDSS_DR12_Z061_NGC(recon=r, postprocess=p, realisation=0) beutler_not_fixed = PowerBeutler2017(recon=r) beutler = PowerBeutler2017(recon=r) sigma_nl = 6.0 if r else 9.3 beutler.set_default("sigma_nl", sigma_nl) beutler.set_fix_params(["om", "sigma_nl"]) seo = PowerSeo2016(recon=r) ding = PowerDing2018(recon=r) noda = PowerNoda2019(recon=r, postprocess=p) for i in range(999): d.set_realisation(i) de.set_realisation(i) fitter.add_model_and_dataset( beutler_not_fixed,
sampler = DynestySampler(temp_dir=dir_name) fitter = Fitter(dir_name) cs = ["#262232", "#116A71", "#48AB75", "#D1E05B"] for r in [True, False]: t = "Recon" if r else "Prerecon" ls = "-" if r else "--" d = PowerSpectrum_SDSS_DR12_Z061_NGC(recon=r, min_k=0.03, max_k=0.21) de = PowerSpectrum_SDSS_DR12_Z061_NGC(recon=r, postprocess=p, min_k=0.03, max_k=0.21) # Fix sigma_nl for one of the Beutler models model = PowerBeutler2017(recon=r) sigma_nl = 6.0 if r else 9.3 model.set_default("sigma_nl", sigma_nl) model.set_fix_params(["om", "sigma_nl"]) fitter.add_model_and_dataset(PowerBeutler2017(recon=r), d, name=f"Beutler 2017 {t}", linestyle=ls, color=cs[0]) fitter.add_model_and_dataset( model, d, name=f"Beutler 2017 Fixed $\\Sigma_{{nl}}$ {t}", linestyle=ls, color=cs[0])
min_k=0.02, max_k=0.30, mocktype=mocktype, redshift_bin=z + 1, realisation=None, num_mocks=1000, ) # Set up the model we'll use. Fix Omega_m and beta. 5 polynomials (default) # for each of the fitted multipoles. Use full analytic marginalisation for speed # Apply the Hartlap correction to the covariance matrix. model = PowerBeutler2017( recon=dataset.recon, isotropic=dataset.isotropic, marg="full", fix_params=["om", "beta"], poly_poles=dataset.fit_poles, correction=Correction.HARTLAP, n_poly=5, ) # Create a unique name for the fit and add it to the list name = dataset.name + " mock mean" fitter.add_model_and_dataset(model, dataset, name=name) allnames.append(name) # Now add the individual realisations to the list for i in range(len(dataset.mock_data)): dataset.set_realisation(i) name = dataset.name + f" realisation {i}" fitter.add_model_and_dataset(model, dataset, name=name)
r_s = c.get_data()["r_s"] p = BAOExtractor(r_s) sampler = DynestySampler(temp_dir=dir_name, nlive=200) for r in [True]: # , False]: t = "Recon" if r else "Prerecon" ls = "-" if r else "--" d = PowerSpectrum_SDSS_DR12_Z061_NGC(recon=r, realisation=0) de = PowerSpectrum_SDSS_DR12_Z061_NGC(recon=r, postprocess=p, realisation=0) ding = PowerDing2018(recon=r) beutler = PowerBeutler2017(recon=r) sigma_nl = 6.0 beutler.set_default("sigma_nl", sigma_nl) beutler.set_fix_params(["om", "sigma_nl"]) beutler_extracted = PowerBeutler2017(recon=r, postprocess=p) beutler_extracted.set_default("sigma_nl", sigma_nl) beutler_extracted.set_fix_params(["om", "sigma_nl"]) ding_extracted = PowerDing2018(recon=r, postprocess=p) for i in range(999): d.set_realisation(i) de.set_realisation(i) fitter.add_model_and_dataset(ding, d, name=f"D18",
import sys sys.path.append("..") from barry.config import setup from barry.models import PowerBeutler2017 from barry.datasets import PowerSpectrum_SDSS_DR12_Z061_NGC from barry.samplers import DynestySampler from barry.fitter import Fitter if __name__ == "__main__": pfn, dir_name, file = setup(__file__) r = True models = [ PowerBeutler2017(recon=r, smooth_type="hinton2017", name="Hinton2017"), PowerBeutler2017(recon=r, smooth_type="eh1998", name="EH1998") ] data = PowerSpectrum_SDSS_DR12_Z061_NGC(name="Recon mean", recon=r, min_k=0.02, max_k=0.30) sampler = DynestySampler(temp_dir=dir_name) fitter = Fitter(dir_name) fitter.add_model_and_dataset(models[0], data, name="Hinton2017") fitter.add_model_and_dataset(models[1], data, name="EH1998") fitter.set_sampler(sampler) fitter.set_num_walkers(10) fitter.fit(file) if fitter.should_plot():
from barry.config import setup from barry.models import PowerSpectrumFit, PowerSeo2016, PowerBeutler2017, PowerDing2018, PowerNoda2019 from barry.samplers import DynestySampler from barry.fitter import Fitter if __name__ == "__main__": pfn, dir_name, file = setup(__file__) sampler = DynestySampler(temp_dir=dir_name, nlive=1000) fitter = Fitter(dir_name) cs = ["#262232", "#116A71", "#48AB75", "#D1E05B"] d = PowerSpectrum_DESIMockChallenge_Handshake(min_k=0.005, max_k=0.3, isotropic=False, realisation="data", fit_poles=[0, 2]) fitter.add_model_and_dataset(PowerBeutler2017(isotropic=False), d, name=f"Beutler 2017 Prerecon", color=cs[0]) fitter.add_model_and_dataset(PowerSeo2016(isotropic=False), d, name=f"Seo 2016 Prerecon", color=cs[1]) fitter.add_model_and_dataset(PowerDing2018(isotropic=False), d, name=f"Ding 2018 Prerecon", color=cs[2]) fitter.add_model_and_dataset(PowerNoda2019(isotropic=False), d, name=f"Noda 2019 Prerecon", color=cs[3]) fitter.set_sampler(sampler) fitter.set_num_walkers(10) fitter.fit(file) if fitter.should_plot(): import logging logging.info("Creating plots") res = fitter.load() from chainconsumer import ChainConsumer