csiborgtools/notebooks/fitting.ipynb

141 lines
179 KiB
Text
Raw Normal View History

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "5a38ed25",
"metadata": {
"ExecuteTime": {
"end_time": "2023-04-12T14:25:46.519408Z",
"start_time": "2023-04-12T14:25:03.003304Z"
},
"scrolled": true
},
"outputs": [],
"source": [
"import sys\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"sys.path.append(\"../\")\n",
"import csiborgtools\n",
"\n",
"%matplotlib widget \n",
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "06a5b2ff",
"metadata": {},
"outputs": [],
"source": [
"paths = csiborgtools.read.CSiBORGPaths(**csiborgtools.paths_glamdring)\n",
"partreader = csiborgtools.read.ParticleReader(paths)\n",
"\n",
"\n",
"nsim = 7444\n",
"nsnap = max(paths.get_snapshots(nsim))\n",
"box = csiborgtools.read.BoxUnits(nsnap, nsim, paths)\n",
"\n",
"particle_archive = np.load(paths.split_path(nsnap, nsim))\n",
"clumpsarr = partreader.read_clumps(nsnap, nsim, cols=[\"index\", 'x', 'y', 'z'])\n",
"clumpid2arrpos = {ind: ii for ii, ind in enumerate(clumpsarr[\"index\"])}"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "382c5341",
"metadata": {},
"outputs": [],
"source": [
"nsim = 7492\n",
"cat = csiborgtools.read.ClumpsCatalogue(nsim, paths)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "b1a84840",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5350561d0be1413d98e3227df70d0e18",
"version_major": 2,
"version_minor": 0
},
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAA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3M6uX4ceCyy4Bnngn3igiiTpAAJAgiMkjNJOFHRCZ79zLxd/Ik0KMHsGYNcOml4V4VQdQJqgEkCIIgCD1++omlfU+eBK64gnX7kvgjGgAkAAmCIAhCC7sduPVWNuO3Vy8W+WvePNyrIoigQAIwAHJzc3HZZZehb9++4V4KYRSa80oQhL9YLMC8ecDgwUz8NWsW7hURRNAgH8A6QD5CUQJ5zBEE4Q92OxN/HFlmdi8RQlFJBfKOlCK7fSoy0pLCvZyohL6/KQJIxALkMUcQhFF27AC6dwd27XJvizDxN3LORjz16S6MnLMRRSUVPvdfvKPY535E7EFdwETDhzzmCIIwQl4eMGIEUF4O/OUvwLJl4V6RB3lHSlFpcwAAKm0O5B0p1Y0CcrFYaXMg0WrGiinXUsSQcEECkGj4kMccQRC+2LYNGDkSOHcOGDgQ+OijcK9Ik+z2qUi0ml2iLrt9qu6+/ohFIvYgAUjEBuQxRxCEHlu2ADfcAJw/D1x7LfDVV0CjRuFelSYZaUlYMeVaQzWA/ohFIvagJpA6QEWkBEEQUc633wI5OcCFC8zv73//Ay65JNyrChrUMKINfX9TBJAgCIKIZf7xDyb+hg0DvviCzfhtQGSkJZHwIzShLmCCIIhAIX/J6OeTT9hc32XLGpz4CwfUdRw9UAQ
"text/html": [
"\n",
" <div style=\"display: inline-block;\">\n",
" <div class=\"jupyter-widgets widget-label\" style=\"text-align: center;\">\n",
" Figure\n",
" </div>\n",
" <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydeXwTZf7HP5Ojl0BLC3KVQrlRsAhSUEBAOawHCiKueAC6rgeuArqr7LrrsSu4qwLr2lV/HqCsKIigrIrclxwWwSIo5SyWctPacvTKMb8/nj7JM5OZZJImT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IoigQAIwAHJzc3HZZZehb9++4V4KYRSa80oQhL9YLMC8ecDgwUz8NWsW7hURRNAgH8A6QD5CUQJ5zBEE4Q92OxN/HFlmdi8RQlFJBfKOlCK7fSoy0pLCvZyohL6/KQJIxALkMUcQhFF27AC6dwd27XJvizDxN3LORjz16S6MnLMRRSUVPvdfvKPY535E7EFdwETDhzzmCIIwQl4eMGIEUF4O/OUvwLJl4V6RB3lHSlFpcwAAKm0O5B0p1Y0CcrFYaXMg0WrGiinXUsSQcEECkGj4kMccQRC+2LYNGDkSOHcOGDgQ+OijcK9Ik+z2qUi0ml2iLrt9qu6+/ohFIvYgAUjEBuQxRxCEHlu2ADfcAJw/D1x7LfDVV0CjRuFelSYZaUlYMeVaQzWA/ohFIvagJpA6QEWkBEEQUc633wI5OcCFC8zv73//Ay65JNyrChrUMKINfX9TBJAgCIKIZf7xDyb+hg0DvviCzfhtQGSkJZHwIzShLmC
" </div>\n",
" "
],
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ismain = cat.ismain\n",
"\n",
"plt.figure()\n",
"plt.scatter(cat['totpartmass'][ismain], cat['mass_cl'][ismain], s=3, label=\"Ultimate parent halos\")\n",
"plt.scatter(cat['totpartmass'][~ismain], cat['mass_cl'][~ismain], s=3, label=\"Not ultimate parent halos\")\n",
"\n",
"\n",
"t = np.linspace(1e12, 1e15, 1000)\n",
"plt.plot(t, t, c=\"red\", ls=\"--\")\n",
"plt.xlabel(\"Total particle mass\")\n",
"plt.ylabel(\"Clump pass\")\n",
"plt.legend()\n",
"plt.xscale(\"log\")\n",
"plt.yscale(\"log\")\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2d9ac81d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "venv_galomatch",
"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.8.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}