2024-07-01 10:48:50 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Density & velocity fields alond a LOS"
]
},
{
"cell_type": "code",
2024-07-25 10:48:37 +00:00
"execution_count": 128,
2024-07-01 10:48:50 +00:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"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",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import jax\n",
"from jax import numpy as jnp\n",
"from numpyro.infer import MCMC, NUTS, init_to_median\n",
"\n",
"import csiborgtools\n",
"\n",
"\n",
"%load_ext autoreload\n",
"%autoreload 2\n",
"%matplotlib inline\n",
"\n",
"paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## LOS density & radial velocity plots "
]
},
{
"cell_type": "code",
2024-07-25 10:48:37 +00:00
"execution_count": 129,
2024-07-01 10:48:50 +00:00
"metadata": {},
2024-07-25 10:48:37 +00:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2024-07-17 10:04:21.726937: reading the catalogue,\n",
"2024-07-17 10:04:21.744932: reading the interpolated field,\n",
"2024-07-17 10:04:21.770393: calculating the radial velocity.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/mnt/users/rstiskalek/csiborgtools/csiborgtools/flow/flow_model.py:91: UserWarning: The number of radial steps is even. Skipping the first step at 0.0 because Simpson's rule requires an odd number of steps.\n",
" warn(f\"The number of radial steps is even. Skipping the first \"\n"
]
}
],
2024-07-01 10:48:50 +00:00
"source": [
"fpath = \"/mnt/extraspace/rstiskalek/catalogs/PV_compilation.hdf5\"\n",
"\n",
2024-07-25 10:48:37 +00:00
"loader_carrick = csiborgtools.flow.DataLoader(\"Carrick2015\", [0], \"Pantheon+\", fpath, paths, ksmooth=0, )\n",
2024-07-01 10:48:50 +00:00
"# loaders_csiborg2X = [csiborgtools.flow.DataLoader(\"csiborg2X\", i, \"LOSS\", fpath, paths, ksmooth=1, verbose=False) for i in range(20)]\n",
"# loaders_csiborg2 = [csiborgtools.flow.DataLoader(\"csiborg2_main\", i, \"LOSS\", fpath, paths, ksmooth=1, verbose=False) for i in range(20)]\n",
"\n",
2024-07-25 10:48:37 +00:00
"# loader_CF4 = csiborgtools.flow.DataLoader(\"CF4gp\", [0], \"LOSS\", fpath, paths, ksmooth=0, )\n",
"# loader_lilow = csiborgtools.flow.DataLoader(\"Lilow2024\", [0], \"LOSS\", fpath, paths, ksmooth=0, )"
2024-07-01 10:48:50 +00:00
]
},
{
"cell_type": "code",
2024-07-25 10:48:37 +00:00
"execution_count": 130,
2024-07-01 10:48:50 +00:00
"metadata": {},
2024-07-25 10:48:37 +00:00
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAArIAAAKwCAYAAABksZyLAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAAC4D0lEQVR4nOzdd3QUZRsF8LvpCYRAKIEAISA19BYITTpSBWmKSFHBElQIgmIB/SxYABUJRZAiShEUKdJDR3qRJqFIxyTUhCSQtvv98TDZhBSyye7O7O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PUsGLFCgwaNAhz5sxB//798/ol5urBgwd455138Nxzz6W//R8VFZXl7X8XFxf4+vqa1N9apkwZzJw5E40aNUJSUhLmzJmD1q1bY9++fWjQoIFZ6s8JgyxRTpYtA27cAMqVA3r3zvp88+ZA2bLAtWvAxo1A9+7Wr5GISAu8vKQVS43r5lFe7n8BgM2bN2PixIk4ffo04uLikJqaigcPHiAxMTF9JTM3NzfUqVMny2szjmxm5+jRo2jZsmV6iM3Ovn37sGbNGixfvjzLjVU7d+5E586d0z9PTk6GwWDA8uXL0x+bNWsWnn/++UyvS0lJQb9+/WAwGAq0umlOqlWrhmrVqqV/3qxZM5w/fx7ffPMNFi5caPbrZcQgS5QTZTT2lVcAl2z+qTg5Ad26yWjs1q0MskTkuHQ6IJu367WkSpUq0Ol0ud7QdfHiRXTr1g2vvfY
"text/plain": [
"<Figure size 700x700 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAArIAAAKxCAYAAACv7U8uAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAACu9klEQVR4nOzdd3gUVRcG8HcT0iEJJST0Ir13CFIF6SIgxQ6IIhpUBGlKEVH5BMVGBDsWUIoCCkqvSu9SpfdQTUISUne+Pw6zm0ASstmZnS3v73n2mcnu7MxJCJuzd88916QoigIiIiIiIhfjZXQARERERET5wUSWiIiIiFwSE1kiIiIicklMZImIiIjIJTGRJSIiIiKXxESWiIiIiFwSE1kiIiIickkFjA7AlZnNZly8eBGFChWCyWQyOhwiIiIil6coCm7evImSJUvCyyv3MVcmsna4ePEiypQpY3QYRERERG7n3LlzKF26dK7HMJG1Q6FChQDIDzo4ONjgaIiIiIhcX3x8PMqUKWPJs3LDRNYOajlBcHAwE1kiIiIiDeWlbJOTvYiIiIjIJTGRJSIiI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URfH2BHTuAPXt0C4+IiIjIVkxkPcXtFUvQvLltzwsLA3r1kv3PP9c2JiIiIiI7MJH1FOpys82a2f7c55+X7Zw5wM2b2sVEREREZAcmsp7AbAbUpeYiI21/fuvWQNWq0ux60SJtYyMiIpfEKTZkD61+f5jIeoIjR4D4eFkBpVYt259vMgF9+8r+779
"text/plain": [
"<Figure size 700x700 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
2024-07-01 10:48:50 +00:00
"source": [
"# ks = [i for i in range(50)]\n",
2024-07-25 10:48:37 +00:00
"# ks = [30, 50,]\n",
"ks = np.random.choice(50, 2, replace=False)\n",
2024-07-01 10:48:50 +00:00
"\n",
"for k in ks:\n",
" fig, axs = plt.subplots(2, 1, figsize=(7, 7), sharex=True)\n",
" fig.subplots_adjust(wspace=0)\n",
" cols = plt.rcParams['axes.prop_cycle'].by_key()['color']\n",
"\n",
" # # CSiBORG2\n",
" # x = loaders_csiborg2X[0].rdist\n",
" # y = np.asarray([loaders_csiborg2[i].los_density[k, :] for i in range(len(loaders_csiborg2X))])\n",
" # ylow, ymed, yhigh = np.percentile(y, [16, 50, 84], axis=0)\n",
" # axs[0].fill_between(x, ylow, yhigh, color=cols[0], alpha=0.25)\n",
" # axs[0].plot(x, ymed, color=cols[0], label=\"CSiBORG2\")\n",
"\n",
" # y = np.asarray([loaders_csiborg2[i].los_radial_velocity[k, :] for i in range(len(loaders_csiborg2X))])\n",
" # ylow, ymed, yhigh = np.percentile(y, [16, 50, 84], axis=0)\n",
" # axs[1].fill_between(x, ylow, yhigh, color=cols[0], alpha=0.25)\n",
" # axs[1].plot(x, ymed, color=cols[0], label=\"CSiBORG2\")\n",
"\n",
" # # CSiBORG2X\n",
" # x = loaders_csiborg2X[0].rdist\n",
" # y = np.asarray([loaders_csiborg2X[i].los_density[k, :] for i in range(len(loaders_csiborg2X))])\n",
" # ylow, ymed, yhigh = np.percentile(y, [16, 50, 84], axis=0)\n",
" # axs[0].fill_between(x, ylow, yhigh, color=cols[1], alpha=0.25)\n",
" # axs[0].plot(x, ymed, color=cols[1], label=\"CSiBORG2X\")\n",
"\n",
" # y = np.asarray([loaders_csiborg2X[i].los_radial_velocity[k, :] for i in range(len(loaders_csiborg2X))])\n",
" # ylow, ymed, yhigh = np.percentile(y, [16, 50, 84], axis=0)\n",
" # axs[1].fill_between(x, ylow, yhigh, color=cols[1], alpha=0.25)\n",
" # axs[1].plot(x, ymed, color=cols[1], label=\"CSiBORG2X\")\n",
"\n",
" # Plot Carrick+2015\n",
" axs[0].plot(loader_carrick.rdist, loader_carrick.los_density[0, k, :], color=\"red\", label=\"Carrick+2015\")\n",
" axs[1].plot(loader_carrick.rdist, loader_carrick.los_radial_velocity[0, k, :] * 0.43, color=\"red\")\n",
2024-07-25 10:48:37 +00:00
" axs[1].axvline(loader_carrick._rmax[0, k], c=\"black\", linestyle=\"--\")\n",
2024-07-01 10:48:50 +00:00
"\n",
2024-07-25 10:48:37 +00:00
" # # Plot CF4\n",
" # c = cols[4]\n",
" # axs[0].plot(loader_CF4.rdist, loader_CF4.los_density[0, k, :], color=c, label=\"CF4\")\n",
" # axs[1].plot(loader_CF4.rdist, loader_CF4.los_radial_velocity[0, k, :], color=c)\n",
2024-07-01 10:48:50 +00:00
"\n",
2024-07-25 10:48:37 +00:00
" # # Plot Lilow2024\n",
" # c = cols[5]\n",
" # axs[0].plot(loader_lilow.rdist, loader_lilow.los_density[0, k, :], color=c, label=\"Lilow+2024\")\n",
" # axs[1].plot(loader_lilow.rdist, loader_lilow.los_radial_velocity[0, k, :], color=c)\n",
" axs[1].axhline(0, color=\"black\", linestyle=\"--\")\n",
2024-07-01 10:48:50 +00:00
"\n",
"\n",
" axs[1].set_xlabel(r\"$r ~ [\\mathrm{Mpc} / h]$\")\n",
" axs[0].set_ylabel(r\"$\\rho_{\\rm LOS} / \\langle \\rho_{\\rm matter} \\rangle$\")\n",
" axs[1].set_ylabel(r\"$v_{\\rm LOS} ~ [\\mathrm{km/s}]$\")\n",
" axs[0].set_yscale(\"log\")\n",
"\n",
" axs[0].legend(loc=\"upper right\")\n",
2024-07-25 10:48:37 +00:00
" # axs[0].set_xlim(0, 200)\n",
2024-07-01 10:48:50 +00:00
"\n",
" fig.tight_layout(w_pad=0, h_pad=0)\n",
" fig.savefig(f\"../../plots/LOSS_los_{k}.png\", dpi=500, bbox_inches=\"tight\")\n",
"\n",
" fig.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test running a model"
]
},
{
"cell_type": "code",
"execution_count": 84,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2024-06-29 19:40:25.229961: reading the catalogue,\n",
"2024-06-29 19:40:25.243502: reading the interpolated field,\n",
"2024-06-29 19:40:25.261423: calculating the radial velocity.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/mnt/users/rstiskalek/csiborgtools/csiborgtools/flow/flow_model.py:91: UserWarning: The number of radial steps is even. Skipping the first step at 0.0 because Simpson's rule requires an odd number of steps.\n",
" warn(f\"The number of radial steps is even. Skipping the first \"\n"
]
}
],
"source": [
"fpath_data = \"/mnt/extraspace/rstiskalek/catalogs/PV_compilation.hdf5\"\n",
"\n",
"simname = \"Carrick2015\"\n",
"catalogue = \"LOSS\"\n",
"loader = csiborgtools.flow.DataLoader(simname, [0, 0], catalogue, fpath_data, paths, ksmooth=0, )\n",
"\n",
"SN_hyperparams = {\"e_mu_mean\": 0.1, \"e_mu_std\": 0.05,\n",
" \"mag_cal_mean\": -18.25, \"mag_cal_std\": 0.5,\n",
" \"alpha_cal_mean\": 0.148, \"alpha_cal_std\": 0.05,\n",
" \"beta_cal_mean\": 3.112, \"beta_cal_std\": 1.0,\n",
" }\n",
"calibration_hyperparams = {\"Vext_std\": 250,\n",
" \"alpha_mean\": 1.0, \"alpha_std\": 0.5,\n",
" \"beta_mean\": 1.0, \"beta_std\": 0.5,\n",
" \"sigma_v_mean\": 150., \"sigma_v_std\": 100.,\n",
" \"sample_alpha\": True, \"sample_beta\": True,\n",
" }\n",
"get_model_kwargs = {\"zcmb_max\": 0.05}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Running HMC"
]
},
{
"cell_type": "code",
"execution_count": 85,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 50/50 galaxies.\n"
]
}
],
"source": [
"model = csiborgtools.flow.get_model(loader, **get_model_kwargs)\n",
"model_kwargs = {\"distmod_hyperparams\": SN_hyperparams, \"calibration_hyperparams\": calibration_hyperparams,}"
]
},
{
"cell_type": "code",
"execution_count": 86,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"sample: 100%|██████████| 1000/1000 [02:10<00:00, 7.68it/s, 7 steps of size 4.49e-01. acc. prob=0.90] \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" mean std median 5.0% 95.0% n_eff r_hat\n",
" Vext[0] -3.71 69.92 -3.04 -123.73 103.87 469.72 1.00\n",
" Vext[1] -27.47 95.52 -30.48 -151.20 172.63 308.02 1.00\n",
" Vext[2] -59.27 131.26 -57.79 -273.64 137.55 456.29 1.00\n",
" alpha 1.09 0.38 1.10 0.50 1.69 400.05 1.00\n",
" alpha_cal 0.13 0.03 0.13 0.09 0.17 558.81 1.00\n",
" beta 0.43 0.11 0.44 0.27 0.61 341.86 1.00\n",
" beta_cal 3.54 0.18 3.54 3.23 3.81 606.77 1.00\n",
" e_mu 0.08 0.03 0.08 0.04 0.12 330.71 1.00\n",
" mag_cal -18.19 0.04 -18.19 -18.25 -18.13 389.94 1.00\n",
" sigma_v 176.93 52.05 169.93 102.74 267.56 315.30 1.00\n",
"\n",
"Number of divergences: 0\n"
]
}
],
"source": [
"kernel = NUTS(model, init_strategy=init_to_median(num_samples=100))\n",
"mcmc = MCMC(kernel, num_warmup=500, num_samples=500)\n",
"\n",
"rng_key = jax.random.PRNGKey(5)\n",
"mcmc.run(rng_key, extra_fields=(\"potential_energy\",), **model_kwargs)\n",
"mcmc.print_summary()\n",
"samples = mcmc.get_samples()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"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",
2024-07-25 10:48:37 +00:00
"version": "3.11.4"
2024-07-01 10:48:50 +00:00
}
},
"nbformat": 4,
"nbformat_minor": 2
}