diff --git a/notebooks/flow/void_test.ipynb b/notebooks/flow/void_test.ipynb new file mode 100644 index 0000000..fb057fa --- /dev/null +++ b/notebooks/flow/void_test.ipynb @@ -0,0 +1,336 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "# Copyright (C) 2024 Richard Stiskalek\n", + "# This program is free software; you can redistribute it and/or modify it\n", + "# under the terms of the GNU General Public License as published by the\n", + "# Free Software Foundation; either version 3 of the License, or (at your\n", + "# option) any later version.\n", + "#\n", + "# This program is distributed in the hope that it will be useful, but\n", + "# WITHOUT ANY WARRANTY; without even the implied warranty of\n", + "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General\n", + "# Public License for more details.\n", + "#\n", + "# You should have received a copy of the GNU General Public License along\n", + "# with this program; if not, write to the Free Software Foundation, Inc.,\n", + "# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n", + "from os.path import exists\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "from corner import corner\n", + "from getdist import plots\n", + "import scienceplots\n", + "from os.path import exists\n", + "import seaborn as sns\n", + "\n", + "\n", + "from reconstruction_comparison import *\n", + "\n", + "%load_ext autoreload\n", + "%autoreload 2\n", + "%matplotlib inline\n", + "\n", + "paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)\n", + "fdir = \"/mnt/extraspace/rstiskalek/csiborg_postprocessing/peculiar_velocity\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Quick checks" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "catalogue = \"CF4_TFR_i\"\n", + "simname = \"IndranilVoid_exp\"\n", + "zcmb_max=0.05\n", + "sample_beta = None\n", + "no_Vext = True\n", + "\n", + "fname = paths.flow_validation(\n", + " fdir, simname, catalogue, inference_method=\"bayes\",\n", + " sample_alpha=False, sample_beta=sample_beta,\n", + " no_Vext=no_Vext, zcmb_max=zcmb_max)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "X = samples_to_getdist(get_samples(fname, False), \"Test\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "params = [\"rLG\", \"sigma_v\"]\n", + "\n", + "\n", + "# params = [\"beta\", f\"a_{catalogue}\", f\"b_{catalogue}\", f\"e_mu_{catalogue}\"]\n", + "# params = [\"Vmag\", \"l\", \"b\", \"sigma_v\", \"beta\", f\"mag_cal_{catalogue}\", f\"alpha_cal_{catalogue}\", f\"beta_cal_{catalogue}\", f\"e_mu_{catalogue}\"]\n", + "\n", + "with plt.style.context(\"science\"):\n", + " g = plots.get_subplot_plotter()\n", + " g.settings.figure_legend_frame = False\n", + " g.settings.alpha_filled_add = 0.75\n", + " \n", + " g.triangle_plot(X, params=params, filled=True, legend_loc='upper right')\n", + " plt.gcf().suptitle(catalogue_to_pretty(catalogue), y=1.025)\n", + " plt.gcf().tight_layout()\n", + " plt.gcf().show()\n", + " # plt.gcf().savefig(f\"../../plots/method_comparison_{simname}_{catalogue}.png\", dpi=500, bbox_inches='tight')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# catalogue = [\"LOSS\", \"Foundation\"]\n", + "catalogue = \"CF4_TFR_i\"\n", + "simname = \"IndranilVoid_exp\"\n", + "zcmb_max = 0.05\n", + "sample_alpha = False\n", + "\n", + "fname = paths.flow_validation(\n", + " fdir, simname, catalogue, inference_method=\"mike\",\n", + " sample_mag_dipole=True,\n", + " sample_beta=False,\n", + " sample_alpha=sample_alpha, zcmb_max=zcmb_max)\n", + "\n", + "\n", + "samples = get_samples(fname, convert_Vext_to_galactic=True)\n", + "\n", + "samples, labels, keys = samples_for_corner(samples)\n", + "fig = corner(samples, labels=labels, show_titles=True,\n", + " title_kwargs={\"fontsize\": 12}, smooth=1)\n", + "# fig.savefig(\"../../plots/test.png\", dpi=250)\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Paper plots" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 1. No $V_{\\rm ext}$ and no $\\beta$" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for simname in [\"IndranilVoid_exp\", \"IndranilVoid_gauss\", \"IndranilVoid_mb\"]:\n", + " X = []\n", + " for catalogue in [\"2MTF\", \"SFI_gals\", \"CF4_TFR_i\", \"CF4_TFR_w1\"]:\n", + "\n", + " fname = paths.flow_validation(\n", + " fdir, simname, catalogue, inference_method=\"bayes\",\n", + " sample_alpha=False, sample_beta=None,\n", + " no_Vext=True, zcmb_max=0.05)\n", + "\n", + " X_i = samples_to_getdist(get_samples(fname, False), catalogue_to_pretty(catalogue))\n", + " X.append(X_i)\n", + "\n", + " params = [\"rLG\", \"sigma_v\"]\n", + " with plt.style.context(\"science\"):\n", + " g = plots.get_subplot_plotter()\n", + " g.settings.figure_legend_frame = False\n", + " g.settings.alpha_filled_add = 0.75\n", + "\n", + " g.triangle_plot(X, params=params, filled=True, legend_loc='upper right')\n", + " plt.gcf().suptitle(simname_to_pretty(simname), y=1.025)\n", + " plt.gcf().tight_layout()\n", + " plt.gcf().show()\n", + " plt.gcf().savefig(f\"../../plots/void_{simname}_noVext_nobeta.png\", dpi=500, bbox_inches='tight')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 2. No $V_{\\rm ext}$ but sampling $\\beta$" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for simname in [\"IndranilVoid_exp\", \"IndranilVoid_gauss\", \"IndranilVoid_mb\"]:\n", + " X = []\n", + " for catalogue in [\"2MTF\", \"SFI_gals\", \"CF4_TFR_i\", \"CF4_TFR_w1\"]:\n", + "\n", + " fname = paths.flow_validation(\n", + " fdir, simname, catalogue, inference_method=\"bayes\",\n", + " sample_alpha=False, sample_beta=True,\n", + " no_Vext=True, zcmb_max=0.05)\n", + "\n", + " X_i = samples_to_getdist(get_samples(fname, False), catalogue_to_pretty(catalogue))\n", + " X.append(X_i)\n", + "\n", + " params = [\"rLG\", \"sigma_v\", \"beta\"]\n", + " with plt.style.context(\"science\"):\n", + " g = plots.get_subplot_plotter()\n", + " g.settings.figure_legend_frame = False\n", + " g.settings.alpha_filled_add = 0.75\n", + "\n", + " g.triangle_plot(X, params=params, filled=True, legend_loc='upper right')\n", + " plt.gcf().suptitle(simname_to_pretty(simname), y=1.025)\n", + " plt.gcf().tight_layout()\n", + " plt.gcf().show()\n", + " plt.gcf().savefig(f\"../../plots/void_{simname}_noVext_beta.png\", dpi=500, bbox_inches='tight')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 3. Yes $V_{\\rm ext}$ and no $\\beta$ " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for simname in [\"IndranilVoid_exp\", \"IndranilVoid_gauss\", \"IndranilVoid_mb\"]:\n", + " X = []\n", + " for catalogue in [\"2MTF\", \"SFI_gals\", \"CF4_TFR_i\", \"CF4_TFR_w1\"]:\n", + "\n", + " fname = paths.flow_validation(\n", + " fdir, simname, catalogue, inference_method=\"bayes\",\n", + " sample_alpha=False, sample_beta=False,\n", + " no_Vext=None, zcmb_max=0.05)\n", + "\n", + " X_i = samples_to_getdist(get_samples(fname, False), catalogue_to_pretty(catalogue))\n", + " X.append(X_i)\n", + "\n", + " params = [\"rLG\", \"sigma_v\", \"Vx\", \"Vy\", \"Vz\"]\n", + " with plt.style.context(\"science\"):\n", + " g = plots.get_subplot_plotter()\n", + " g.settings.figure_legend_frame = False\n", + " g.settings.alpha_filled_add = 0.75\n", + "\n", + " g.triangle_plot(X, params=params, filled=True, legend_loc='upper right')\n", + " plt.gcf().suptitle(simname_to_pretty(simname), y=1.025)\n", + " plt.gcf().tight_layout()\n", + " plt.gcf().show()\n", + " plt.gcf().savefig(f\"../../plots/void_{simname}_Vext_nobeta.png\", dpi=500, bbox_inches='tight')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 4. Yes $V_{\\rm ext}$ and yes $\\beta$" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for simname in [\"IndranilVoid_exp\", \"IndranilVoid_gauss\", \"IndranilVoid_mb\"]:\n", + " X = []\n", + " for catalogue in [\"2MTF\", \"SFI_gals\", \"CF4_TFR_i\", \"CF4_TFR_w1\"]:\n", + "\n", + " fname = paths.flow_validation(\n", + " fdir, simname, catalogue, inference_method=\"bayes\",\n", + " sample_alpha=False, sample_beta=True,\n", + " no_Vext=None, zcmb_max=0.05)\n", + "\n", + " X_i = samples_to_getdist(get_samples(fname, False), catalogue_to_pretty(catalogue))\n", + " X.append(X_i)\n", + "\n", + " params = [\"rLG\", \"sigma_v\", \"beta\", \"Vx\", \"Vy\", \"Vz\"]\n", + " with plt.style.context(\"science\"):\n", + " g = plots.get_subplot_plotter()\n", + " g.settings.figure_legend_frame = False\n", + " g.settings.alpha_filled_add = 0.75\n", + "\n", + " g.triangle_plot(X, params=params, filled=True, legend_loc='upper right')\n", + " plt.gcf().suptitle(simname_to_pretty(simname), y=1.025)\n", + " plt.gcf().tight_layout()\n", + " plt.gcf().show()\n", + " plt.gcf().savefig(f\"../../plots/void_{simname}_Vext_beta.png\", dpi=500, bbox_inches='tight')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "venv_csiborg", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.4" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}