mirror of
https://github.com/Richard-Sti/csiborgtools.git
synced 2024-12-23 08:18:02 +00:00
405 lines
12 KiB
Text
405 lines
12 KiB
Text
|
{
|
||
|
"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": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>halo_ID</th>\n",
|
||
|
" <th>KIND</th>\n",
|
||
|
" <th>l[deg]</th>\n",
|
||
|
" <th>b[deg]</th>\n",
|
||
|
" <th>d[kpc]</th>\n",
|
||
|
" <th>z</th>\n",
|
||
|
" <th>Rdelta[kpc]</th>\n",
|
||
|
" <th>rhos[Msol/kpc^3]</th>\n",
|
||
|
" <th>rs[kpc]</th>\n",
|
||
|
" <th>prof[keywrd]</th>\n",
|
||
|
" <th>#1</th>\n",
|
||
|
" <th>#2</th>\n",
|
||
|
" <th>#3</th>\n",
|
||
|
" <th>FOVDiam[deg]</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>0</th>\n",
|
||
|
" <td>halo_647110</td>\n",
|
||
|
" <td>CLUSTER</td>\n",
|
||
|
" <td>-47.66</td>\n",
|
||
|
" <td>29.96</td>\n",
|
||
|
" <td>-1</td>\n",
|
||
|
" <td>0.01142</td>\n",
|
||
|
" <td>4523.71</td>\n",
|
||
|
" <td>643822.01573</td>\n",
|
||
|
" <td>663.92743</td>\n",
|
||
|
" <td>kZHAO</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>3.0</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>37.74875</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>halo_10128802</td>\n",
|
||
|
" <td>CLUSTER</td>\n",
|
||
|
" <td>-90.76</td>\n",
|
||
|
" <td>25.97</td>\n",
|
||
|
" <td>-1</td>\n",
|
||
|
" <td>0.00310</td>\n",
|
||
|
" <td>1975.98</td>\n",
|
||
|
" <td>611499.11522</td>\n",
|
||
|
" <td>294.56973</td>\n",
|
||
|
" <td>kZHAO</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>3.0</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>60.00762</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>halo_1338057</td>\n",
|
||
|
" <td>CLUSTER</td>\n",
|
||
|
" <td>-35.42</td>\n",
|
||
|
" <td>-6.15</td>\n",
|
||
|
" <td>-1</td>\n",
|
||
|
" <td>0.00371</td>\n",
|
||
|
" <td>2738.50</td>\n",
|
||
|
" <td>593219.40743</td>\n",
|
||
|
" <td>413.73423</td>\n",
|
||
|
" <td>kZHAO</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>3.0</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>69.19885</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>halo_20419495</td>\n",
|
||
|
" <td>CLUSTER</td>\n",
|
||
|
" <td>87.42</td>\n",
|
||
|
" <td>88.09</td>\n",
|
||
|
" <td>-1</td>\n",
|
||
|
" <td>0.00563</td>\n",
|
||
|
" <td>3082.73</td>\n",
|
||
|
" <td>596355.51967</td>\n",
|
||
|
" <td>465.36921</td>\n",
|
||
|
" <td>kZHAO</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>3.0</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>51.83070</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>halo_20355327</td>\n",
|
||
|
" <td>CLUSTER</td>\n",
|
||
|
" <td>-94.48</td>\n",
|
||
|
" <td>75.29</td>\n",
|
||
|
" <td>-1</td>\n",
|
||
|
" <td>0.00124</td>\n",
|
||
|
" <td>1644.94</td>\n",
|
||
|
" <td>635981.23866</td>\n",
|
||
|
" <td>240.83028</td>\n",
|
||
|
" <td>kZHAO</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>3.0</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>119.66328</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>5</th>\n",
|
||
|
" <td>halo_2503990</td>\n",
|
||
|
" <td>CLUSTER</td>\n",
|
||
|
" <td>-35.24</td>\n",
|
||
|
" <td>-12.06</td>\n",
|
||
|
" <td>-1</td>\n",
|
||
|
" <td>0.01118</td>\n",
|
||
|
" <td>3164.45</td>\n",
|
||
|
" <td>600754.77263</td>\n",
|
||
|
" <td>478.21044</td>\n",
|
||
|
" <td>kZHAO</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>3.0</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>27.04669</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>6</th>\n",
|
||
|
" <td>halo_21251859</td>\n",
|
||
|
" <td>CLUSTER</td>\n",
|
||
|
" <td>31.15</td>\n",
|
||
|
" <td>44.45</td>\n",
|
||
|
" <td>-1</td>\n",
|
||
|
" <td>0.00824</td>\n",
|
||
|
" <td>2731.34</td>\n",
|
||
|
" <td>595715.63380</td>\n",
|
||
|
" <td>413.32640</td>\n",
|
||
|
" <td>kZHAO</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>3.0</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>31.59913</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>7</th>\n",
|
||
|
" <td>halo_745775</td>\n",
|
||
|
" <td>CLUSTER</td>\n",
|
||
|
" <td>-47.49</td>\n",
|
||
|
" <td>36.08</td>\n",
|
||
|
" <td>-1</td>\n",
|
||
|
" <td>0.01000</td>\n",
|
||
|
" <td>2878.14</td>\n",
|
||
|
" <td>597011.32933</td>\n",
|
||
|
" <td>435.71418</td>\n",
|
||
|
" <td>kZHAO</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>3.0</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>27.49495</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>8</th>\n",
|
||
|
" <td>halo_3003328</td>\n",
|
||
|
" <td>CLUSTER</td>\n",
|
||
|
" <td>39.76</td>\n",
|
||
|
" <td>-46.41</td>\n",
|
||
|
" <td>-1</td>\n",
|
||
|
" <td>0.01349</td>\n",
|
||
|
" <td>3172.97</td>\n",
|
||
|
" <td>602266.09230</td>\n",
|
||
|
" <td>479.82208</td>\n",
|
||
|
" <td>kZHAO</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>3.0</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>22.50342</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>9</th>\n",
|
||
|
" <td>halo_4200359</td>\n",
|
||
|
" <td>CLUSTER</td>\n",
|
||
|
" <td>-28.67</td>\n",
|
||
|
" <td>-22.77</td>\n",
|
||
|
" <td>-1</td>\n",
|
||
|
" <td>0.00312</td>\n",
|
||
|
" <td>1826.88</td>\n",
|
||
|
" <td>621061.51007</td>\n",
|
||
|
" <td>270.55674</td>\n",
|
||
|
" <td>kZHAO</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>3.0</td>\n",
|
||
|
" <td>1.0</td>\n",
|
||
|
" <td>55.35257</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"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
|
||
|
}
|