{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Matching of haloes to clusters" ] }, { "cell_type": "code", "execution_count": 144, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The autoreload extension is already loaded. To reload it, use:\n", " %reload_ext autoreload\n" ] } ], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from astropy.cosmology import FlatLambdaCDM\n", "\n", "import pandas as pd\n", "\n", "%load_ext autoreload\n", "%autoreload 2\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load in the data\n", "Harry: the exact routine may not work, I had to edit the raw .txt file a little" ] }, { "cell_type": "code", "execution_count": 124, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[34.14606699 9.28692846 11.11279198 16.85641068 3.71636485 33.43032196\n", " 24.65595192 29.91007806 40.31604335 9.346801 ]\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
halo_IDKINDl[deg]b[deg]d[kpc]zRdelta[kpc]rhos[Msol/kpc^3]rs[kpc]prof[keywrd]#1#2#3FOVDiam[deg]
0halo_647110CLUSTER-47.6629.96-10.011424523.71643822.01573663.92743kZHAO1.03.01.037.74875
1halo_10128802CLUSTER-90.7625.97-10.003101975.98611499.11522294.56973kZHAO1.03.01.060.00762
2halo_1338057CLUSTER-35.42-6.15-10.003712738.50593219.40743413.73423kZHAO1.03.01.069.19885
3halo_20419495CLUSTER87.4288.09-10.005633082.73596355.51967465.36921kZHAO1.03.01.051.83070
4halo_20355327CLUSTER-94.4875.29-10.001241644.94635981.23866240.83028kZHAO1.03.01.0119.66328
5halo_2503990CLUSTER-35.24-12.06-10.011183164.45600754.77263478.21044kZHAO1.03.01.027.04669
6halo_21251859CLUSTER31.1544.45-10.008242731.34595715.63380413.32640kZHAO1.03.01.031.59913
7halo_745775CLUSTER-47.4936.08-10.010002878.14597011.32933435.71418kZHAO1.03.01.027.49495
8halo_3003328CLUSTER39.76-46.41-10.013493172.97602266.09230479.82208kZHAO1.03.01.022.50342
9halo_4200359CLUSTER-28.67-22.77-10.003121826.88621061.51007270.55674kZHAO1.03.01.055.35257
\n", "
" ], "text/plain": [ " halo_ID KIND l[deg] b[deg] d[kpc] z Rdelta[kpc] \\\n", "0 halo_647110 CLUSTER -47.66 29.96 -1 0.01142 4523.71 \n", "1 halo_10128802 CLUSTER -90.76 25.97 -1 0.00310 1975.98 \n", "2 halo_1338057 CLUSTER -35.42 -6.15 -1 0.00371 2738.50 \n", "3 halo_20419495 CLUSTER 87.42 88.09 -1 0.00563 3082.73 \n", "4 halo_20355327 CLUSTER -94.48 75.29 -1 0.00124 1644.94 \n", "5 halo_2503990 CLUSTER -35.24 -12.06 -1 0.01118 3164.45 \n", "6 halo_21251859 CLUSTER 31.15 44.45 -1 0.00824 2731.34 \n", "7 halo_745775 CLUSTER -47.49 36.08 -1 0.01000 2878.14 \n", "8 halo_3003328 CLUSTER 39.76 -46.41 -1 0.01349 3172.97 \n", "9 halo_4200359 CLUSTER -28.67 -22.77 -1 0.00312 1826.88 \n", "\n", " rhos[Msol/kpc^3] rs[kpc] prof[keywrd] #1 #2 #3 FOVDiam[deg] \n", "0 643822.01573 663.92743 kZHAO 1.0 3.0 1.0 37.74875 \n", "1 611499.11522 294.56973 kZHAO 1.0 3.0 1.0 60.00762 \n", "2 593219.40743 413.73423 kZHAO 1.0 3.0 1.0 69.19885 \n", "3 596355.51967 465.36921 kZHAO 1.0 3.0 1.0 51.83070 \n", "4 635981.23866 240.83028 kZHAO 1.0 3.0 1.0 119.66328 \n", "5 600754.77263 478.21044 kZHAO 1.0 3.0 1.0 27.04669 \n", "6 595715.63380 413.32640 kZHAO 1.0 3.0 1.0 31.59913 \n", "7 597011.32933 435.71418 kZHAO 1.0 3.0 1.0 27.49495 \n", "8 602266.09230 479.82208 kZHAO 1.0 3.0 1.0 22.50342 \n", "9 621061.51007 270.55674 kZHAO 1.0 3.0 1.0 55.35257 " ] }, "execution_count": 124, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\n", "cosmo = FlatLambdaCDM(H0=100, Om0=0.307)\n", "\n", "data0 = pd.read_csv(\"/mnt/users/rstiskalek/csiborgtools/data/top10_pwave_coords.txt\", sep='\\s+')\n", "data = {}\n", "\n", "data[\"id\"] = np.array([int(x.split(\"_\")[-1]) for x in data0[\"halo_ID\"].values])\n", "data[\"l\"] = data0[\"l[deg]\"].values\n", "data[\"b\"] = data0[\"b[deg]\"].values\n", "data[\"dist\"] = cosmo.comoving_distance(data0[\"z\"].values).value\n", "\n", "print(data[\"dist\"])\n", "data0" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load in the halo catalogue" ] }, { "cell_type": "code", "execution_count": 126, "metadata": {}, "outputs": [], "source": [ "boxsize = 677.7\n", "\n", "halos = np.load(\"/users/hdesmond/Mmain/Mmain_9844.npy\")\n", "names = [\"id\", \"x\", \"y\", \"z\", \"M\"]\n", "halos = {k: halos[:, i] for i, k in enumerate(names)}\n", "halos[\"id\"] = halos[\"id\"].astype(int)\n", "# Coordinates are in box units. Convert to Mpc/h\n", "for p in (\"x\", \"y\", \"z\"):\n", " halos[p] = halos[p] * boxsize\n", "\n", "halos[\"dist\"] = np.sqrt((halos[\"x\"] - boxsize/2)**2 + (halos[\"y\"] - boxsize/2)**2 + (halos[\"z\"] - boxsize/2)**2)\n" ] }, { "cell_type": "code", "execution_count": 142, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "5791\n" ] } ], "source": [ "# Find which item in the catalogue matches the nth halo in the .txt file\n", "n = 0\n", "k = np.where(data[\"id\"][n] == halos[\"id\"])[0][0]\n", "print(k)" ] }, { "cell_type": "code", "execution_count": 143, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(34.14606698507264, 149.24046381654668)" ] }, "execution_count": 143, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data[\"dist\"][n], halos[\"dist\"][k]" ] } ], "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 }