2024-09-16 11:39:49 +00:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"# Lagrangian patch example"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 1,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"import numpy as np\n",
|
2024-09-18 22:42:17 +00:00
|
|
|
"\n",
|
2024-09-16 11:39:49 +00:00
|
|
|
"import matplotlib.pyplot as plt\n",
|
2024-09-18 22:42:17 +00:00
|
|
|
"import scienceplots\n",
|
|
|
|
"\n",
|
2024-09-16 11:39:49 +00:00
|
|
|
"import csiborgtools\n",
|
|
|
|
"\n",
|
2024-09-18 22:42:17 +00:00
|
|
|
"\n",
|
|
|
|
"%matplotlib inline\n",
|
2024-09-16 11:39:49 +00:00
|
|
|
"\n",
|
|
|
|
"%load_ext autoreload\n",
|
|
|
|
"%autoreload 2"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2024-09-25 13:30:06 +00:00
|
|
|
"execution_count": 2,
|
2024-09-16 11:39:49 +00:00
|
|
|
"metadata": {},
|
2024-09-18 22:42:17 +00:00
|
|
|
"outputs": [],
|
2024-09-16 11:39:49 +00:00
|
|
|
"source": [
|
|
|
|
"paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)\n",
|
|
|
|
"bounds = {\"dist\": (0, 155)}\n",
|
|
|
|
"\n",
|
2024-09-18 22:42:17 +00:00
|
|
|
"nsim0 = 7444 + 24 * 61\n",
|
2024-09-16 11:39:49 +00:00
|
|
|
"nsnap_final = paths.get_snapshots(nsim0, \"csiborg1\")[-1]\n",
|
|
|
|
"snap0_initial = csiborgtools.read.CSiBORG1Snapshot(nsim0, nsnap=1)\n",
|
|
|
|
"cat0 = csiborgtools.read.CSiBORG1Catalogue(nsim0, paths, snapshot=snap0_initial, bounds=bounds)\n",
|
|
|
|
"\n",
|
|
|
|
"nsimx = 9844\n",
|
|
|
|
"nsnap_final = paths.get_snapshots(nsimx, \"csiborg1\")[-1]\n",
|
|
|
|
"snapx_initial = csiborgtools.read.CSiBORG1Snapshot(nsimx, nsnap=1)\n",
|
|
|
|
"catx = csiborgtools.read.CSiBORG1Catalogue(nsimx, paths, snapshot=snapx_initial, bounds=bounds)\n",
|
|
|
|
"\n",
|
|
|
|
"pair_overlapper = csiborgtools.summary.PairOverlap(cat0, catx, 13.25, )\n"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2024-09-25 13:30:06 +00:00
|
|
|
"execution_count": 3,
|
2024-09-16 11:39:49 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2024-09-18 22:42:17 +00:00
|
|
|
"15.319891\n",
|
|
|
|
"74.15419337073868\n"
|
2024-09-16 11:39:49 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"k = np.argsort(cat0[\"totmass\"])[::-1][1]\n",
|
|
|
|
"\n",
|
|
|
|
"print(np.log10(cat0[\"totmass\"][k]))\n",
|
|
|
|
"print(cat0[\"dist\"][k])\n",
|
|
|
|
"\n",
|
|
|
|
"hid0 = cat0[\"index\"][k]\n"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2024-09-25 13:30:06 +00:00
|
|
|
"execution_count": 4,
|
2024-09-16 11:39:49 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2024-09-18 22:42:17 +00:00
|
|
|
"Overlaps are [7.8512335e-01 9.1506150e-03 2.9659141e-03 3.0178351e-03 2.0852157e-04]\n"
|
2024-09-16 11:39:49 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"print(\"Overlaps are \", pair_overlapper.overlap(True)[k])\n",
|
|
|
|
"hidx = catx[\"index\"][pair_overlapper[\"match_indxs\"][k][0]]"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2024-09-25 13:30:06 +00:00
|
|
|
"execution_count": 5,
|
2024-09-16 11:39:49 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"overlapper = csiborgtools.match.ParticleOverlap(**{\"box_size\": 2048, \"bckg_halfsize\": 512})\n",
|
|
|
|
"\n",
|
|
|
|
"pos0_initial = snap0_initial.halo_coordinates(hid0)\n",
|
|
|
|
"pos0_initial = csiborgtools.match.pos2cell(pos0_initial / cat0.boxsize, 2048)\n",
|
|
|
|
"mass0_initial = snap0_initial.halo_masses(hid0)\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"posx_initial = snapx_initial.halo_coordinates(hidx)\n",
|
|
|
|
"posx_initial = csiborgtools.match.pos2cell(posx_initial / catx.boxsize, 2048)\n",
|
|
|
|
"massx_initial = snapx_initial.halo_masses(hidx)\n"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2024-09-25 13:30:06 +00:00
|
|
|
"execution_count": 6,
|
2024-09-16 11:39:49 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"smooth_kwargs = {\"sigma\": 1, \"mode\": \"constant\", \"cval\": 0}\n",
|
|
|
|
"# smooth_kwargs = None\n",
|
|
|
|
"\n",
|
|
|
|
"delta1_initial, delta2_initial, cellmins, __ = overlapper.make_deltas(\n",
|
|
|
|
" pos0_initial, posx_initial, mass0_initial, massx_initial, smooth_kwargs=smooth_kwargs, )\n",
|
|
|
|
"\n",
|
|
|
|
"x0 = cellmins[0] / 2048 * 677.7\n",
|
|
|
|
"xf = (cellmins[0] + delta1_initial.shape[0]) / 2048 * 677.7\n",
|
|
|
|
"\n",
|
|
|
|
"y0 = cellmins[1] / 2048 * 677.7\n",
|
|
|
|
"yf = (cellmins[1] + delta1_initial.shape[1]) / 2048 * 677.7"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2024-09-18 22:42:17 +00:00
|
|
|
"execution_count": 56,
|
2024-09-16 11:39:49 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
2024-09-25 13:30:06 +00:00
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAzMAAAGhCAYAAABVmurXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOx9d5gcxZ32W9U9s1GbpFWOq5xhFRASSULCGDBOyBhHkiSfsY3DZwt8tnHgDos7Y85ZAgM2tjGWsE2wCbsSIFBAYVFEAWmFct4gbZ7pqu+PCl3d0zObFft9nt3p6VBd3TNTb7+/VIRzzhEiRIgQIUKECBEiRIgQ5xno2e5AiBAhQoQIESJEiBAhQrQFoZgJESJEiBAhQoQIESLEeYlQzIQIESJEiBAhQoQIEeK8RChmQoQIESJEiBAhQoQIcV4iFDMhQoQIESJEiBAhQoQ4LxGKmRAhQoQIESJEiBAhQpyXCMVMiBAhQoQIESJEiBAhzkuEYiZEiBAhQoQIESJEiBDnJUIxE+LCwqZFwM8I8OLs5Pssny/2WT4/cVtDlVj/9ASxz6/yRVtV5Wem/RAhQoQI0WYsWr4IZA7B7N8lH6PnL5kPModg/pLEMbqqrgrzl8zHhJ9MAJlDkH9vPmb/bjbKj5efkfZDhAjReoRiJsSFh7Q8YOeS5Ns3LRL7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F84WZZAfnICq+qqUD+Sd3X5RtyKUvFeic2Cq6qoSRMSg+wdhwSvueLrw8wtR3L8YEx6cgPx787HwzYWYOdIoqzxyJh56+SEMun8Qyo+XY/331jfb//IT5brfC99ciPXfW+8pRLD0W0tRkFWACQ9OwIQHJ6CitkJ7WEKE6EwQzjk/250IESLEGcTiWUJ
|
2024-09-16 11:39:49 +00:00
|
|
|
"text/plain": [
|
2024-09-18 22:42:17 +00:00
|
|
|
"<Figure size 830x498 with 2 Axes>"
|
2024-09-16 11:39:49 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"with plt.style.context(\"science\"):\n",
|
2024-09-18 22:42:17 +00:00
|
|
|
" # plt.rcParams.update({'font.size': 9})\n",
|
|
|
|
"\n",
|
|
|
|
" fig, axs = plt.subplots(1, 2, figsize=(8.3, 0.6* 8.3), sharey=True, sharex=True)\n",
|
2024-09-16 11:39:49 +00:00
|
|
|
" fig.subplots_adjust(wspace=0.05, hspace=0.05)\n",
|
|
|
|
"\n",
|
2024-09-18 22:42:17 +00:00
|
|
|
" kwargs = {\"origin\": \"lower\", \"cmap\": \"viridis\", \"vmin\": 0,\n",
|
|
|
|
" \"extent\": [x0, xf, y0, yf]}\n",
|
2024-09-25 13:30:06 +00:00
|
|
|
" \n",
|
|
|
|
" X1 = np.mean(delta1_initial, axis=-1)\n",
|
|
|
|
" X2 = np.mean(delta2_initial, axis=-1)\n",
|
|
|
|
"\n",
|
|
|
|
" img1 = axs[0].imshow(X1, **kwargs)\n",
|
|
|
|
" img2 = axs[1].imshow(X2, **kwargs)\n",
|
|
|
|
"\n",
|
|
|
|
" kwargs = {\"extent\": [x0, xf, y0, yf]}\n",
|
|
|
|
" # contour_level_X1 = np.percentile(X1, [1, 99]) # This will give the value at the 95th percentile\n",
|
|
|
|
" # # contour_level_X2 = np.percentile(X2, [1, 99]) # You can adjust this to enclose more/less area\n",
|
|
|
|
" contour_level_X1 = 1\n",
|
|
|
|
" contour_level_X2 = 1\n",
|
|
|
|
"\n",
|
|
|
|
" axs[0].contour(X1, colors='darkorange', levels=contour_level_X1, **kwargs)\n",
|
|
|
|
" axs[0].contour(X2, colors='darkgreen', levels=contour_level_X2, **kwargs)\n",
|
2024-09-16 11:39:49 +00:00
|
|
|
"\n",
|
2024-09-25 13:30:06 +00:00
|
|
|
" axs[1].contour(X1, colors='darkorange', levels=contour_level_X1, **kwargs)\n",
|
|
|
|
" axs[1].contour(X2, colors='darkgreen', levels=contour_level_X2, **kwargs)\n",
|
2024-09-16 11:39:49 +00:00
|
|
|
"\n",
|
|
|
|
" for i in range(2):\n",
|
|
|
|
" axs[i].set_xlabel(r\"$x ~ [\\mathrm{cMpc} / h]$\")\n",
|
2024-09-18 22:42:17 +00:00
|
|
|
" axs[0].set_ylabel(r\"$y ~ [\\mathrm{cMpc} / h]$\")\n",
|
2024-09-16 11:39:49 +00:00
|
|
|
"\n",
|
2024-09-25 13:30:06 +00:00
|
|
|
" axs[0].set_title(f\"MCMC step {nsim0}\", color=\"darkorange\")\n",
|
|
|
|
" axs[1].set_title(f\"MCMC step {nsimx}\", color=\"darkgreen\")\n",
|
2024-09-16 11:39:49 +00:00
|
|
|
"\n",
|
|
|
|
" fig.tight_layout()\n",
|
|
|
|
" fig.savefig(\"../../plots/lagrangian_patch_example.pdf\", bbox_inches=\"tight\", dpi=450)\n",
|
|
|
|
" fig.show()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"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",
|
|
|
|
"version": "3.11.4"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 2
|
|
|
|
}
|