Пример #1
0
 def __init__(self,
              name="Corr Ding 2018",
              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 = PowerDing2018(fix_params=fix_params,
                                 smooth_type=smooth_type,
                                 recon=recon,
                                 correction=correction)
Пример #2
0
    def __init__(
        self,
        name="Corr Ding 2018",
        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 = PowerDing2018(
            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)
        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(
                beutler,
Пример #4
0
    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)
        c.analysis.get_latex_table(filename=pfn + "_params.txt")
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
Пример #6
0
    c = getCambGenerator()
    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,
import logging

from barry.models import PowerDing2018

if __name__ == "__main__":
    logging.basicConfig(
        level=logging.DEBUG,
        format="[%(levelname)7s |%(funcName)20s]   %(message)s")
    logging.getLogger("matplotlib").setLevel(logging.ERROR)
    recon = False
    model1 = PowerDing2018(recon=recon, name=f"Ding2018, recon={recon}")
    model_smooth = PowerDing2018(recon=recon,
                                 name=f"Ding2018, 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=31.62,
                                                step_size=5)
    dataset2 = DummyPowerSpectrum_SDSS_DR12_Z061_NGC(
        name="Dummy data, real window fn",
        min_k=0.02,
        max_k=0.25,
        step_size=5,
        dummy_window=False)
    dataset3 = DummyPowerSpectrum_SDSS_DR12_Z061_NGC(name="DummyWindowFnToo",
Пример #8
0
                                     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])

    fitter.set_sampler(sampler)
    fitter.set_num_walkers(10)
    fitter.fit(file)

    if fitter.should_plot():
Пример #9
0
    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():
            c.add_chain(chain, weights=weight, parameters=model.get_labels(), **extra)
Пример #10
0
import numpy as np
import pandas as pd

# Check correlation between pk and xi results using recon Ding
if __name__ == "__main__":
    pfn, dir_name, file = setup(__file__)
    fitter = Fitter(dir_name, save_dims=2, remove_output=False)
    sampler = DynestySampler(temp_dir=dir_name, nlive=400)

    for r in [True]:
        t = "Recon" if r else "Prerecon"

        d_pk = PowerSpectrum_SDSS_DR12_Z061_NGC(recon=r, realisation=0)
        d_xi = CorrelationFunction_SDSS_DR12_Z061_NGC(recon=r, realisation=0)

        ding_pk = PowerDing2018(recon=r)
        ding_pk_smooth = PowerDing2018(recon=r, smooth=True)

        ding_xi = CorrDing2018(recon=r)
        ding_xi_smooth = CorrDing2018(recon=r, smooth=True)

        for i in range(999):
            d_pk.set_realisation(i)
            d_xi.set_realisation(i)

            fitter.add_model_and_dataset(
                ding_pk,
                d_pk,
                name=f"Ding 2018 $P(k)$, mock number {i}",
                linestyle="-",
                color="p",
            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)
Пример #12
0
                                     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