csiborgtools/notebooks/match_observation/harry_clusters.ipynb
Richard Stiskalek 779f2e76ac
Calculate upglade redshifts (#128)
* Update redshift reading

* Add helio to CMB redshift

* Update imports

* Update nb

* Run for Quijote

* Add script

* Update

* Update .gitignore

* Update imports

* Add Peery estimator

* Add bulk flow scripts

* Update typs

* Add comment

* Add blank space

* Update submission script

* Update description

* Add barriers

* Update nb

* Update nb

* Rename script

* Move to old

* Update imports

* Add nb

* Update script

* Fix catalogue key

* Update script

* Update submit

* Update comment

* Update .gitignore

* Update nb

* Update for stationary obsrevers

* Update submission

* Add nb

* Add better verbose control

* Update nb

* Update submit

* Update nb

* Add SN errors

* Add draft of the script

* Update verbosity flags

* Add submission script

* Debug script

* Quickfix

* Remove comment

* Update nb

* Update submission

* Update nb

* Processed UPGLADE
2024-06-20 14:33:00 +01:00

12 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 [ ]: