예제 #1
0
    def __init__(
        self,
        name="Corr Seo 2016",
        fix_params=("om", "beta"),
        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"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 = PowerSeo2016(
            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"a{{{pole}}}_1", 0.0)
                self.set_default(f"a{{{pole}}}_2", 0.0)
                self.set_default(f"a{{{pole}}}_3", 0.0)
예제 #2
0
 def __init__(self,
              name="Corr Seo 2016",
              recon=False,
              smooth_type="hinton2017",
              fix_params=("om", "f"),
              smooth=False,
              correction=None):
     self.recon = recon
     self.recon_smoothing_scale = None
     super().__init__(name=name,
                      fix_params=fix_params,
                      smooth_type=smooth_type,
                      smooth=smooth,
                      correction=correction)
     self.parent = PowerSeo2016(fix_params=fix_params,
                                smooth_type=smooth_type,
                                recon=recon,
                                smooth=smooth,
                                correction=correction)
import logging
from barry.models import PowerSeo2016

if __name__ == "__main__":
    logging.basicConfig(
        level=logging.DEBUG,
        format="[%(levelname)7s |%(funcName)20s]   %(message)s")
    logging.getLogger("matplotlib").setLevel(logging.ERROR)
    recon = True
    model1 = PowerSeo2016(recon=recon, name=f"Seo2016, recon={recon}")
    model_smooth = PowerSeo2016(recon=recon,
                                name=f"Seo2016, recon={recon}",
                                smooth=True)

    from barry.datasets import PowerSpectrum_SDSS_DR12_Z061_NGC
    from barry.datasets import DummyPowerSpectrum_SDSS_DR12_Z061_NGC

    dataset1 = PowerSpectrum_SDSS_DR12_Z061_NGC(name="Recon mean",
                                                recon=recon,
                                                min_k=0.02,
                                                max_k=0.3,
                                                reduce_cov_factor=30,
                                                step_size=5)
    dataset2 = DummyPowerSpectrum_SDSS_DR12_Z061_NGC(
        name="Dummy data, real window fn",
        min_k=0.02,
        max_k=0.25,
        dummy_window=False)
    dataset3 = DummyPowerSpectrum_SDSS_DR12_Z061_NGC(name="DummyWindowFnToo",
                                                     min_k=0.02,
                                                     max_k=0.25,
    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,
                d,
                name=f"Beutler 2017 {t}, mock number {i}",
                linestyle=ls,
                color="p",
                realisation=i)
            fitter.add_model_and_dataset(
예제 #5
0
    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)
        c.configure(shade=True, bins=30, legend_artists=True)
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
        import copy
예제 #7
0
        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])
        fitter.add_model_and_dataset(PowerSeo2016(recon=r),
                                     d,
                                     name=f"Seo 2016 {t}",
                                     linestyle=ls,
                                     color=cs[1])
        fitter.add_model_and_dataset(PowerDing2018(recon=r),
                                     d,
                                     name=f"Ding 2018 {t}",
                                     linestyle=ls,
                                     color=cs[2])
        fitter.add_model_and_dataset(PowerNoda2019(recon=r, postprocess=p),
                                     de,
                                     name=f"Noda 2019 {t}",
                                     linestyle=ls,
                                     color=cs[3])
예제 #8
0
파일: pk_avg_2d.py 프로젝트: npadmana/Barry
    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():
        import logging

        logging.info("Creating plots")

        from chainconsumer import ChainConsumer

        c = ChainConsumer()
        for posterior, weight, chain, evidence, model, data, extra in fitter.load():
                                          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",
예제 #10
0
        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():