Example #1
0
import logging
from barry.models import CorrBeutler2017

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 CorrelationFunction_SDSS_DR12_Z061_NGC

    for recon in [True, False]:
        dataset1 = CorrelationFunction_SDSS_DR12_Z061_NGC(recon=recon)
        data1 = dataset1.get_data()

        # Run on mean
        model = CorrBeutler2017(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 5.0
        # Prerecon 8.0
import logging

from barry.models import CorrBeutler2017

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 CorrelationFunction_SDSS_DR12_Z061_NGC

    for recon in [True, False]:
        model = CorrBeutler2017()
        model_smooth = CorrBeutler2017(smooth=True)

        dataset1 = CorrelationFunction_SDSS_DR12_Z061_NGC(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.98 (postrecon) and 1.007 (prerecon)
Example #3
0
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, remove_output=False)

    cs = ["#262232", "#116A71", "#48AB75", "#D1E05B"]
    for r in [True, False]:
        t = "Recon" if r else "Prerecon"
        ls = "-" if r else "--"
        d = CorrelationFunction_SDSS_DR12_Z061_NGC(recon=r)

        # Fix sigma_nl for one of the Beutler models
        model = CorrBeutler2017()
        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(CorrBeutler2017(), 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(CorrSeo2016(recon=r), d, name=f"Seo 2016 {t}", linestyle=ls, color=cs[1])
        fitter.add_model_and_dataset(CorrDing2018(recon=r), d, name=f"Ding 2018 {t}", linestyle=ls, color=cs[2])

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

    if fitter.should_plot():
        import logging
Example #4
0
    r_s = c.get_data()[0]
    p = BAOExtractor(r_s)

    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 = CorrelationFunction_SDSS_DR12_Z061_NGC(recon=r,
                                                   min_dist=20,
                                                   max_dist=250)

        # Fix sigma_nl for one of the Beutler models
        model = CorrBeutler2017()
        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(CorrBeutler2017(),
                                     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])
Example #5
0
                fit_poles=[0, 2, 4],
                min_dist=50.0,
                max_dist=170.0,
                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 = CorrBeutler2017(
                recon=dataset.recon,
                isotropic=dataset.isotropic,
                marg="full",
                fix_params=["om", "beta"],
                poly_poles=dataset.fit_poles,
                correction=Correction.HARTLAP,
            )

            # 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)
                allnames.append(name)
    model.set_data(data.get_data())
    model.kvals = pklin[:, 0]
    model.pksmooth = smooth(model.kvals, pklin[:, 1])
    model.pkratio = pklin[:, 1] / model.pksmooth - 1.0

    # Power spectrum

    ls = "-"
    names = [f"Xinyi-std Pk", f"Pedro-std Pk", f"Baojiu-std Pk", f"Xinyi-Hada Pk", f"Hee-Jong-std Pk", f"Yu-Yu-std Pk", f"Javier-std Pk"]
    for i in range(7):
        data.set_realisation(i)
        fitter.add_model_and_dataset(model, data, name=names[i], color=cs[i], realisation=i, ls=ls)

    # Correlation Function
    data = CorrelationFunction_DESIMockChallenge(recon=True, isotropic=False, fit_poles=[0, 2])
    model = CorrBeutler2017(recon=True, isotropic=False, fix_params=["om"], poly_poles=[0, 2], correction=Correction.NONE, marg="full")

    ls = "--"
    names = [f"Xinyi-std Xi", f"Pedro-std Xi", f"Baojiu-std Xi", f"Xinyi-Hada Xi", f"Hee-Jong-std Xi", f"Yu-Yu-std Xi", f"Javier-std Xi"]
    for i in range(7):
        data.set_realisation(i)
        fitter.add_model_and_dataset(model, data, name=names[i], color=cs[i], realisation=i, ls=ls)

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

    # Everything below is nasty plotting code ###########################################################
    if fitter.should_plot():
        import logging
Example #7
0
import pandas as pd


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=200)
    c4 = ["#262232", "#116A71", "#48AB75", "#D1E05B"]

    for r in [True, False]:
        t = "Recon" if r else "Prerecon"
        ls = "-" if r else "--"

        d = CorrelationFunction_SDSS_DR12_Z061_NGC(recon=r, realisation=0)

        beutler_not_fixed = CorrBeutler2017()
        beutler = CorrBeutler2017()
        sigma_nl = 5.0 if r else 8.0
        beutler.set_default("sigma_nl", sigma_nl)
        beutler.set_fix_params(["om", "sigma_nl"])

        seo = CorrSeo2016(recon=r)
        ding = CorrDing2018(recon=r)

        for i in range(999):
            d.set_realisation(i)
            fitter.add_model_and_dataset(beutler_not_fixed, d, name=f"Beutler 2017 {t}, mock number {i}", linestyle=ls, color=c4[0], realisation=i)
            fitter.add_model_and_dataset(beutler, d, name=f"Beutler 2017 Fixed $\\Sigma_{{nl}}$ {t}, mock number {i}", linestyle=ls, color=c4[0], realisation=i)
            fitter.add_model_and_dataset(seo, d, name=f"Seo 2016 {t}, mock number {i}", linestyle=ls, color=c4[1], realisation=i)
            fitter.add_model_and_dataset(ding, d, name=f"Ding 2018 {t}, mock number {i}", linestyle=ls, color=c4[2], realisation=i)
Example #8
0
                    data = CorrelationFunction_DESIMockChallenge_Post(
                        isotropic=False,
                        recon=recon,
                        realisation="data",
                        fit_poles=fit_poles,
                        min_dist=smin,
                        max_dist=157.5,
                        num_mocks=998,
                        smoothtype=smoothtype,
                        covtype="nonfix",
                        tracer="elg",
                    )
                    model = CorrBeutler2017(
                        recon=data.recon,
                        isotropic=data.isotropic,
                        marg="full",
                        fix_params=["om", "beta"],
                        poly_poles=fit_poles,
                        correction=Correction.NONE,
                    )
                    smoothnames = [" 5", " 10", " 15"]
                    hexname = " Hexa " if 4 in fit_poles else " No-Hexa "
                    name = names[i] + recon + smoothnames[
                        smoothtype - 1] + hexname + str(
                            r"$s_{min}=%3.1lf$" % smin)
                    allnames.append(name)
                    fitter.add_model_and_dataset(model, data, name=name)
                    counter += 1

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