csiborgtools/scripts/dist.ipynb

203 lines
251 KiB
Text
Raw Normal View History

{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2022-10-20T13:24:14.926839Z",
"start_time": "2022-10-20T13:24:14.426124Z"
}
},
"outputs": [],
"source": [
"import numpy as np\n",
"import healpy as hp\n",
"%matplotlib notebook\n",
"import matplotlib.pyplot as plt\n",
"# Local imports\n",
"try:\n",
2022-10-20 22:37:33 +00:00
" import csiborgtools\n",
"except ModuleNotFoundError:\n",
" import sys\n",
" sys.path.append(\"../\")\n",
2022-10-20 22:37:33 +00:00
" import csiborgtools\n",
"import utils\n",
"\n",
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 110,
"metadata": {
"ExecuteTime": {
"end_time": "2022-10-20T14:17:46.639414Z",
"start_time": "2022-10-20T14:17:44.896731Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 3.30it/s]\n"
]
}
],
"source": [
"obs = utils.load_2mpp()\n",
"\n",
"\n",
"cols = [\"ra\", \"dec\", \"mass_cl\", \"dist\"]\n",
"\n",
"mmains = utils.load_mmains(1)\n",
2022-10-20 22:37:33 +00:00
"mmains = csiborgtools.utils.list_to_ndarray(mmains, cols)\n",
"sim = mmains[0, ...]\n",
2022-10-20 22:37:33 +00:00
"sim = csiborgtools.utils.array_to_structured(sim ,cols)\n",
"\n",
"planck = utils.load_planck2015()"
]
},
{
"cell_type": "code",
"execution_count": 119,
"metadata": {
"ExecuteTime": {
"end_time": "2022-10-20T14:21:43.591434Z",
"start_time": "2022-10-20T14:21:43.437257Z"
}
},
"outputs": [
{
"data": {
2022-10-20 22:37:33 +00:00
"application/javascript": "/* Put everything inside the global mpl namespace */\n/* global mpl */\nwindow.mpl = {};\n\nmpl.get_websocket_type = function () {\n if (typeof WebSocket !== 'undefined') {\n return WebSocket;\n } else if (typeof MozWebSocket !== 'undefined') {\n return MozWebSocket;\n } else {\n alert(\n 'Your browser does not have WebSocket support. ' +\n 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n 'Firefox 4 and 5 are also supported but you ' +\n 'have to enable WebSockets in about:config.'\n );\n }\n};\n\nmpl.figure = function (figure_id, websocket, ondownload, parent_element) {\n this.id = figure_id;\n\n this.ws = websocket;\n\n this.supports_binary = this.ws.binaryType !== undefined;\n\n if (!this.supports_binary) {\n var warnings = document.getElementById('mpl-warnings');\n if (warnings) {\n warnings.style.display = 'block';\n warnings.textContent =\n 'This browser does not support binary websocket messages. ' +\n 'Performance may be slow.';\n }\n }\n\n this.imageObj = new Image();\n\n this.context = undefined;\n this.message = undefined;\n this.canvas = undefined;\n this.rubberband_canvas = undefined;\n this.rubberband_context = undefined;\n this.format_dropdown = undefined;\n\n this.image_mode = 'full';\n\n this.root = document.createElement('div');\n this.root.setAttribute('style', 'display: inline-block');\n this._root_extra_style(this.root);\n\n parent_element.appendChild(this.root);\n\n this._init_header(this);\n this._init_canvas(this);\n this._init_toolbar(this);\n\n var fig = this;\n\n this.waiting = false;\n\n this.ws.onopen = function () {\n fig.send_message('supports_binary', { value: fig.supports_binary });\n fig.send_message('send_image_mode', {});\n if (fig.ratio !== 1) {\n fig.send_message('set_device_pixel_ratio', {\n device_pixel_ratio: fig.ratio,\n });\n }\n fig.send_message('refresh', {});\n };\n\n this.imageObj.onload = function () {\n if (fig.image_mode === 'full') {\n // Full images could contain transparency (where diff images\n // almost always do), so we need to clear the canvas so that\n // there is no ghosting.\n fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n }\n fig.context.drawImage(fig.imageObj, 0, 0);\n };\n\n this.imageObj.onunload = function () {\n fig.ws.close();\n };\n\n this.ws.onmessage = this._make_on_message_function(this);\n\n this.ondownload = ondownload;\n};\n\nmpl.figure.prototype._init_header = function () {\n var titlebar = document.createElement('div');\n titlebar.classList =\n 'ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix';\n var titletext = document.createElement('div');\n titletext.classList = 'ui-dialog-title';\n titletext.setAttribute(\n 'style',\n 'width: 100%; text-align: center; padding: 3px;'\n );\n titlebar.appendChild(titletext);\n this.root.appendChild(titlebar);\n this.header = titletext;\n};\n\nmpl.figure.prototype._canvas_extra_style = function (_canvas_div) {};\n\nmpl.figure.prototype._root_extra_style = function (_canvas_div) {};\n\nmpl.figure.prototype._init_canvas = function () {\n var fig = this;\n\n var canvas_div = (this.canvas_div = document.createElement('div'));\n canvas_div.setAttribute(\n 'style',\n 'border: 1px solid #ddd;' +\n 'box-sizing: content-box;' +\n 'clear: both;' +\n 'min-height: 1px;' +\n 'min-width: 1px;' +\n 'outline: 0;' +\n 'overflow: hidden;' +\n 'position: relative;' +\n 'resize: both;'\n );\n\n function on_keyboard_event_closure(name) {\n return function (event) {\n return fig.key
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAACgKADAAQAAAABAAAB4AAAAAAfNMscAABAAElEQVR4AeydB7wVxfn3h8sFAZFiRZrYYu/dJMauqFhRNMZEfVM0pug/Ro3GgsYSY6IxUVONJsaCClbU2E3T2LB3UVHECigCUu595ztnnz3Pztnds+fecy73wjz3c8/szjzzzMwzszO/faZst1ZLJlDQQNBA0EDQQNBA0EDQQNDAEqOBpiWmpKGgQQNBA0EDQQNBA0EDQQNBA04DAQCGhhA0EDQQNBA0EDQQNBA0sIRpIADAJazCQ3GDBoIGggaCBoIGggaCBgIADG0gaCBoIGggaCBoIGggaGAJ00AAgEtYhYfiBg0EDQQNBA0EDQQNBA0EABjaQNBA0EDQQNBA0EDQQNDAEqaBAACXsAoPxQ0aCBoIGggaCB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7bRNqaUqu1TfMD/va9NDULrBV85eyR8ecjhUl/RlIDRe0vvIV2O8bM4WKx1MCSDIL0s1bk3L/FsAGEcwCrVGreOTuNOAesSnbiYAY6rBQMVEOX7RP7514wgMonzfzp0LywHKEPPPCA2WGHHcz06dPNgAEDcjirBDEINwK0tVdue+NXKXanD25ju8grV2rbRc8AvywatKEx054uhzKl77UXwOVzdvp2g6
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"dx = 20\n",
"dmin = 125\n",
"dmax = dmin + dx\n",
"\n",
"mask_obs = (dmin < obs[\"CDIST_CMB\"]) & (obs[\"CDIST_CMB\"] < dmax)\n",
"mask_sim = (dmin < sim[\"dist\"]) & (sim[\"dist\"] < dmax) & (sim[\"mass_cl\"] > 1e12)\n",
"\n",
"width = 6.4\n",
"plt.figure(figsize=(width, width*0.75))\n",
"plt.scatter(obs[\"RA\"][mask_obs], obs[\"DEC\"][mask_obs], s=1.5, label=\"2M++\")\n",
"plt.scatter(sim[\"ra\"][mask_sim] , sim[\"dec\"][mask_sim], s=1.5, label=\"CSiBORG\")\n",
"plt.scatter(planck[\"RA\"], planck[\"DEC\"], label=\"Planck SZ clusters < 214 MPc\", c=\"red\")\n",
"\n",
"\n",
"plt.legend()\n",
"plt.xlabel(\"RA\")\n",
"plt.ylabel(\"dec\")\n",
"plt.tight_layout()\n",
"# plt.savefig(\"../plots/2mpp_overlap.png\", dpi=450)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2022-10-18T12:35:27.120104Z",
"start_time": "2022-10-18T12:35:27.039527Z"
}
},
"outputs": [],
"source": [
2022-10-20 22:37:33 +00:00
"fpath = \"/mnt/zfsusers/rstiskalek/csiborgtools/data/HFI_PCCS_SZ-union_R2.08.fits\"\n",
"obs = csiborgtools.io.read_planck2015(fpath, cosmo, 214)\n",
"\n",
"\n",
"c1 = SkyCoord(ra=obs[\"RA\"]*u.degree, dec=obs[\"DEC\"]*u.degree, distance=obs[\"COMDIST\"]*u.Mpc)\n",
"c2 = SkyCoord(ra=sim[\"ra\"]*u.degree, dec=sim[\"dec\"]*u.degree, distance=sim[\"dist\"]*u.Mpc)\n",
"\n",
2022-10-20 22:37:33 +00:00
"sep, indxs = csiborgtools.match.brute_spatial_separation(c1, c2, N=100, angular=False, verbose=True, )"
]
},
{
"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_galomatch",
"language": "python",
"name": "venv_galomatch"
},
"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"
},
"vscode": {
"interpreter": {
"hash": "48b586a1ee27fc2e7b130d2436dca8c87c36333659e2ed3c8e31ccbf57230401"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}