csiborgtools/notebooks/field_velocity_fof_sph.ipynb

472 lines
1 MiB
Text
Raw Normal View History

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Tests of velocities of haloes in CSiBORG"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import csiborgtools\n",
"\n",
"from scipy.stats import spearmanr, binned_statistic\n",
"\n",
"%matplotlib inline\n",
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## FoF vs SPH velocity"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"kind = \"main\"\n",
"nsnap = 99\n",
"nsim = 17417\n",
"\n",
"field_reader = csiborgtools.read.CSiBORG2Field(nsim, kind)\n",
"catalogue = csiborgtools.read.CSiBORG2Catalogue(nsim, nsnap, kind)\n",
"boxsize = csiborgtools.simname2boxsize(\"csiborg2_main\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"velocity_field = field_reader.velocity_field(\"SPH\", 1024)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"pos = catalogue[\"cartesian_pos\"] / boxsize\n",
"vel = catalogue[\"cartesian_vel\"]\n",
"mass = catalogue[\"totmass\"]\n",
"\n",
"spherical_pos = catalogue[\"spherical_pos\"]\n",
"RA = np.deg2rad(spherical_pos[:, 1])\n",
"dec = np.deg2rad(spherical_pos[:, 2])\n",
"\n",
"def project_radial(vx, vy, vz, RA, dec):\n",
" return vx * np.cos(dec) * np.cos(RA) + vy * np.cos(dec) * np.sin(RA) + vz * np.sin(dec)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"vx, vy, vz = csiborgtools.field.evaluate_cartesian_cic(velocity_field[0], velocity_field[1], velocity_field[2], pos=pos)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABdEAAAGNCAYAAAD+VjiVAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3gVxdfA8e/ubemNFkIJTemgoiJKUUE6KoqKoBRBkCqCFSu8KApIkSoWQH8iiF2QKlVARAQpCtJ7Cun9lp33j5vc5KZAkBLK+fjkkczO7s7uTWY3Z2fPaEophRBCCCGEEEIIIYQQQgghCtBLugFCCCGEEEIIIYQQQgghxJVKguhCCCGEEEIIIYQQQgghRBEkiC6EEEIIIYQQQgghhBBCFEGC6EIIIYQQQgghhBBCCCFEESSILoQQQgghhBBCCCGEEEIUQYLoQgghhBBCCCGEEEIIIUQRJIguhBBCCCGEEEIIIYQQQhRBguhCCCGEEEIIIYQQQgghRBEkiC6EEEIIIYQQQgghhBBCFEGC6EIIIYS4rmiaxltvvVXSzbhgn3/+ObVq1cJisRASElLSzRGX2Ny5c9E0jSNHjlyS7b/11ltomnZFtOVKsHbtWjRN4+uvvy7ppoizOHLkCJqmMXfu3GLVv1b6fyGEEEJcfhJEF0IIIa4zBw8epH///lSrVg0fHx+CgoK46667mDJlChkZGSXdPFEMe/fupVevXlSvXp2PPvqI2bNnF1k3Jzha2NesWbPOa78Xsq0ZM2YUO9B1Pux2O1OmTOHmm28mKCiIkJAQ6tatS79+/di7d6+nXk7gN+fLx8eHG2+8kcGDBxMdHe2pd67gaa9evQgICLjox3Eleuedd/j+++9LuhnnZdOmTbz11lskJiYWq/78+fOZPHnyJW2TuLx+/vlnCZQLIYQQ4qIzl3QDhBBCCHH5LFmyhEceeQSbzUaPHj2oV68edrudX3/9lRdeeIE9e/acNSB7LcjIyMBsvrpvgdauXYthGEyZMoUaNWoUa52ZM2cWCP42btz4P+3/v2xrxowZl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2pHz58jz77LOEh4fzzz//sHjxYq8HZ3l9/vnn9O3bl9tvv51+/foBUL169SLb8vnnn9OzZ0/atGnDe++9R3p6OjNnzqRp06Zs377d8/v38MMPs2fPHoYMGUKVKlWIiYlh5cqVHDt2rMjf0ZxjOHToEL179yY8PNyTemrPnj389ttvaJrGQw89xL///suXX37JpEmTPG9LlClTptBtvvrqqyQlJXHixAkmTZoEUCBN0bvvvouu6zz//PMkJSUxbtw4unfvzpYtWzx1LuQz/Oijjxg6dChdunTh2WefJTMzk507d7Jlyxa6desGuN+42LRpE127dqVixYocOXKEmTNncvfdd/P3338XSEM0ZMgQwsPDGTVqFL/99huzZ88mJCSETZs2UblyZd555x1+/vlnxo8fT7169ejRo4dn3f79+3v6g6FDh3L48GGmTZvG9u3bvX6milKcvlwpxf3338+aNWvo06cPN910E8uXL+eFF17g5MmTns9iz549dOzYkQYNGjB69GhsNhsHDhw468OJ/v37c+rUKVauXMnnn39+1rbm7KNZs2YEBQXx4osvYrFY+PDDD7n77rtZt25dgTRVQ4YMITQ0lDfffJMjR44wefJkBg8ezMKFC8+5LyGEEEJc5ZQQQgghrnlJSUkKUA888ECx6u/YsUMBqm/fvl7lzz//vALU6tWrPWWRkZEKUJs2bfKULV++XAHK19dXHT161FP+4YcfKkCtWbPGU9azZ08FqCFDhnjKDMNQHTp0UFarVcXGxnrK09PTvdpjt9tVvXr11L3
"text/plain": [
"<Figure size 1500x400 with 4 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, axs = plt.subplots(1, 4, figsize=(15, 4))\n",
"fig.suptitle(\"Comparison of FoF to SPH velocities at the same position\")\n",
"\n",
"axs[0].hexbin(vel[:, 0], vx, gridsize=50, bins=\"log\", mincnt=1)\n",
"axs[0].set_xlabel(r\"FoF $v_x ~ [\\mathrm{km} / \\mathrm{s}]$\")\n",
"axs[0].set_ylabel(r\"SPH $v_x ~ [\\mathrm{km} / \\mathrm{s}]$\")\n",
"\n",
"axs[1].hexbin(vel[:, 1], vy, gridsize=50, bins=\"log\", mincnt=1)\n",
"axs[1].set_xlabel(r\"FoF $v_y ~ [\\mathrm{km} / \\mathrm{s}]$\")\n",
"axs[1].set_ylabel(r\"SPH $v_y ~ [\\mathrm{km} / \\mathrm{s}]$\")\n",
"\n",
"axs[2].hexbin(vel[:, 2], vz, gridsize=50, bins=\"log\", mincnt=1)\n",
"axs[2].set_xlabel(r\"FoF $v_z ~ [\\mathrm{km} / \\mathrm{s}]$\")\n",
"axs[2].set_ylabel(r\"SPH $v_z ~ [\\mathrm{km} / \\mathrm{s}]$\")\n",
"\n",
"\n",
"vr_fof = project_radial(vel[:, 0], vel[:, 1], vel[:, 2], RA, dec)\n",
"vr_sph = project_radial(vx, vy, vz, RA, dec)\n",
"axs[3].hexbin(vr_fof, vr_sph, gridsize=50, bins=\"log\", mincnt=1)\n",
"axs[3].set_xlabel(r\"FoF $v_r ~ [\\mathrm{km} / \\mathrm{s}]$\")\n",
"axs[3].set_ylabel(r\"SPH $v_r ~ [\\mathrm{km} / \\mathrm{s}]$\")\n",
"\n",
"for i in range(4):\n",
" axs[i].axline([0, 0], [1, 1], color=\"red\", ls=\"--\")\n",
"\n",
"fig.tight_layout()\n",
"fig.savefig(\"../plots/fof_to_sph_velocity_comparison.png\")\n",
"fig.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Correlation of the peculiar velocity and total mass"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"kind = \"main\"\n",
"nsnap = 99\n",
"nsim = 17417"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### FoF haloes"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"SignificanceResult(statistic=-0.011239061725954754, pvalue=1.637324987020833e-17)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"catalogue = csiborgtools.read.CSiBORG2Catalogue(nsim, nsnap, kind)\n",
"\n",
"vel = catalogue[\"cartesian_vel\"]\n",
"mass = catalogue[\"totmass\"]\n",
"velmag = np.linalg.norm(vel, axis=1)\n",
"\n",
"spearmanr(mass, velmag)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkkAAAHLCAYAAADcEAx6AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3hTVRvAf/cmaboXbSlQ9p4yZO+9ZQ9RlqCCoIK4B+LCLbhwC4iiMmTvjciQPQXZs4XumaZJ7vn+SJM2bVoKFAqf5/c8fWzuPefc99xcuW/fqQghBBKJRCKRSCQSF9SiFkAikUgkEonkbkQqSRKJRCKRSCRukEqSRCKRSCQSiRukkiSRSCQSiUTiBqkkSSQSiUQikbhBKkkSiUQikUgkbpBKkkQikUgkEokbpJIkkUgkEolE4gapJEkkEolEIpG4QSpJEsn/AVOmTEFRlNu2/ogRIyhXrtxtW/9ewWq18vzzz1O6dGlUVaV3795FLZJbZs2ahaIonDt3rqhFyZcPP/yQChUqoNPpqFu3blGLI5HkQipJkv8UjpeHu58XX3yxyNa610hLS2PKlCls3ry5qEW5o/z44498+OGH9O/fn9mzZzNx4sQilWfq1KksXry4SGW4WdauXcvzzz9P8+bNmTlzJlOnTi1qkSSSXOiLWgCJpCh48803KV++vMuxWrVqFfladyvfffcdmqY5P6elpfHGG28A0KZNmyKS6s6zceNGSpUqxbRp04paFMCuJPXv3z+XRWvo0KEMHjwYo9FYNIIVgI0bN6KqKj/88AMeHh5FLY5E4hapJEn+k3Tt2pX777//rlvrbsVgMBS1CHcF165dIzAwsKjFuC46nQ6dTlfUYuTLtWvX8PLykgqS5K5GutskEjds3LiRli1b4uPjQ2BgIL169eKff/4plLXHjx+Pr68vaWlpuc49+OCDhIeHY7PZnMdWrVrllMXPz4/u3btz9OjR617HarXy1ltvUbFiRYxGI+XKlePll1/GbDbnGrtq1Spat26Nn58f/v7+NGzYkLlz5zrPZ49JOnfuHKGhoQC88cYbThfjlClTmDlzJoqisH///lzXmDp1KjqdjsuXL+cp8/nz53niiSeoWrUqXl5eFCtWjAEDBuSKrbFYLLzxxhtUrlwZT09PihUrRosWLVi3bl2+9yQuLo5nn32W2rVr4+vri7+/P127duXgwYP5zjt37hyKorBp0yaOHj3q3PPmzZvZvHmz83d3c2bNmuU8NmLECHx9fbl8+TK9e/fG19eX0NBQnn32WZfvHEDTND799FNq166Np6cnoaGhdOnShT179gCgKAqpqanMnj3bKc+IESOAvGOSZsyYQc2aNTEajZQsWZJx48aRkJDgMqZNmzbUqlWLY8eO0bZtW7y9vSlVqhQffPBBvvfIQUGeO0VRmDlzJqmpqU7Zs9+nnDhkOnToEK1bt8bb25tKlSqxYMECALZs2ULjxo3x8vKiatWqrF+/3mV+YT5XUVFRjBw5koiICIxGIyVKlKBXr153ffyX5OaQSpLkP0liYiIxMTEuPw7Wr19P586duXbtGlOmTOGZZ55h+/btNG/e3O0/hPmt5Y5BgwaRmprKihUrXI6npaWxbNky+vfv77QCzJkzh+7du+Pr68v777/Pa6+9xrFjx2jRosV1/1EePXo0kydPpn79+kybNo3WrVvz7rvvMnjwYJdxs2bNonv37sTFxfHSSy/x3nvvUbduXVavXu123dDQUL766isA+vTpw5w5c5gzZw59+/alf//+eHl58csvv+Sa98svv9CmTRtKlSqVp8y7d+9m+/btDB48mM8++4wxY8awYcMG2rRp46JUTpkyhTfeeIO2bdvyxRdf8Morr1CmTBn27duX7z05c+YMixcvpkePHnzyySc899xzHD58mNatW3PlypU854WGhjJnzhyqVatGRESEc8/Vq1fP93rusNlsdO7cmWLFivHRRx/RunVrPv74Y7799luXcaNGjWLChAmULl2a999/nxdffBFPT0927twJ2J8No9FIy5YtnfI8/vjjeV53ypQpjBs3jpIlS/Lxxx/Tr18/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atSqBgYFUr16dxo0bO487fs8ua2E9V44Yqs2bNxMfH3/Te5HcO0glSfKfpFGjRnTo0MHlB+yxC2D/Bzgn1atXJyYmhtTU1AKtlR+DBg3CZDKxdOlSAFJSUli5ciUDBgxwvgQd/1C3a9eO0NBQl5+1a9dy7dq1PNc/f/48qqpSqVIll+Ph4eEEBgY693n69GmgcLPxOnbsSIkSJZwuN03T+PXXX+nVqxd+fn75zjWZTEyePJnSpUtjNBoJCQkhNDSUhIQEEhMTnePefPNNEhISqFKlCrVr1+a5557j0KFD15VN0zSmTZtG5cqVXdY/dOiQy/q3E0d8UXaCgoJcXrqnT5+mZMmSLor6rZDXc+3h4UGFChWc5x1ERETkUsZyypjXdQry3N0M7mQKCAigdOnSuY4BLrIW1nNlNBp5//33WbVqFcWLF6dVq1Z88MEHREVF3fS+JHc3UkmSSIqAJk2aUK5cOebNmwfAsmXLMJlMDBo0yDnGkXI/Z86cXJaqdevWsWTJkute53YWmMwLnU7HkCFDWLhwIenp6WzatIkrV664WCby4sknn+Sdd95h4MCBzJs3j7Vr17Ju3TqKFSvmUoKgVatWnD59mh9//JFatWrx/fffU79+fb7//vt81586dSrPPPMMrVq14ueff2bNmjWsW7eOmjVruqx/I+R1j3MGYju427POIG8ZhRAFmn87nru8ZCqIrIX5XE2YMIF///2Xd999F09PT1577TWqV6/uNllBcu8jSwBIJNkoW7YsACdOnMh17vjx44SEhODj41Mo1xo4cCCffvopSUlJ/P7775QrV44mTZo4z1esWBGAsLCwAlmnslO2bFk0TePkyZMuwcVXr14lISHBuU/HNY4cOZLrr//
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.figure()\n",
"plt.title(\"FoF velocity as a function of mass\")\n",
"plt.hexbin(np.log10(mass), velmag, mincnt=1, bins=\"log\")\n",
"\n",
"\n",
"plt.xlim(np.log10(np.min(mass)))\n",
"plt.ylim(0)\n",
"plt.xlabel(r\"$\\log M_{\\rm FoF} ~ [M_\\odot / h]$\")\n",
"plt.ylabel(r\"$V_{\\rm pec} ~ [\\mathrm{km} / \\mathrm{s}]$\")\n",
"\n",
"plt.savefig(\"../plots/fof_velocity_to_mass.png\", dpi=300, bbox_inches=\"tight\")\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Subfind subhaloes"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
"catalogue = csiborgtools.read.CSiBORG2SUBFINDCatalogue(nsim, nsnap, kind)\n",
"\n",
"mass = catalogue[\"totmass\"]\n",
"vec = np.linalg.norm(catalogue[\"cartesian_vel\"], axis=1)\n",
"is_central = catalogue[\"Central\"]\n",
"\n",
"def get_binned_trend(x, y, nbins=20):\n",
" median, bin_edges, __ = binned_statistic(x, y, bins=nbins, statistic=\"median\")\n",
" lower, __, __ = binned_statistic(x, y, bins=nbins, statistic=lambda x: np.percentile(x, 16))\n",
" upper, __, __ = binned_statistic(x, y, bins=nbins, statistic=lambda x: np.percentile(x, 84))\n",
" std, __, __ = binned_statistic(x, y, bins=nbins, statistic=\"std\")\n",
" xrange = (bin_edges[1:] + bin_edges[:-1]) / 2\n",
" std = (upper - lower) / 2\n",
" return xrange, median, lower, upper, std"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA90AAAGGCAYAAABmGOKbAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd1gUxxvA8e/e0aUJiIBgr9hil9h77zUae4k9ahKNiYlRf5bEGDXNaEw0RU2ssWDvDXvvvSJgpde7/f1xcHoCCngI6vt5Hp+Evd3Z2aW8Ozsz7yiqqqoIIYQQQgghhBDC7DRZXQEhhBBCCCGEEOJNJY1uIYQQQg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fV1tbW5HfJnL8bQojkNm3apGq1WlWr1ap+fn7qqFGj1I0bN6pxcXEm+6U1xj1viHda43VahpentE9q507reVX17YrHL4o9qfnrr79UQP3tt99Mtv/444+qk5OTGhISoqqqmq7h5RmNc+aOxy8aXl6yZEm1bt26ybafOXNGBdRffvlFVdWMPVuY434kSUvcfno/id2vD+npFmaTNBTWwcHhhfuqqsry5cvp2LEjqqqavNVs1KgR//zzD0ePHqVatWrG7QMGDDApo0aNGqxcuZKwsLBkby5T82wZgMkbyfj4eMLCwihcuDDOzs4cPXqUbt26pVqes7MzBw4cIDAwEC8vrzTVITUzZszAxcWFadOmmWyvVasWABcvXkyW1ONFypYtmywzZ2rSOkT
"text/plain": [
"<Figure size 1000x400 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"nbins = 15\n",
"\n",
"fig, axs = plt.subplots(1, 2, figsize=(10, 4))\n",
"\n",
"# Centrals\n",
"mask = is_central & (mass > 1e12)\n",
"x, y = np.log10(mass[mask]), vec[mask]\n",
"xrange, median, lower, upper, std = get_binned_trend(x, y, nbins=nbins)\n",
"sigma_v, e_sigma_v = np.mean(std), np.std(std)\n",
"axs[0].set_title(r\"Centrals, $\\sigma_v = {:.1f} \\pm {:.1f} ~ \\mathrm{{km}} / \\mathrm{{s}}$\".format(sigma_v, e_sigma_v))\n",
"axs[0].hexbin(x, y, mincnt=1, bins=\"log\")\n",
"\n",
"axs[0].plot(xrange, median, color=\"red\")\n",
"axs[0].fill_between(xrange, lower, upper, color=\"red\", alpha=0.3)\n",
"\n",
"# Satellites\n",
"mask = ~is_central & (mass > 1e12)\n",
"x, y = np.log10(mass[mask]), vec[mask]\n",
"xrange, median, lower, upper, std = get_binned_trend(x, y, nbins=nbins)\n",
"sigma_v, e_sigma_v = np.mean(std), np.std(std)\n",
"axs[1].set_title(r\"Satellites, $\\sigma_v = {:.1f} \\pm {:.1f} ~ \\mathrm{{km}} / \\mathrm{{s}}$\".format(sigma_v, e_sigma_v))\n",
"axs[1].hexbin(x, y, mincnt=1, bins=\"log\")\n",
"axs[1].plot(xrange, median, color=\"red\")\n",
"axs[1].fill_between(xrange, lower, upper, color=\"red\", alpha=0.3)\n",
"\n",
"for i in range(2):\n",
" axs[i].set_xlim(np.log10(1e12))\n",
" axs[i].set_ylim(0)\n",
" axs[i].set_xlabel(r\"$\\log M_{\\rm tot} ~ [M_\\odot / h]$\")\n",
" axs[i].set_ylabel(r\"$V_{\\rm pec} ~ [\\mathrm{km} / \\mathrm{s}]$\")\n",
"\n",
"fig.tight_layout()\n",
"fig.savefig(\"../plots/velocity_to_mass_subhaloes.png\", dpi=300, bbox_inches=\"tight\")\n",
"fig.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### SUBFIND haloes but subtracting the velocity of the velocity field"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"field_reader = csiborgtools.read.CSiBORG2Field(nsim, kind)\n",
"catalogue = csiborgtools.read.CSiBORG2SUBFINDCatalogue(nsim, nsnap, kind)\n",
"boxsize = csiborgtools.simname2boxsize(\"csiborg2_main\")\n",
"\n",
"mass = catalogue[\"totmass\"]\n",
"pos = catalogue[\"cartesian_pos\"] / boxsize\n",
"subfind_vel = catalogue[\"cartesian_vel\"]\n",
"is_central = catalogue[\"Central\"]\n",
"\n",
"parent_mass = catalogue[\"ParentMass\"]"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"velocity_field = field_reader.velocity_field(\"SPH\", 1024)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"vx, vy, vz = csiborgtools.field.evaluate_cartesian_cic(velocity_field[0], velocity_field[1], velocity_field[2], pos=pos)\n",
"\n",
"residual_vel = np.copy(subfind_vel)\n",
"residual_vel[:, 0] -= vx\n",
"residual_vel[:, 1] -= vy\n",
"residual_vel[:, 2] -= vz\n",
"\n",
"residual_vel_mag = np.linalg.norm(residual_vel, axis=1)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA90AAAGMCAYAAADHg8H9AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzddXgUVxfA4d9u3EMgikNwd4J7gOAuheAOBVqgtHhLKVRwKcVKkRZooTgELyVIcXcrkKBJCPHd+f7Ily1LbBN2SQLnfZ6U7sydO2cmmz17Z+7cq1IURUEIIYQQQgghhBBGp87oAIQQQgghhBBCiPeVNLqFEEIIIYQQQggTkUa3EEIIIYQQQghhItLoFkIIIYQQQgghTEQa3UIIIYQQQgghhIlIo1sIIYQQQgghhDARaXQLIYQQQgghhBAmIo1uIYQQQgghhBDCRKTRLYQQQgghhBBCmIg0uoUQ741JkyahUqkMKqtSqZg0aZJJ46lTpw516tQx6T4yYr/58uWjR48eJqtfvF/u3LmDSqVixYoVqZa9fv06jRo1wsnJCZVKxaZNm0wW14EDB1CpVGzYsMFk+0hJwnn57rvvMmT/mcUvv/xC0aJFsbCwwNnZGXi7zzBDP59WrFiBSqXizp076dqPEEKkhTS6hRBGl/BlJuHH3NycnDlz0qNHDx48eJDR4Qkju3TpEpMmTcr0X14jIiKYNGkSBw4cyOhQMqUFCxYY1DA2JX9/f86fP8/UqVP55ZdfqFixYobGYwzbt283+QW+1ISHhzNx4kRKliyJnZ0d2bNnp2zZsnz88cc8fPhQVy7hwmXCj62tLcWLF2fcuHGEhYXpyiV8xv/zzz9J7q9OnTqULFky1biuXLlCjx49KFiwID/99BOLFy9++4MVQohMyDyjAxBCvL+mTJlC/vz5iYqK4ujRo6xYsYLDhw9z4cIFrK2tjb6/cePG8dlnnxm9XqHv6tWrqNX/XbO9dOkSkydPpk6dOuTLly/jAktFREQEkydPBsiQHgiZ3YIF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mJoYNGzbQtm3bZB+X6d+/Pw8fPiQgIIBffvklyTJr1qzh5cuX9O/fH5VKxYwZM2jTpg23bt3S/U0b+jmZlISLGStXrmTcuHHp6h6e0HDPnj273vLQ0FCePn2aqHxSF9reNGvWLFauXMnGjRt13dmT+3vUarW0aNGCw4cP069fP4oVK8b58+eZOXMm165dS3HAvaCgIOrWrUtcXJzu3C1evBgbG5tUYxRCCKNRhBDCyJYvX64Ayp49e5QnT54o9+/fVzZs2KC4uroqVlZWyv3793Vl69evr5QqVUqJiorSLdNqtUq1atWUQoUK6ZaVKVNG8fPzS3G/EydOVF7/WDtz5owCKIMGDdIr16VLFwVQJk6cqFvm7++v5M2bN9U6FUVRIiIiEpXz9fVVChQooLesdu3aSu3atVOM+erVqwqgzJ07V2/5oEGDFHt7e92+/vrrLwVQVq9erVdu586diZa/ud9Zs2YpgLJq1SrdspiYGMXHx0ext7dXwsLCFEVRlH379imAMmzYsERxarVa3f/nzZtX8ff3171ev369Aij79+/X20aj0Si5cuVSOnbsqLf8hx9+UFQqlXLr1q0Uzkz8cQDKypUrdcuio6MVDw8PpW3btmk+vidPniT6vackKipK0Wg0estu376tWFlZKVOmTNEtW7ZsmQIoP/zwQ6I6Es6bIec24f3ap08fvfWffvqpAij79u3TLUvuON783ST8LTZo0EDvdzhixAjFzMxMCQkJ0S0rUaJEku/XL7/8UrGzs1OuXbumt/yzzz5TzMzMlHv37imKoiibNm1SAGXGjBm6MnFxcUrNmjUVQFm+fHm
"text/plain": [
"<Figure size 1000x400 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"nbins = 15\n",
"\n",
"fig, axs = plt.subplots(1, 2, figsize=(10, 4))\n",
"fig.suptitle(\"Residual velocity not accounted for by the SPH field.\")\n",
"# Centrals\n",
"mask = is_central & (mass > 1e12)\n",
"x, y = np.log10(mass[mask]), residual_vel_mag[mask]\n",
"xrange, median, lower, upper, std = get_binned_trend(x, y, nbins=nbins)\n",
"sigma_v, e_sigma_v = np.mean(std), np.std(std)\n",
"axs[0].set_title(r\"Centrals, $\\sigma_v = {:.1f} \\pm {:.1f} ~ \\mathrm{{km}} / \\mathrm{{s}}$\".format(sigma_v, e_sigma_v))\n",
"axs[0].hexbin(x, y, mincnt=1, bins=\"log\")\n",
"\n",
"axs[0].plot(xrange, median, color=\"red\")\n",
"axs[0].fill_between(xrange, lower, upper, color=\"red\", alpha=0.3)\n",
"\n",
"# Satellites\n",
"mask = ~is_central & (mass > 1e12)\n",
"x, y = np.log10(mass[mask]), residual_vel_mag[mask]\n",
"xrange, median, lower, upper, std = get_binned_trend(x, y, nbins=nbins)\n",
"sigma_v, e_sigma_v = np.mean(std), np.std(std)\n",
"axs[1].set_title(r\"Satellites, $\\sigma_v = {:.1f} \\pm {:.1f} ~ \\mathrm{{km}} / \\mathrm{{s}}$\".format(sigma_v, e_sigma_v))\n",
"axs[1].hexbin(x, y, mincnt=1, bins=\"log\")\n",
"axs[1].plot(xrange, median, color=\"red\")\n",
"axs[1].fill_between(xrange, lower, upper, color=\"red\", alpha=0.3)\n",
"\n",
"for i in range(2):\n",
" axs[i].set_xlim(np.log10(1e12))\n",
" axs[i].set_ylim(0)\n",
" axs[i].set_xlabel(r\"$\\log M_{\\rm tot} ~ [M_\\odot / h]$\")\n",
" axs[i].set_ylabel(r\"$\\Delta V_{\\rm pec} ~ [\\mathrm{km} / \\mathrm{s}]$\")\n",
"\n",
"fig.tight_layout()\n",
"fig.savefig(\"../plots/residual_velocity_to_mass_subhaloes.png\", dpi=300, bbox_inches=\"tight\")\n",
"fig.show()"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAArUAAAHbCAYAAADVtmL2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQ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CYDy5ctnuu5z587x999/07VrV4oUKUJ4eDg///wz9evX59ixY+ZTtgaDgTZt2rB27Vp69OjBq6++SkxMDKtXr+bIkSMUK1Ys2/t24MCBzJgxgy5duvD666+zc+dOxo0bx/Hjx1m4cOFD91dmhg8fTr58+RgzZgwXLlxgwoQJDBs2jD///BOACRMmMHz4cFxcXHj33XcByJ8/P5B6SrF+/fpcvXqVl19+mUKFCrFt2zZGjx7N9evXmTBhAgBKKdq3b8+WLVsYNGgQpUuXZuHChfTp0+eh8XXq1AkPDw9GjhxJz549adWqFS4uLkDqMaJu3bq4ubnx5ptvYmtry88//0yDBg3YuHEjNWrUsFjWkCFD8PHx4f333ycuLu6h6/7kk0/QNI233nqLiIgIJkyYQJMmTThw4ACOjo706tWLDz/8kD///NOiLCIpKYn58+fTuXPnTMupXn75Za5du8bq1auZNWtWhn3mzJlDTEwML7/8Mpqm8cUXX9CpUyfOnTtn/kxn9ziZEdOPhZkzZ/K///3vkcoHTImxl5eXRXtUVBQ3b95M1z+jH7IPmjBhAjNnzmThwoXmcofMPo9Go5F
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"nbins = 15\n",
"\n",
"fig, axs = plt.subplots(1, 1)\n",
"axs = [axs]\n",
"fig.suptitle(\"Residual velocity not accounted for by the SPH field as a function of parent mass\")\n",
"\n",
"# Satellites\n",
"mask = ~is_central & (parent_mass > 1e12)\n",
"x, y = np.log10(parent_mass[mask]), residual_vel_mag[mask]\n",
"xrange, median, lower, upper, std = get_binned_trend(x, y, nbins=nbins)\n",
"sigma_v, e_sigma_v = np.mean(std), np.std(std)\n",
"axs[0].set_title(r\"Satellites, $\\sigma_v = {:.1f} \\pm {:.1f} ~ \\mathrm{{km}} / \\mathrm{{s}}$\".format(sigma_v, e_sigma_v))\n",
"axs[0].hexbin(x, y, mincnt=1, bins=\"log\")\n",
"axs[0].plot(xrange, median, color=\"red\")\n",
"axs[0].fill_between(xrange, lower, upper, color=\"red\", alpha=0.3)\n",
"\n",
"axs[0].set_xlim(np.log10(1e12))\n",
"axs[0].set_ylim(0)\n",
"axs[0].set_xlabel(r\"$\\log M_{\\rm parent} ~ [M_\\odot / h]$\")\n",
"axs[0].set_ylabel(r\"$\\Delta V_{\\rm pec} ~ [\\mathrm{km} / \\mathrm{s}]$\")\n",
"\n",
"fig.tight_layout()\n",
"fig.savefig(\"../plots/residual_velocity_to_mass_subhaloes_parent.png\", dpi=300, bbox_inches=\"tight\")\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.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}