From c881f8eb390436f9b599aac5472df77f8fa3d877 Mon Sep 17 00:00:00 2001 From: Richard Stiskalek Date: Mon, 23 Sep 2024 12:33:48 +0200 Subject: [PATCH] Void boost along axis. (#151) * Add Vmag along model ax * Fix typo * Updat evoid plots * Add label * Update script * Update defaults --- csiborgtools/flow/flow_model.py | 14 ++++++-- csiborgtools/read/paths.py | 7 ++-- notebooks/flow/reconstruction_comparison.py | 1 + notebooks/flow/void_test.ipynb | 36 +++++++++++++++++---- scripts/flow/flow_validation.py | 5 ++- scripts/flow/flow_validation.sh | 7 ++-- 6 files changed, 55 insertions(+), 15 deletions(-) diff --git a/csiborgtools/flow/flow_model.py b/csiborgtools/flow/flow_model.py index 85e1d46..1b3d524 100644 --- a/csiborgtools/flow/flow_model.py +++ b/csiborgtools/flow/flow_model.py @@ -378,7 +378,7 @@ def sample_simple(e_mu_min, e_mu_max, dmu_min, dmu_max, alpha_min, alpha_max, def sample_calibration(Vext_min, Vext_max, Vmono_min, Vmono_max, beta_min, beta_max, sigma_v_min, sigma_v_max, h_min, h_max, rLG_min, rLG_max, no_Vext, sample_Vmono, sample_beta, - sample_h, sample_rLG): + sample_h, sample_rLG, sample_Vmag_vax): """Sample the flow calibration.""" sigma_v = sample("sigma_v", Uniform(sigma_v_min, sigma_v_max)) @@ -387,10 +387,18 @@ def sample_calibration(Vext_min, Vext_max, Vmono_min, Vmono_max, beta_min, else: beta = 1.0 + if not no_Vext and sample_Vmag_vax: + raise RuntimeError("Cannot sample Vext and Vext magnitude along the " + "void axis simultaneously.") + if no_Vext: Vext = jnp.zeros(3) - # 840 in the direction of (l, b) = (117, 4) - # Vext = jnp.asarray([338.9478154 , -11.45056064, 768.49415294]) + + if sample_Vmag_vax: + Vext_mag = sample("Vext_axis_mag", Uniform(0.0, Vext_max)) + # In the direction if (l, b) = (117, 4) + Vext = Vext_mag * jnp.asarray([0.4035093, -0.01363162, 0.91487396]) + else: Vext = sample("Vext", Uniform(Vext_min, Vext_max).expand([3])) diff --git a/csiborgtools/read/paths.py b/csiborgtools/read/paths.py index 4e012e9..9941ca8 100644 --- a/csiborgtools/read/paths.py +++ b/csiborgtools/read/paths.py @@ -694,7 +694,7 @@ class Paths: sample_beta=False, no_Vext=None, sample_Vmono=False, sample_mag_dipole=False, sample_curvature=False, absolute_calibration=None, - verbose_print=True): + sample_Vmag_vax=False, verbose_print=True): """Flow validation file path.""" if isinstance(catalogue, list) and len(catalogue) == 1: catalogue = catalogue[0] @@ -710,10 +710,11 @@ class Paths: keys = ["smooth", "nsim", "zcmb_min", "zcmb_max", "mag_selection", "sample_alpha", "sample_beta", "no_Vext", "sample_Vmono", "sample_mag_dipole", "sample_curvature", - "absolute_calibration"] + "sample_Vmag_vax", "absolute_calibration"] values = [smooth, nsim, zcmb_min, zcmb_max, mag_selection, sample_alpha, sample_beta, no_Vext, sample_Vmono, - sample_mag_dipole, sample_curvature, absolute_calibration] + sample_mag_dipole, sample_curvature, + sample_Vmag_vax, absolute_calibration] for key, value in zip(keys, values): diff --git a/notebooks/flow/reconstruction_comparison.py b/notebooks/flow/reconstruction_comparison.py index bef313c..19adc4f 100644 --- a/notebooks/flow/reconstruction_comparison.py +++ b/notebooks/flow/reconstruction_comparison.py @@ -60,6 +60,7 @@ def names_to_latex(names, for_corner=False): "l": "\\ell ~ [\\mathrm{deg}]", "b": "b ~ [\\mathrm{deg}]", "rLG": "R_{\\rm offset} ~ [\\mathrm{Mpc} / h]", + "Vext_axis_mag": "V_{\\rm axis} ~ [\\mathrm{km} / \\mathrm{s}]", } ltx_corner = {"alpha": r"$\alpha$", diff --git a/notebooks/flow/void_test.ipynb b/notebooks/flow/void_test.ipynb index fb057fa..a2acd08 100644 --- a/notebooks/flow/void_test.ipynb +++ b/notebooks/flow/void_test.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -286,18 +286,42 @@ ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], - "source": [] + "source": [ + "### 5. $V_{\\rm ext}$ along the model axis and $\\beta = 1$" + ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "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, sample_Vmag_vax=True)\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\", \"Vext_axis_mag\"]\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_along_axis_no_beta.png\", dpi=500, bbox_inches='tight')" + ] }, { "cell_type": "code", diff --git a/scripts/flow/flow_validation.py b/scripts/flow/flow_validation.py index 5196e0a..11f99bf 100644 --- a/scripts/flow/flow_validation.py +++ b/scripts/flow/flow_validation.py @@ -310,6 +310,7 @@ if __name__ == "__main__": sample_alpha = False if "IndranilVoid_" in ARGS.simname or ARGS.simname == "no_field" else True # noqa sample_beta = None no_Vext = None + sample_Vmag_vax = False sample_Vmono = False sample_mag_dipole = False absolute_calibration = None @@ -325,6 +326,7 @@ if __name__ == "__main__": "sample_alpha": sample_alpha, "sample_beta": sample_beta, "no_Vext": no_Vext, + "sample_Vmag_vax": sample_Vmag_vax, "sample_Vmono": sample_Vmono, "sample_mag_dipole": sample_mag_dipole, "absolute_calibration": absolute_calibration, @@ -377,7 +379,8 @@ if __name__ == "__main__": "beta_min": -10.0, "beta_max": 10.0, "sigma_v_min": 1.0, "sigma_v_max": 5000 if "IndranilVoid_" in ARGS.simname else 750., # noqa "h_min": 0.01, "h_max": 5.0, - "no_Vext": False if no_Vext is None else no_Vext, # noqa + "no_Vext": False if no_Vext is None else no_Vext, # noqa + "sample_Vmag_vax": sample_Vmag_vax, "sample_Vmono": sample_Vmono, "sample_beta": sample_beta, "sample_h": sample_h, diff --git a/scripts/flow/flow_validation.sh b/scripts/flow/flow_validation.sh index 02ed06f..cbaa5a6 100755 --- a/scripts/flow/flow_validation.sh +++ b/scripts/flow/flow_validation.sh @@ -37,9 +37,12 @@ else fi -for simname in "IndranilVoid_exp" "IndranilVoid_gauss" "IndranilVoid_mb"; do +# for simname in "IndranilVoid_exp" "IndranilVoid_gauss" "IndranilVoid_mb"; do + +for simname in "Carrick2015" "Lilow2024" "csiborg2_main" "csiborg2X" "manticore_2MPP_N128_DES_V1" "CF4" "CLONES"; do # for simname in "no_field"; do for catalogue in "LOSS" "Foundation" "2MTF" "SFI_gals" "CF4_TFR_i" "CF4_TFR_w1"; do + # for catalogue in "2MTF"; do # for catalogue in "CF4_TFR_i" "CF4_TFR_w1"; do # for catalogue in "2MTF" "SFI_gals" "CF4_TFR_i" "CF4_TFR_w1"; do for ksim in "none"; do @@ -47,7 +50,7 @@ for simname in "IndranilVoid_exp" "IndranilVoid_gauss" "IndranilVoid_mb"; do # for ksim in $(seq 0 5 500); do # for ksim in "0_100_5" "100_200_5" "200_300_5" "300_400_5" "400_500_5"; do # for ksim in {0..500}; do - for ksmooth in 0; do + for ksmooth in 0 1; do pythoncm="$env $file --catalogue $catalogue --simname $simname --ksim $ksim --ksmooth $ksmooth --ndevice $ndevice --device $device" if [ "$on_login" == "1" ]; then