2023-12-13 16:08:25 +00:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-12-18 17:09:08 +00:00
|
|
|
"execution_count": 1,
|
2023-12-13 16:08:25 +00:00
|
|
|
"metadata": {},
|
2023-12-18 17:09:08 +00:00
|
|
|
"outputs": [],
|
2023-12-13 16:08:25 +00:00
|
|
|
"source": [
|
|
|
|
"from os.path import join\n",
|
|
|
|
"\n",
|
|
|
|
"import csiborgtools\n",
|
|
|
|
"import healpy\n",
|
|
|
|
"import matplotlib.pyplot as plt\n",
|
|
|
|
"import numpy\n",
|
2023-12-18 17:09:08 +00:00
|
|
|
"import scienceplots\n",
|
2023-12-13 16:08:25 +00:00
|
|
|
"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",
|
|
|
|
"%load_ext autoreload\n",
|
|
|
|
"%autoreload 2"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2024-01-30 16:14:07 +00:00
|
|
|
"execution_count": 8,
|
2023-12-13 16:08:25 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"@cache_to_disk(30)\n",
|
2023-12-18 17:09:08 +00:00
|
|
|
"def _plot_sky_projected_density(nsim, simname, grid, nside, MAS, survey_name,\n",
|
|
|
|
" dmin, dmax):\n",
|
2023-12-13 16:08:25 +00:00
|
|
|
" paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)\n",
|
2023-12-18 17:09:08 +00:00
|
|
|
" boxsize = csiborgtools.simname2boxsize(simname)\n",
|
2023-12-13 16:08:25 +00:00
|
|
|
"\n",
|
2023-12-18 17:09:08 +00:00
|
|
|
" if simname == \"csiborg1\":\n",
|
|
|
|
" reader = csiborgtools.read.CSiBORG1Field(nsim, paths)\n",
|
|
|
|
" elif \"csiborg2\" in simname:\n",
|
|
|
|
" kind = simname.split(\"_\")[-1]\n",
|
2024-01-30 16:14:07 +00:00
|
|
|
" reader = csiborgtools.read.CSiBORG2Field(nsim, kind, paths)\n",
|
2023-12-18 17:09:08 +00:00
|
|
|
" else:\n",
|
|
|
|
" raise ValueError(f\"Unknown simname `{simname}`.\")\n",
|
|
|
|
"\n",
|
|
|
|
" field = reader.density_field(MAS, grid)\n",
|
|
|
|
"\n",
|
|
|
|
" if survey_name == \"2M++\":\n",
|
|
|
|
" survey = csiborgtools.read.TwoMPPGalaxies()\n",
|
|
|
|
" dist = survey[\"ZCMB\"] * 3e5 / 100\n",
|
|
|
|
" ra, dec = survey[\"RA\"], survey[\"DEC\"]\n",
|
|
|
|
" ra *= numpy.pi / 180\n",
|
|
|
|
" dec *= numpy.pi / 180\n",
|
|
|
|
" elif survey_name == \"SDSS\":\n",
|
|
|
|
" survey = csiborgtools.SDSS()()\n",
|
|
|
|
" dist = survey[\"DIST\"]\n",
|
|
|
|
" ra, dec = survey[\"RA\"], survey[\"DEC\"]\n",
|
|
|
|
" ra *= numpy.pi / 180\n",
|
|
|
|
" dec *= numpy.pi / 180\n",
|
2024-01-30 16:14:07 +00:00
|
|
|
" elif survey_name == \"csiborg2\":\n",
|
|
|
|
" cat = csiborgtools.read.CSiBORG2Catalogue(\n",
|
|
|
|
" nsim, 99, \"main\", paths, bounds={\"totmass\": (1e12, None)})\n",
|
|
|
|
" coord = cat[\"spherical_pos\"]\n",
|
|
|
|
" dist, ra, dec = coord[:, 0], coord[:, 1], coord[:, 2]\n",
|
|
|
|
" ra *= numpy.pi / 180\n",
|
|
|
|
" dec *= numpy.pi / 180\n",
|
2023-12-13 16:08:25 +00:00
|
|
|
" else:\n",
|
2023-12-18 17:09:08 +00:00
|
|
|
" raise ValueError(f\"Unknown survey name `{survey_name}`.\")\n",
|
|
|
|
" \n",
|
|
|
|
" mask = (dist > dmin) & (dist < dmax)\n",
|
|
|
|
" ra = ra[mask]\n",
|
|
|
|
" dec = dec[mask]\n",
|
2023-12-13 16:08:25 +00:00
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
" angpos = csiborgtools.field.nside2radec(nside)\n",
|
|
|
|
" dist = numpy.linspace(dmin, dmax, 1000)\n",
|
2023-12-18 17:09:08 +00:00
|
|
|
" dmap = csiborgtools.field.make_sky(field, angpos=angpos, dist=dist,\n",
|
|
|
|
" boxsize=boxsize)\n",
|
|
|
|
" return dmap, ra, dec"
|
2023-12-13 16:08:25 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2024-01-30 16:14:07 +00:00
|
|
|
"execution_count": 9,
|
2023-12-13 16:08:25 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"def plot_sky_projected_density(nsim, simname, grid, nside, MAS=\"PCS\",\n",
|
2023-12-18 17:09:08 +00:00
|
|
|
" dmin=0, dmax=220, survey_name=\"2M++\",\n",
|
|
|
|
" ext=\"png\", to_save=False):\n",
|
|
|
|
" dmap, ra, dec = _plot_sky_projected_density(\n",
|
|
|
|
" nsim, simname, grid, nside, MAS, survey_name, dmin, dmax)\n",
|
2023-12-13 16:08:25 +00:00
|
|
|
" \n",
|
|
|
|
" with plt.style.context(plt_utils.mplstyle):\n",
|
2023-12-18 17:09:08 +00:00
|
|
|
" healpy.mollview(numpy.log10(dmap), fig=0, title=\"\", unit=\"\", rot=90)\n",
|
2023-12-13 16:08:25 +00:00
|
|
|
"\n",
|
2023-12-18 17:09:08 +00:00
|
|
|
" healpy.projscatter(numpy.pi / 2 - dec, ra, s=0.05, c=\"red\",\n",
|
2023-12-13 16:08:25 +00:00
|
|
|
" label=\"2M++ galaxies\")\n",
|
|
|
|
"\n",
|
|
|
|
" if to_save:\n",
|
2023-12-18 17:09:08 +00:00
|
|
|
" fout = join(plt_utils.fout, f\"sky_density_{simname}_{nsim}_from_{dmin}_to_{dmax}.{ext}\") # noqa\n",
|
2023-12-13 16:08:25 +00:00
|
|
|
" print(f\"Saving to `{fout}`.\")\n",
|
|
|
|
" plt.savefig(fout, dpi=plt_utils.dpi, bbox_inches=\"tight\")\n",
|
|
|
|
" plt.show()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2024-01-30 16:14:07 +00:00
|
|
|
"execution_count": 3,
|
2023-12-13 16:08:25 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
2024-01-30 16:14:07 +00:00
|
|
|
{
|
|
|
|
"ename": "NameError",
|
|
|
|
"evalue": "name 'hp' is not defined",
|
|
|
|
"output_type": "error",
|
|
|
|
"traceback": [
|
|
|
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
|
|
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
|
|
|
"Cell \u001b[0;32mIn[3], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mhp\u001b[49m\n",
|
|
|
|
"\u001b[0;31mNameError\u001b[0m: name 'hp' is not defined"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": []
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 10,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stderr",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"100%|██████████| 196608/196608 [00:22<00:00, 8765.57it/s]\n"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"Saving to `../plots/sky_density_csiborg2_main_15517_from_100_to_125.png`.\n"
|
|
|
|
]
|
|
|
|
},
|
2023-12-13 16:08:25 +00:00
|
|
|
{
|
|
|
|
"data": {
|
2024-01-30 16:14:07 +00:00
|
|
|
"image/png": "iVBORw0KGg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9xZbiPhONyqW8ExYY3ph7TtbHM88ZWLvTvRiuE2A0iYFXLoBZD9EKk7QjBiSoT+SGf/8fEf6LxRYFYnU++0eSHB76FU8+eAHCzYTeE8MaDDG5TwEY8TsqyuLp9BH1DzItheRyfzXKnaQDZDTmylOX2tj4OLU9zp7WPg6szlDtCVhrjnHmc5VpPmqZVi0cMAKBvuqLK4odVZzRZCjmYm+ZOQz++JGO36BgrDrneGAANEwWiF1aTTX25CAiBv1SqUAAV8HxCfYuuFsQ1lLwI1t22pLi3RRevUuGwfaRoHHaziZeQCVSJ5YMSqu/zkQ+zfHBY0PFU3+cjl8ZwUxJ36wY4MSmof1ajwpGlSW50pnE1BadeIrYSku+OKkU5h0/f/ICfP3gWz9NIrHnstSdF4mnGSUgWl/pGcBOgluD09BheziTpWlzpHoboL+4BZxw3b5JyLG43DAHg61DsjIwkXgTENl2OLE9y3xTVMbdOwYsqXHaDREPWida3SHa8uIoWOeGFkkQYVSjVvE0oSci2W/0/rzFWdbyzmivPho8fk6tr7MbPR+5zrgvnz8Pbb4P2B9MHa6ihhhr+NKKW6NRQQw1/JvDG1/1zAMotKooTorghsisoY0eWsvze1w3jKQpBo8MbjyeIzypc6x5m7YwIBmOPRKDtJkPeuT5OQTM5vJwl16AhpTxmlR0oQcDZzGOeJ1qYbOvg/YPDJMtl/vFnf5P/17d+I0eezrJv/AW/lD7D4YUZFDvgVvsAh19O894xQfF64/4ENzvSlNt
|
2023-12-13 16:08:25 +00:00
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 850x540 with 2 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"# delete_disk_caches_for_function(\"_plot_sky_projected_density\")\n",
|
2023-12-18 17:09:08 +00:00
|
|
|
"plot_sky_projected_density(15517, \"csiborg2_main\", 1024, 128, \"SPH\", dmin=100,\n",
|
2024-01-30 16:14:07 +00:00
|
|
|
" dmax=125, survey_name=\"csiborg2\", to_save=True)"
|
2023-12-13 16:08:25 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"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
|
|
|
|
}
|