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": [
|
2023-12-18 17:09:08 +00:00
|
|
|
"# flake8: noqa\n",
|
|
|
|
"\n",
|
2023-12-13 16:08:25 +00:00
|
|
|
"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",
|
2023-12-18 17:09:08 +00:00
|
|
|
"execution_count": 22,
|
2023-12-13 16:08:25 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2023-12-18 17:09:08 +00:00
|
|
|
"# flake8: noq\n",
|
2023-12-13 16:08:25 +00:00
|
|
|
"\n",
|
|
|
|
"@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",
|
|
|
|
" reader = csiborgtools.read.CSiBORG2Field(nsim, paths, kind=kind)\n",
|
|
|
|
" 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",
|
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",
|
2023-12-18 17:09:08 +00:00
|
|
|
"execution_count": 28,
|
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",
|
2023-12-18 17:09:08 +00:00
|
|
|
"execution_count": 30,
|
2023-12-13 16:08:25 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
2023-12-18 17:09:08 +00:00
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAzoAAAHdCAYAAADVbwynAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9d7RtX3bXB37Wzifec+PL+d373vvlnOtXpapSSSDaGLAtyyAMtgk2eLixcbvNAHsMbBraFlJ3uz0YYLsRIIIMGIRQVqVf1S/n+MJ9Ob+bT9559R9zrX3eLYENRqAq6cx/bjjn7L322uHMueY3KK21ZhrTmMY0pjGNaUxjGtOYxjR+E4XzGz2AaUxjGtOYxjSmMY1pTGMa0/j1jmmhM41pTGMa05jGNKYxjWlM4zddTAudaUxjGtOYxjSmMY1pTGMav+liWuhMYxrTmMY0pjGNaUxjGtP4TRfTQmca05jGNKYxjWlMYxrTmMZvupgWOtOYxjSmMY1pTGMa05jGNH7ThfcbPYBpTGMa05jGr098+XN/rvq9iFz6B4Ndrzfu5QC4SQGAdhQASWfyVdC8PpJf8hKA0eFG9ZqTabxxUf3tDTL5/Hwkr6fyGXecV+9RRYnKyupv7d+3vuYotFLVn/FSCEDpyf/CHdmOk08+r3JNed820s7urzF7TACFL7/X76Xy3hl5b9DLd32mCF3iObf6+82f+s+YxjSmMY1pfO+HmvroTGMa05jGd0d8/rf9PwEIuimUk0ezKjUqNsm5axL5Ql4vZiKyll+9V7tQBFIING5K0XJ/YeBkJXpSC1DWJPnXjiJtT4oGJ9cwqS/w4gJ135iy5uS93aM+9bVJAVRbz8hapqjYyShqkyLCjg0g6GfkkTvZfnrfDh21q2hJOz5OJvvfXvaZ/yypX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xJPMRecOh9BTrjxtO0yqM9k0Kv5lLJfGcQ9DV1LbkmOJZt+rqlK4UebUNTf+w7SaBY+qrl8+dJUlD/EbCq0dNZ04Ok6wBnkGe2WtDu4A5z4PDqromwv6koBruN0ISt8uqUPINNypru+Smw5V0FJ3V1IxJBpTXPXyjhKeVQpsOpddP0ErhJFn1v3y2VinexfP23igoak51jb31N6bqc9OYxjS+t2Na6ExjGtP4noiXf+i/A2C84EmCnklyHuQpP7L6Dd55+hCvnlzh8e2LvHr6JM3PDITsBYEN1T6RDDRraup3JcFLW5AslHgLIz73qzd4/fgyScMl2DbwpbY8HjvnYfu0jKN5U+EPpMtiuxhODt3jstJev2dkmfc4uGYB3RYPZQBeXvDc9Qu8cXiFNHJxE5MAM0mgc9EwINzR9I+Y/d5QHPg3rwBwb9AC4ECry6WfPQFAvGCS5Zqmec1AnjLpDtn928JLu5PfbVJfW8/JWjKQ0YJD6ct421clyY7nnKrj1Loh/wu3c0qTeA+XjKDASHPnK6YQuu2TH42Jztbw5DTQviaffenipwzDiCdvnudvH/sChePib40q7pMl7rtbPcpWw/zPTFBRgGNghp06zigDz9kl8JC3ZTuWn7S94tG+LvvuHXbNMWt2TkNLphU3oSoy6+uy/8JXFcfo3ufl883zPuGOxisLnlxb5dsPrND5TO8SZAARjYh2CrZXfGYvSAHSPeLTuGdgfamFIepK8tuq0Mn/ZUO9owHNWznbp30cUwd2LmcVt8sz3bPRvEttW373hgVuWuL1EjAFjfacqhBUmYHKxRllu1bt00LutOdUnysiKf6G+3zCrnz+1b//J5nGNKYxje/2mBY605jGNL5r4vkf/jEAgv6EXzHcY5LSrZLNB+X38QGTSM/F/Cc/9hqd0YBalnO32eGtA8vU3JhXj8kKu03yiwCaN+Vx17opK+HDvT5Jx+GFa2dZe9KhNY55L36UTJoFOPI24bCku8caLyo
|
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",
|
|
|
|
" dmax=125, survey_name=\"2M++\", to_save=False)\n",
|
2023-12-13 16:08:25 +00:00
|
|
|
"# 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
|
|
|
|
}
|