Esempio n. 1
0
sys.path.append("..")
from barry.config import setup
from barry.models import PowerNoda2019
from barry.datasets import PowerSpectrum_SDSS_DR12_Z061_NGC
from barry.postprocessing import BAOExtractor
from barry.cosmology.camb_generator import getCambGenerator
from barry.samplers import DynestySampler
from barry.fitter import Fitter

if __name__ == "__main__":
    pfn, dir_name, file = setup(__file__)

    c = getCambGenerator()
    r_s = c.get_data()[0]

    postprocess = BAOExtractor(r_s)

    sampler = DynestySampler(temp_dir=dir_name)
    fitter = Fitter(dir_name)

    for r in [True, False]:
        rt = "Recon" if r else "Prerecon"
        data = PowerSpectrum_SDSS_DR12_Z061_NGC(recon=r,
                                                postprocess=postprocess)
        n = PowerNoda2019(postprocess=postprocess,
                          recon=r,
                          nonlinear_type="spt")
        n2 = PowerNoda2019(postprocess=postprocess,
                           recon=r,
                           nonlinear_type="halofit")
Esempio n. 2
0
from barry.utils import weighted_avg_and_std
from barry.datasets.dataset_power_spectrum import PowerSpectrum_DESIMockChallenge0_Z01
from barry.cosmology.camb_generator import getCambGenerator
from barry.postprocessing import BAOExtractor
from barry.config import setup
from barry.models import PowerBeutler2017
from barry.samplers import DynestySampler
from barry.fitter import Fitter
from barry.models.model import Correction

if __name__ == "__main__":
    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"])
Esempio n. 3
0
from barry.datasets import PowerSpectrum_SDSS_DR12_Z061_NGC
from barry.postprocessing import BAOExtractor
from barry.cosmology.camb_generator import CambGenerator
from barry.samplers import DynestySampler
from barry.fitter import Fitter

if __name__ == "__main__":
    pfn, dir_name, file = setup(__file__)

    c = CambGenerator()
    r_s = c.get_data()[0]

    fitter = Fitter(dir_name)

    ps = [
        BAOExtractor(r_s, extra_ks=(0.095, 0.13)),
        BAOExtractor(r_s, extra_ks=(0.095, 0.14)),
        BAOExtractor(r_s, extra_ks=(0.095, 0.15)),
        BAOExtractor(r_s, extra_ks=(0.095, 0.16)),
        BAOExtractor(r_s, extra_ks=(0.095, 0.17)),
        BAOExtractor(r_s, extra_ks=(0.095, 0.18)),
        BAOExtractor(r_s, extra_ks=(0.095, 0.19)),
        BAOExtractor(r_s, extra_ks=(0.095, 0.20)),
        BAOExtractor(r_s, extra_ks=(0.095, 0.21)),
        BAOExtractor(r_s, extra_ks=(0.095, 0.22)),
        BAOExtractor(r_s, extra_ks=(0.095, 0.23)),
        BAOExtractor(r_s, extra_ks=(0.095, 0.24)),
    ]

    recon = True
    for p in ps:
                cov[i, j] = pk_cov[i, j]
    return cov


if __name__ == "__main__":
    import seaborn as sb
    import matplotlib.pyplot as plt

    logging.basicConfig(
        level=logging.INFO,
        format="[%(levelname)7s |%(funcName)18s]   %(message)s")
    logging.getLogger("matplotlib").setLevel(logging.WARNING)

    camb = getCambGenerator()
    r_s = c.get_data()[0]
    extractor = BAOExtractor(r_s, reorder=False)
    extractor2 = PureBAOExtractor(r_s)

    step_size = 1
    mink = 0.02
    maxk = 0.3
    data_raw = PowerSpectrum_SDSS_DR12_Z061_NGC(step_size=step_size,
                                                fake_diag=False,
                                                min_k=0.0,
                                                max_k=0.32)
    data2 = PowerSpectrum_SDSS_DR12_Z061_NGC(postprocess=extractor,
                                             step_size=step_size,
                                             min_k=mink,
                                             max_k=maxk)

    ks = data_raw.ks
Esempio n. 5
0
import logging
from barry.cosmology.camb_generator import getCambGenerator
from barry.datasets import PowerSpectrum_SDSS_DR12_Z061_NGC
from barry.models import PowerNoda2019
from barry.postprocessing import BAOExtractor

if __name__ == "__main__":
    logging.basicConfig(
        level=logging.DEBUG,
        format="[%(levelname)7s |%(funcName)20s]   %(message)s")
    logging.getLogger("matplotlib").setLevel(logging.ERROR)

    c = getCambGenerator()
    r_s = c.get_data()["r_s"]

    postprocess = BAOExtractor(r_s, mink=0.15)

    for recon in [True, False]:

        model1 = PowerNoda2019(recon=recon,
                               name=f"Noda2019, recon={recon}",
                               postprocess=postprocess,
                               fix_params=["om", "f", "gamma"])
        dataset1 = PowerSpectrum_SDSS_DR12_Z061_NGC(recon=recon,
                                                    postprocess=postprocess,
                                                    min_k=0.03,
                                                    max_k=0.15)
        data1 = dataset1.get_data()
        print(list(data1[0].keys()))
        print(data1[0]["ks_output"])
        exit()
Esempio n. 6
0
from barry.datasets import PowerSpectrum_SDSS_DR12_Z061_NGC
from barry.postprocessing import BAOExtractor
from barry.cosmology.camb_generator import CambGenerator
from barry.samplers import DynestySampler
from barry.fitter import Fitter

if __name__ == "__main__":
    pfn, dir_name, file = setup(__file__)

    c = CambGenerator()
    r_s = c.get_data()[0]

    fitter = Fitter(dir_name)

    ps = [
        BAOExtractor(r_s, mink=0.03),
        BAOExtractor(r_s, mink=0.04),
        BAOExtractor(r_s, mink=0.05),
        BAOExtractor(r_s, mink=0.06),
        BAOExtractor(r_s, mink=0.07)
    ]

    recon = True
    for p in ps:
        n = f"$k = {p.mink:0.2f}\, h / {{\\rm Mpc}}$"
        model = PowerNoda2019(postprocess=p, recon=recon)
        data = PowerSpectrum_SDSS_DR12_Z061_NGC(min_k=0.02,
                                                max_k=0.30,
                                                postprocess=p,
                                                recon=recon)
        fitter.add_model_and_dataset(model, data, name=n)
Esempio n. 7
0
            pk1d = integrate.simps(pk_smooth * (kaiser_prefac ** 2 + pk_nonlinear), self.mu, axis=0)
        else:
            # Compute the BAO damping/propagator
            propagator = self.get_damping(growth, om, gamma)
            pk1d = integrate.simps(pk_smooth * ((1.0 + pk_ratio * propagator) * kaiser_prefac ** 2 + pk_nonlinear), self.mu, axis=0)

        return ks, pk1d


if __name__ == "__main__":
    import sys

    sys.path.append("../..")
    from barry.datasets.dataset_power_spectrum import PowerSpectrum_SDSS_DR12_Z061_NGC
    from barry.postprocessing import BAOExtractor
    from barry.config import setup_logging

    setup_logging()

    postprocess = BAOExtractor(147.6)

    print("Checking pre-recon")
    dataset = PowerSpectrum_SDSS_DR12_Z061_NGC(recon=False, postprocess=postprocess)
    model_pre = PowerNoda2019(recon=False, postprocess=postprocess)
    model_pre.sanity_check(dataset)

    print("Checking post-recon")
    dataset = PowerSpectrum_SDSS_DR12_Z061_NGC(recon=True, postprocess=postprocess)
    model_post = PowerNoda2019(recon=True, postprocess=postprocess)
    model_post.sanity_check(dataset)
Esempio n. 8
0
from barry.config import setup
from barry.models import PowerNoda2019
from barry.datasets import PowerSpectrum_SDSS_DR12_Z061_NGC
from barry.postprocessing import BAOExtractor, PureBAOExtractor
from barry.cosmology.camb_generator import getCambGenerator
from barry.samplers import DynestySampler
from barry.fitter import Fitter
import numpy as np

if __name__ == "__main__":
    pfn, dir_name, file = setup(__file__)

    c = getCambGenerator()
    r_s = c.get_data()["r_s"]

    postprocess = BAOExtractor(r_s)
    r = True
    model = PowerNoda2019(postprocess=postprocess, recon=r, name="")
    mink = 0.03
    maxk = 0.30
    datas = [
        PowerSpectrum_SDSS_DR12_Z061_NGC(name="Mock covariance",
                                         recon=r,
                                         min_k=mink,
                                         max_k=maxk,
                                         postprocess=postprocess),
        PowerSpectrum_SDSS_DR12_Z061_NGC(name="Nishimichi, full",
                                         recon=r,
                                         min_k=mink,
                                         max_k=maxk,
                                         postprocess=postprocess),
Esempio n. 9
0
from barry.config import setup
from barry.models import PowerSeo2016, PowerBeutler2017, PowerDing2018
from barry.samplers import DynestySampler, EnsembleSampler
from barry.fitter import Fitter
from barry.models.model import Correction

# Check to see if including the hexadecapole or higher order multipoles gives tighter constraints on BAO parameters
# when fitting the mock average

if __name__ == "__main__":
    pfn, dir_name, file = setup(__file__)
    # dir_name = dir_name + "nlive_1500/"

    c = getCambGenerator()
    r_s = c.get_data()["r_s"]
    p = BAOExtractor(r_s)

    sampler = DynestySampler(temp_dir=dir_name, nlive=500)
    # sampler = EnsembleSampler(temp_dir=dir_name, num_steps=5000)
    fitter = Fitter(dir_name)

    cs = ["#262232", "#116A71", "#48AB75", "#D1E05B"]

    for r in [True]:
        t = "Recon" if r else "Prerecon"
        ls = "-"  # if r else "--"
        d_quad = PowerSpectrum_Beutler2019(recon=r,
                                           isotropic=False,
                                           fit_poles=[0, 2],
                                           reduce_cov_factor=np.sqrt(2000.0))
        d_odd = PowerSpectrum_Beutler2019(recon=r,