csiborgtools/notebooks/MAH/mah.ipynb
Richard Stiskalek ee222cd010
Fix overlap runs (#125)
* Update nb

* Update script

* Update script

* Rename

* Update script

* Update script

* Remove warning

* Ignore minors when extracting MAH

* Fix paths bug

* Move notebooks

* Move files

* Rename and delete things

* Rename file

* Move file

* Rename things

* Remove old print statement

* Add basic MAH plot

* Add random MAH path

* Output snapshot numbers

* Add MAH random extraction

* Fix redshift bug

* Edit script

* Add extracting random MAH

* Little updates

* Add CB2 redshift

* Add some caching

* Add diagnostic plots

* Add caching

* Minor updates

* Update nb

* Update notebook

* Update script

* Add Sorce randoms

* Add CB2 varysmall

* Update nb

* Update nb

* Update nb

* Use catalogue HMF

* Move definition of radec2galactic

* Update nb

* Update import

* Update import

* Add galatic coords to catalogues

* Update nb
2024-04-08 11:23:21 +02:00

390 KiB

In [ ]:
# Copyright (C) 2024 Richard Stiskalek
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
from os.path import exists
import numpy as np
import matplotlib.pyplot as plt
from corner import corner
from getdist import plots
import scienceplots
from os.path import exists
import seaborn as sns


from reconstruction_comparison import *

%load_ext autoreload
%autoreload 2
%matplotlib inline

paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)
fdir = "/mnt/extraspace/rstiskalek/csiborg_postprocessing/peculiar_velocity"

Quick checks

In [ ]:
catalogue = "CF4_TFR_i"
simname = "IndranilVoid_exp"
zcmb_max=0.05
sample_beta = None
no_Vext = True

fname = paths.flow_validation(
    fdir, simname, catalogue, inference_method="bayes",
    sample_alpha=False, sample_beta=sample_beta,
    no_Vext=no_Vext, zcmb_max=zcmb_max)
In [ ]:
X = samples_to_getdist(get_samples(fname, False), "Test")
In [ ]:
params = ["rLG", "sigma_v"]


# params = ["beta", f"a_{catalogue}", f"b_{catalogue}", f"e_mu_{catalogue}"]
# params = ["Vmag", "l", "b", "sigma_v", "beta", f"mag_cal_{catalogue}", f"alpha_cal_{catalogue}", f"beta_cal_{catalogue}", f"e_mu_{catalogue}"]

with plt.style.context("science"):
    g = plots.get_subplot_plotter()
    g.settings.figure_legend_frame = False
    g.settings.alpha_filled_add = 0.75
    
    g.triangle_plot(X, params=params, filled=True, legend_loc='upper right')
    plt.gcf().suptitle(catalogue_to_pretty(catalogue), y=1.025)
    plt.gcf().tight_layout()
    plt.gcf().show()
    # plt.gcf().savefig(f"../../plots/method_comparison_{simname}_{catalogue}.png", dpi=500, bbox_inches='tight')
In [ ]:
# catalogue = ["LOSS", "Foundation"]
catalogue = "CF4_TFR_i"
simname = "IndranilVoid_exp"
zcmb_max = 0.05
sample_alpha = False

fname = paths.flow_validation(
    fdir, simname, catalogue, inference_method="mike",
    sample_mag_dipole=True,
    sample_beta=False,
    sample_alpha=sample_alpha, zcmb_max=zcmb_max)


samples = get_samples(fname, convert_Vext_to_galactic=True)

samples, labels, keys = samples_for_corner(samples)
fig = corner(samples, labels=labels, show_titles=True,
             title_kwargs={"fontsize": 12}, smooth=1)
# fig.savefig("../../plots/test.png", dpi=250)
fig.show()

Paper plots

1. No $V_{\rm ext}$ and no $\beta$

In [ ]:
for simname in ["IndranilVoid_exp", "IndranilVoid_gauss", "IndranilVoid_mb"]:
    X = []
    for catalogue in ["2MTF", "SFI_gals", "CF4_TFR_i", "CF4_TFR_w1"]:

        fname = paths.flow_validation(
            fdir, simname, catalogue, inference_method="bayes",
            sample_alpha=False, sample_beta=None,
            no_Vext=True, zcmb_max=0.05)

        X_i = samples_to_getdist(get_samples(fname, False), catalogue_to_pretty(catalogue))
        X.append(X_i)

    params = ["rLG", "sigma_v"]
    with plt.style.context("science"):
        g = plots.get_subplot_plotter()
        g.settings.figure_legend_frame = False
        g.settings.alpha_filled_add = 0.75

        g.triangle_plot(X, params=params, filled=True, legend_loc='upper right')
        plt.gcf().suptitle(simname_to_pretty(simname), y=1.025)
        plt.gcf().tight_layout()
        plt.gcf().show()
        plt.gcf().savefig(f"../../plots/void_{simname}_noVext_nobeta.png", dpi=500, bbox_inches='tight')

2. No $V_{\rm ext}$ but sampling $\beta$

In [ ]:
for simname in ["IndranilVoid_exp", "IndranilVoid_gauss", "IndranilVoid_mb"]:
    X = []
    for catalogue in ["2MTF", "SFI_gals", "CF4_TFR_i", "CF4_TFR_w1"]:

        fname = paths.flow_validation(
            fdir, simname, catalogue, inference_method="bayes",
            sample_alpha=False, sample_beta=True,
            no_Vext=True, zcmb_max=0.05)

        X_i = samples_to_getdist(get_samples(fname, False), catalogue_to_pretty(catalogue))
        X.append(X_i)

    params = ["rLG", "sigma_v", "beta"]
    with plt.style.context("science"):
        g = plots.get_subplot_plotter()
        g.settings.figure_legend_frame = False
        g.settings.alpha_filled_add = 0.75

        g.triangle_plot(X, params=params, filled=True, legend_loc='upper right')
        plt.gcf().suptitle(simname_to_pretty(simname), y=1.025)
        plt.gcf().tight_layout()
        plt.gcf().show()
        plt.gcf().savefig(f"../../plots/void_{simname}_noVext_beta.png", dpi=500, bbox_inches='tight')

3. Yes $V_{\rm ext}$ and no $\beta$

In [ ]:
for simname in ["IndranilVoid_exp", "IndranilVoid_gauss", "IndranilVoid_mb"]:
    X = []
    for catalogue in ["2MTF", "SFI_gals", "CF4_TFR_i", "CF4_TFR_w1"]:

        fname = paths.flow_validation(
            fdir, simname, catalogue, inference_method="bayes",
            sample_alpha=False, sample_beta=False,
            no_Vext=None, zcmb_max=0.05)

        X_i = samples_to_getdist(get_samples(fname, False), catalogue_to_pretty(catalogue))
        X.append(X_i)

    params = ["rLG", "sigma_v", "Vx", "Vy", "Vz"]
    with plt.style.context("science"):
        g = plots.get_subplot_plotter()
        g.settings.figure_legend_frame = False
        g.settings.alpha_filled_add = 0.75

        g.triangle_plot(X, params=params, filled=True, legend_loc='upper right')
        plt.gcf().suptitle(simname_to_pretty(simname), y=1.025)
        plt.gcf().tight_layout()
        plt.gcf().show()
        plt.gcf().savefig(f"../../plots/void_{simname}_Vext_nobeta.png", dpi=500, bbox_inches='tight')

4. Yes $V_{\rm ext}$ and yes $\beta$

In [ ]:
for simname in ["IndranilVoid_exp", "IndranilVoid_gauss", "IndranilVoid_mb"]:
    X = []
    for catalogue in ["2MTF", "SFI_gals", "CF4_TFR_i", "CF4_TFR_w1"]:

        fname = paths.flow_validation(
            fdir, simname, catalogue, inference_method="bayes",
            sample_alpha=False, sample_beta=True,
            no_Vext=None, zcmb_max=0.05)

        X_i = samples_to_getdist(get_samples(fname, False), catalogue_to_pretty(catalogue))
        X.append(X_i)

    params = ["rLG", "sigma_v", "beta", "Vx", "Vy", "Vz"]
    with plt.style.context("science"):
        g = plots.get_subplot_plotter()
        g.settings.figure_legend_frame = False
        g.settings.alpha_filled_add = 0.75

        g.triangle_plot(X, params=params, filled=True, legend_loc='upper right')
        plt.gcf().suptitle(simname_to_pretty(simname), y=1.025)
        plt.gcf().tight_layout()
        plt.gcf().show()
        plt.gcf().savefig(f"../../plots/void_{simname}_Vext_beta.png", dpi=500, bbox_inches='tight')

5. $V_{\rm ext}$ along the model axis and $\beta = 1$

In [ ]:
for simname in ["IndranilVoid_exp", "IndranilVoid_gauss", "IndranilVoid_mb"]:
    X = []
    for catalogue in ["2MTF", "SFI_gals", "CF4_TFR_i", "CF4_TFR_w1"]:

        fname = paths.flow_validation(
            fdir, simname, catalogue, inference_method="bayes",
            sample_alpha=False, sample_beta=None,
            no_Vext=True, zcmb_max=0.05, sample_Vmag_vax=True)
        
        X_i = samples_to_getdist(get_samples(fname, False), catalogue_to_pretty(catalogue))
        X.append(X_i)

    params = ["rLG", "sigma_v", "Vext_axis_mag"]
    with plt.style.context("science"):
        g = plots.get_subplot_plotter()
        g.settings.figure_legend_frame = False
        g.settings.alpha_filled_add = 0.75

        g.triangle_plot(X, params=params, filled=True, legend_loc='upper right')
        plt.gcf().suptitle(simname_to_pretty(simname), y=1.025)
        plt.gcf().tight_layout()
        plt.gcf().show()
        plt.gcf().savefig(f"../../plots/void_{simname}_Vext_along_axis_no_beta.png", dpi=500, bbox_inches='tight')
In [ ]: