mirror of
https://github.com/Richard-Sti/csiborgtools.git
synced 2024-12-23 03:08:01 +00:00
257 lines
786 KiB
Text
257 lines
786 KiB
Text
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 78,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"The autoreload extension is already loaded. To reload it, use:\n",
|
||
|
" %reload_ext autoreload\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from os.path import join\n",
|
||
|
"\n",
|
||
|
"import csiborgtools\n",
|
||
|
"import healpy\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import numpy\n",
|
||
|
"import scienceplots # noqa\n",
|
||
|
"from cache_to_disk import cache_to_disk, delete_disk_caches_for_function\n",
|
||
|
"from h5py import File\n",
|
||
|
"\n",
|
||
|
"import plt_utils\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"sim2boxsize = {\"csiborg\" : 677.7,\n",
|
||
|
" \"csiborg2_main\": 676.7,\n",
|
||
|
" \"BORG\": 677.7,\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"%load_ext autoreload\n",
|
||
|
"%autoreload 2"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 88,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"with File(\"/mnt/zfsusers/hdesmond/BORG_final/mcmc_9844.h5\", 'r') as f:\n",
|
||
|
" d = f[\"scalars/BORG_final_density\"][:]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 92,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"-1.0"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 92,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"d.min()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 127,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"@cache_to_disk(30)\n",
|
||
|
"def _plot_sky_projected_density(nsim, simname, grid, nside, MAS=\"PCS\",\n",
|
||
|
" dmin=0, dmax=220, volume_weight=True):\n",
|
||
|
" paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)\n",
|
||
|
" # nsnap = max(paths.get_snapshots(nsim, simname))\n",
|
||
|
" # Some work here to get the box\n",
|
||
|
" boxsize = sim2boxsize[simname]\n",
|
||
|
"\n",
|
||
|
" if simname == \"csiborg\":\n",
|
||
|
" field = numpy.load(paths.field(\"density\", MAS, grid, nsim, in_rsp=False))\n",
|
||
|
" elif simname == \"BORG\":\n",
|
||
|
" with File(\"/mnt/zfsusers/hdesmond/BORG_final/mcmc_9844.h5\", 'r') as f:\n",
|
||
|
" field = f[\"scalars/BORG_final_density\"][:]\n",
|
||
|
" field = field.astype(numpy.float32)\n",
|
||
|
" # field = field.T\n",
|
||
|
" field += 1\n",
|
||
|
" else:\n",
|
||
|
" with File(\"/mnt/extraspace/rstiskalek/csiborg2_main/fields/chain_15517_1024.hdf5\", 'r') as f:\n",
|
||
|
" field = f[\"density\"][:].T\n",
|
||
|
"\n",
|
||
|
" # field /= numpy.mean(field)\n",
|
||
|
" # field += 1\n",
|
||
|
"\n",
|
||
|
" angpos = csiborgtools.field.nside2radec(nside)\n",
|
||
|
" dist = numpy.linspace(dmin, dmax, 1000)\n",
|
||
|
" return csiborgtools.field.make_sky(field, angpos=angpos, dist=dist,\n",
|
||
|
" boxsize=boxsize, volume_weight=volume_weight)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 135,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def plot_sky_projected_density(nsim, simname, grid, nside, MAS=\"PCS\",\n",
|
||
|
" dmin=0, dmax=220, volume_weight=True, ext=\"png\",\n",
|
||
|
" to_save=False):\n",
|
||
|
" dmap = _plot_sky_projected_density(nsim, simname, grid, nside, MAS,\n",
|
||
|
" dmin, dmax, volume_weight)\n",
|
||
|
" obs = numpy.genfromtxt(\"/mnt/zfsusers/rstiskalek/csiborgtools/data/2MPP.txt\")\n",
|
||
|
" \n",
|
||
|
" dist = obs[:, 6] * 3e5 / 100\n",
|
||
|
" \n",
|
||
|
" mask = (dist > dmin) & (dist < dmax)\n",
|
||
|
" obs = obs[mask]\n",
|
||
|
"\n",
|
||
|
" print(obs[:, 2].min(), obs[:, 2].max())\n",
|
||
|
"\n",
|
||
|
" with plt.style.context(plt_utils.mplstyle):\n",
|
||
|
" healpy.mollview(numpy.log10(dmap), fig=0, title=\"\", unit=\"\", rot=75)\n",
|
||
|
"\n",
|
||
|
" healpy.projscatter(numpy.pi / 2 - obs[:, 2], obs[:, 1], s=0.05, c=\"red\",\n",
|
||
|
" label=\"2M++ galaxies\")\n",
|
||
|
" \n",
|
||
|
" # for name in [\"Virgo\", \"Fornax\"]:\n",
|
||
|
" # d, ra, dec = csiborgtools.clusters[name].spherical_pos\n",
|
||
|
" # ra *= numpy.pi / 180\n",
|
||
|
" # dec *= numpy.pi / 180\n",
|
||
|
" # healpy.projscatter([numpy.pi / 2 - dec], [ra], s=30, c=\"black\", marker='x')\n",
|
||
|
" # healpy.projscatter(obs[:, 2] - numpy.pi / 2, obs[:, 1], s=0.25, c=\"red\",\n",
|
||
|
" # label=\"2M++ galaxies\")\n",
|
||
|
" # healpy.projscatter(obs[:, 2] - numpy.pi / 2 , obs[:, 1], s=1, c=\"red\",\n",
|
||
|
" # label=\"2M++ galaxies\")\n",
|
||
|
"\n",
|
||
|
" # if plot_groups:\n",
|
||
|
" # groups = csiborgtools.read.TwoMPPGroups(fpath=\"/mnt/extraspace/rstiskalek/catalogs/2M++_group_catalog.dat\") # noqa\n",
|
||
|
" # healpy.projscatter(numpy.deg2rad(groups[\"DEC\"] + 90),\n",
|
||
|
" # numpy.deg2rad(groups[\"RA\"]), s=1, c=\"blue\",\n",
|
||
|
" # label=\"2M++ groups\")\n",
|
||
|
"\n",
|
||
|
" # if plot_halos is not None or plot_groups:\n",
|
||
|
" # plt.legend(markerscale=5)\n",
|
||
|
"\n",
|
||
|
" if to_save:\n",
|
||
|
" # fout = join(plt_utils.fout, f\"sky_density_{simname}_{nsim}_from_{dmin}_to_{dmax}_vol{volume_weight}.{ext}\") # noqa\n",
|
||
|
" fout = \"test.png\"\n",
|
||
|
" print(f\"Saving to `{fout}`.\")\n",
|
||
|
" plt.savefig(fout, dpi=plt_utils.dpi, bbox_inches=\"tight\")\n",
|
||
|
" plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 140,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"100%|██████████| 3145728/3145728 [06:06<00:00, 8572.34it/s]\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"-1.50601 1.48367\n",
|
||
|
"Saving to `test.png`.\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAzoAAAHdCAYAAADVbwynAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9d7SlWZreBf723p879vqwGd6nqcxKn1m+q7oatUBCOKGWRoDwDKwZZhg0YsEAYlgySN0zaOFBEk2vQYMGaTCN1K0un95UZWVVZkTciMgM76879nN77/nj3ee7WZihm/bV512rVlVF3Lj33O9855z33e/z/B7lvffMa17zmte85jWvec1rXvOa149R6d/uBzCvec1rXvOa17zmNa95zWtev9E1H3TmNa95zWte85rXvOY1r3n92NV80JnXvOY1r3nNa17zmte85vVjV/NBZ17zmte85jWvec1rXvOa149dzQedec1rXvOa17zmNa95zWteP3Y1H3TmNa95zWte85rXvOY1r3n92FX02/0A5jWvec1rXr8x9aWf/LMo55muJdSZQleebMuiageANwqUwmtQ1hOPanRpwTlwQKRxicFmBptofCTfw+QWk9e4SINSuFiDApvKf+vCEY1rzLjAGwORbr6ncuFnxwavFcp5UArblo+fuhVhM4VNtPyswmFyh3IeZT14jwohCF4rAFyiqXryGD9ZuvboMvw7wGYamyii3BGNLdp6qm5E1ZF/pysPCpKBRZcObxQuUnzrb/3J3+ynal7zmte85vVbUGqeozOvec1rXr8z6qvP/BvosgbAKyU7dyXNvU8iXKTxiabqRNhU4w0oKw2+KRymsKjKyfCiFHgZKrx8C7zReKPwkcZFCtsyeCMDhLJeBowwJCgHurQymHjwiWZ0IKVuKZKRR1defr6TgUHZ3f/oWgYIF+vmZ88eh3KeKLdgwwDjPMp7vFZ4o5shykWq+d0neyK8hmToqNoaF4HX4M3s9wrXoYJ46sPA5IkmFm3DEBc+6pTf/d8AdTembslApBxEU0c8rDG5PA8u0qAVPlJU3UieF0B5uS4AunQoJ3+mas/XvvWv/IbfG/Oa17zmNa9fe80HnXnNa17z+k2on3zxT4NW4DyEQWI2eKjKArJhcVlMsZRAGAJw0tgDRIU006b0xGPbfG9dObxW1G0jm5t6d9jRlWuGHeU8WI+Pdfh50rQD8rhAmnitsKnGtmRyUM7jImn8XRy2KGEgQkGdKuoWaAvxWAYLafTD7wDYWLYjNlGYypPu2GYg8kZ+pqp3B4SqE1G35OtRYErwCqZrGmU96Y4ML8nQyuPN5HskOzU20bhUUWeaqq3YOQV1z4FV6FLhEs+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G0dtmTyPHbuVnLflbverxmswkUKtOKbf3tOn5vXvOb1u7vmg8685jWv35k1mcC/8+/Ak0/CV7/Kn/hn/4+8duYUZWpAe2zfEm1ERLnC5GGACPKrqgfFmiWyls/f+YBvnzqN226RbGlMLoNO1fVkG4p0W5rcZjNSgql2JVHTZU3Zlya4f81S9DXTvYpoLJ6TOlMN/YvU8sL1dd48dBoKI9Q0RyCQgU1EfqVq8JH8Wd3y2EM5CwsT/uCRH3Cv7POt6yeYbLbpXInl36Wequ/QhaZ1X352OnDoisbboWuPM7INmq5olIP2fUs09Q1Oueoopnuk2e1dl39f9hVlXxGNRXqnrA/XQfwpdVtTZ4rxPk255ClXLEQOjIdaowpN56ohGXiyLcfnLn/IVCd8+uEV/sujX8DXAl9QwYODET+TzmtwDm+MIKi9B+t2vU5xhNdaBiPAtWJsFqFLi0sM+Vr6I3CDuhW8QQ7Krmr+nbKyOXGxXO/ubUc8kcdStTQ2VQyPKOqWJx7JsGcKT+QsT29c4q1HTuMrTeeeky2Jl+1b3VJUbcXCtQq
|
||
|
"text/plain": [
|
||
|
"<Figure size 850x540 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# delete_disk_caches_for_function(\"_plot_sky_projected_density\")\n",
|
||
|
"plot_sky_projected_density(15517, \"csiborg2_main\", 512, 512, \"PCS\", dmin=100,\n",
|
||
|
" dmax=125, volume_weight=True, to_save=True)\n",
|
||
|
"# plt.savefig(\"test.png\", dpi=300)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
},
|
||
|
{
|
||
|
"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
|
||
|
}
|