Created
October 24, 2024 05:47
-
-
Save zonca/08a0d25c677fdac169888f35ed171dda to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 28, | |
"id": "ec1b9c94", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"import healpy as hp\n", | |
"import numpy as np\n", | |
"import pickle\n", | |
"import h5py\n", | |
"import altair as alt\n", | |
"alt.renderers.enable('html')\n", | |
"import pandas as pd\n", | |
"import warnings\n", | |
"warnings.filterwarnings(\"ignore\")\n", | |
"import pysm3.units as u" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 29, | |
"id": "471a5203", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<script>\n", | |
"code_show=true; \n", | |
"function code_toggle() {\n", | |
" if (code_show){\n", | |
" $('div.input').hide();\n", | |
" } else {\n", | |
" $('div.input').show();\n", | |
" }\n", | |
" code_show = !code_show\n", | |
"} \n", | |
"$( document ).ready(code_toggle);\n", | |
"</script>\n", | |
"<form action=\"javascript:code_toggle()\"><input type=\"submit\" value=\"Click here to toggle on/off the raw code.\"></form>" | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"execution_count": 29, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"from IPython.display import HTML\n", | |
"\n", | |
"HTML('''<script>\n", | |
"code_show=true; \n", | |
"function code_toggle() {\n", | |
" if (code_show){\n", | |
" $('div.input').hide();\n", | |
" } else {\n", | |
" $('div.input').show();\n", | |
" }\n", | |
" code_show = !code_show\n", | |
"} \n", | |
"$( document ).ready(code_toggle);\n", | |
"</script>\n", | |
"<form action=\"javascript:code_toggle()\"><input type=\"submit\" value=\"Click here to toggle on/off the raw code.\"></form>''')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 30, | |
"id": "4868574d", | |
"metadata": { | |
"papermill": {}, | |
"tags": [ | |
"parameters" | |
] | |
}, | |
"outputs": [], | |
"source": [ | |
"input_telescope = \"SAT\"\n", | |
"pol = \"T\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 31, | |
"id": "02b0108b", | |
"metadata": { | |
"tags": [ | |
"injected-parameters" | |
] | |
}, | |
"outputs": [], | |
"source": [ | |
"# Parameters\n", | |
"input_telescope = \"SAT\"\n", | |
"pol = \"E\"\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 32, | |
"id": "364660cd", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"selection = {}\n", | |
"cl = {}\n", | |
"i_pol = \"TEB\".index(pol)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 33, | |
"id": "e8faa01d", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"site = \"Chile\"\n", | |
"telescope = input_telescope[-3:]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 34, | |
"id": "77677ca7", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"/mnt/home/azonca/p/software/s4mapbasedsims\n" | |
] | |
} | |
], | |
"source": [ | |
"%cd .." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 35, | |
"id": "7cbe9b89", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"import os\n", | |
"\n", | |
"if os.path.basename(os.getcwd()) == \"verification\":\n", | |
" %cd .." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 36, | |
"id": "1c700cd3", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"from astropy.table import QTable" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 37, | |
"id": "15e89046", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [ | |
{ | |
"ename": "FileNotFoundError", | |
"evalue": "[Errno 2] No such file or directory: 'instrument_model/cmbs4_instrument_model.tbl'", | |
"output_type": "error", | |
"traceback": [ | |
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | |
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", | |
"Cell \u001b[0;32mIn[37], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m chs \u001b[38;5;241m=\u001b[39m \u001b[43mQTable\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43minstrument_model/cmbs4_instrument_model.tbl\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mformat\u001b[39;49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mascii.ipac\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", | |
"File \u001b[0;32m~/mambaforge-pypy3/envs/so/lib/python3.10/site-packages/astropy/table/connect.py:62\u001b[0m, in \u001b[0;36mTableRead.__call__\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 59\u001b[0m units \u001b[38;5;241m=\u001b[39m kwargs\u001b[38;5;241m.\u001b[39mpop(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124munits\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[1;32m 60\u001b[0m descriptions \u001b[38;5;241m=\u001b[39m kwargs\u001b[38;5;241m.\u001b[39mpop(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdescriptions\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[0;32m---> 62\u001b[0m out \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mregistry\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mcls\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 64\u001b[0m \u001b[38;5;66;03m# For some readers (e.g., ascii.ecsv), the returned `out` class is not\u001b[39;00m\n\u001b[1;32m 65\u001b[0m \u001b[38;5;66;03m# guaranteed to be the same as the desired output `cls`. If so,\u001b[39;00m\n\u001b[1;32m 66\u001b[0m \u001b[38;5;66;03m# try coercing to desired class without copying (io.registry.read\u001b[39;00m\n\u001b[1;32m 67\u001b[0m \u001b[38;5;66;03m# would normally do a copy). The normal case here is swapping\u001b[39;00m\n\u001b[1;32m 68\u001b[0m \u001b[38;5;66;03m# Table <=> QTable.\u001b[39;00m\n\u001b[1;32m 69\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mcls\u001b[39m \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m out\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__class__\u001b[39m:\n", | |
"File \u001b[0;32m~/mambaforge-pypy3/envs/so/lib/python3.10/site-packages/astropy/io/registry/core.py:219\u001b[0m, in \u001b[0;36mUnifiedInputRegistry.read\u001b[0;34m(self, cls, format, cache, *args, **kwargs)\u001b[0m\n\u001b[1;32m 214\u001b[0m \u001b[38;5;28mformat\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_valid_format(\n\u001b[1;32m 215\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mread\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28mcls\u001b[39m, path, fileobj, args, kwargs\n\u001b[1;32m 216\u001b[0m )\n\u001b[1;32m 218\u001b[0m reader \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mget_reader(\u001b[38;5;28mformat\u001b[39m, \u001b[38;5;28mcls\u001b[39m)\n\u001b[0;32m--> 219\u001b[0m data \u001b[38;5;241m=\u001b[39m \u001b[43mreader\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 221\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(data, \u001b[38;5;28mcls\u001b[39m):\n\u001b[1;32m 222\u001b[0m \u001b[38;5;66;03m# User has read with a subclass where only the parent class is\u001b[39;00m\n\u001b[1;32m 223\u001b[0m \u001b[38;5;66;03m# registered. This returns the parent class, so try coercing\u001b[39;00m\n\u001b[1;32m 224\u001b[0m \u001b[38;5;66;03m# to desired subclass.\u001b[39;00m\n\u001b[1;32m 225\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n", | |
"File \u001b[0;32m~/mambaforge-pypy3/envs/so/lib/python3.10/site-packages/astropy/io/ascii/connect.py:19\u001b[0m, in \u001b[0;36mio_read\u001b[0;34m(format, filename, **kwargs)\u001b[0m\n\u001b[1;32m 17\u001b[0m \u001b[38;5;28mformat\u001b[39m \u001b[38;5;241m=\u001b[39m re\u001b[38;5;241m.\u001b[39msub(\u001b[38;5;124mr\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m^ascii\u001b[39m\u001b[38;5;124m\\\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28mformat\u001b[39m)\n\u001b[1;32m 18\u001b[0m kwargs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mformat\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mformat\u001b[39m\n\u001b[0;32m---> 19\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilename\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", | |
"File \u001b[0;32m~/mambaforge-pypy3/envs/so/lib/python3.10/site-packages/astropy/io/ascii/ui.py:426\u001b[0m, in \u001b[0;36mread\u001b[0;34m(table, guess, **kwargs)\u001b[0m\n\u001b[1;32m 424\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 425\u001b[0m reader \u001b[38;5;241m=\u001b[39m get_reader(\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mnew_kwargs)\n\u001b[0;32m--> 426\u001b[0m dat \u001b[38;5;241m=\u001b[39m \u001b[43mreader\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtable\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 427\u001b[0m _read_trace\u001b[38;5;241m.\u001b[39mappend(\n\u001b[1;32m 428\u001b[0m {\n\u001b[1;32m 429\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mkwargs\u001b[39m\u001b[38;5;124m\"\u001b[39m: copy\u001b[38;5;241m.\u001b[39mdeepcopy(new_kwargs),\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 432\u001b[0m }\n\u001b[1;32m 433\u001b[0m )\n\u001b[1;32m 435\u001b[0m \u001b[38;5;66;03m# Static analysis (pyright) indicates `dat` might be left undefined, so just\u001b[39;00m\n\u001b[1;32m 436\u001b[0m \u001b[38;5;66;03m# to be sure define it at the beginning and check here.\u001b[39;00m\n", | |
"File \u001b[0;32m~/mambaforge-pypy3/envs/so/lib/python3.10/site-packages/astropy/io/ascii/core.py:1414\u001b[0m, in \u001b[0;36mBaseReader.read\u001b[0;34m(self, table)\u001b[0m\n\u001b[1;32m 1411\u001b[0m newline \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 1413\u001b[0m \u001b[38;5;66;03m# Get a list of the lines (rows) in the table\u001b[39;00m\n\u001b[0;32m-> 1414\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlines \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minputter\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_lines\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtable\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnewline\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnewline\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1416\u001b[0m \u001b[38;5;66;03m# Set self.data.data_lines to a slice of lines contain the data rows\u001b[39;00m\n\u001b[1;32m 1417\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdata\u001b[38;5;241m.\u001b[39mget_data_lines(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlines)\n", | |
"File \u001b[0;32m~/mambaforge-pypy3/envs/so/lib/python3.10/site-packages/astropy/io/ascii/core.py:335\u001b[0m, in \u001b[0;36mBaseInputter.get_lines\u001b[0;34m(self, table, newline)\u001b[0m\n\u001b[1;32m 331\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 332\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mhasattr\u001b[39m(table, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mread\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mor\u001b[39;00m (\n\u001b[1;32m 333\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m table \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\r\u001b[39;00m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m table \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 334\u001b[0m ):\n\u001b[0;32m--> 335\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m get_readable_fileobj(table, encoding\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencoding) \u001b[38;5;28;01mas\u001b[39;00m fileobj:\n\u001b[1;32m 336\u001b[0m table \u001b[38;5;241m=\u001b[39m fileobj\u001b[38;5;241m.\u001b[39mread()\n\u001b[1;32m 337\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m newline \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n", | |
"File \u001b[0;32m~/mambaforge-pypy3/envs/so/lib/python3.10/contextlib.py:135\u001b[0m, in \u001b[0;36m_GeneratorContextManager.__enter__\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 133\u001b[0m \u001b[38;5;28;01mdel\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39margs, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mkwds, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfunc\n\u001b[1;32m 134\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 135\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mnext\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mgen\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 136\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mStopIteration\u001b[39;00m:\n\u001b[1;32m 137\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mRuntimeError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mgenerator didn\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mt yield\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28mNone\u001b[39m\n", | |
"File \u001b[0;32m~/mambaforge-pypy3/envs/so/lib/python3.10/site-packages/astropy/utils/data.py:353\u001b[0m, in \u001b[0;36mget_readable_fileobj\u001b[0;34m(name_or_obj, encoding, cache, show_progress, remote_timeout, sources, http_headers, use_fsspec, fsspec_kwargs, close_files)\u001b[0m\n\u001b[1;32m 344\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m is_url:\n\u001b[1;32m 345\u001b[0m name_or_obj \u001b[38;5;241m=\u001b[39m download_file(\n\u001b[1;32m 346\u001b[0m name_or_obj,\n\u001b[1;32m 347\u001b[0m cache\u001b[38;5;241m=\u001b[39mcache,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 351\u001b[0m http_headers\u001b[38;5;241m=\u001b[39mhttp_headers,\n\u001b[1;32m 352\u001b[0m )\n\u001b[0;32m--> 353\u001b[0m fileobj \u001b[38;5;241m=\u001b[39m \u001b[43mio\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mFileIO\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname_or_obj\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mr\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 354\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m is_url \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m cache:\n\u001b[1;32m 355\u001b[0m delete_fds\u001b[38;5;241m.\u001b[39mappend(fileobj)\n", | |
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'instrument_model/cmbs4_instrument_model.tbl'" | |
] | |
} | |
], | |
"source": [ | |
"chs = QTable.read(\"instrument_model/cmbs4_instrument_model.tbl\", format=\"ascii.ipac\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "7fe389a0", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"chs = chs[chs[\"telescope\"] == telescope]\n", | |
"chs = chs[chs[\"site\"] == site]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "d36506f3", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"chs" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "32e5ecc9", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"alt.data_transformers.enable(\"default\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "534ab9cb", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"alt.data_transformers.disable_max_rows()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "9d33f12a", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"import pysm3 as pysm\n", | |
"from pysm3 import units as u" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "eba35b48", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"import mapsims" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "4b0e1183", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"pol_label = [\"TT\", \"EE\", \"BB\"][i_pol]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "78f114d1", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"from glob import glob" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "c5889b67", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"toml_files = glob(\"*.toml\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "b16292cb", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"toml_files.remove(\"common.toml\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "f4cc1040", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"toml_files.remove(\"co_co1.toml\")\n", | |
"toml_files.remove(\"co_co3.toml\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "ef1b3b2c", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"toml_files.sort()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "068cc901", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"pysm_nside = 512 if telescope == \"SAT\" else 2048" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "64f69d2a", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"channels = chs[\"band\"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "2dee446f", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"chs" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "f8e2b468", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"for config_file in toml_files: \n", | |
" mapsim = mapsims.from_config([\"common.toml\", config_file], override={\"channels\":\"all\"})\n", | |
" component = config_file.split(\".\")[0]\n", | |
" print(component)\n", | |
" filename = f\"output/C_ell_{component}.pkl\"\n", | |
" with open(filename, \"rb\") as f:\n", | |
" cl[component] = pickle.load(f)\n", | |
" sky = pysm.Sky(nside=pysm_nside,\n", | |
" preset_strings=[mapsim.pysm_components_string],\n", | |
" output_unit=u.uK_CMB\n", | |
" )\n", | |
" onecl = pd.DataFrame(\n", | |
" {ch:pd.Series(cl[component][ch][i_pol]) for ch in channels}\n", | |
" ).reset_index().rename(columns={\"index\":\"ell\"})\n", | |
"\n", | |
" pysm_emission = sky.get_emission(chs[\"center_frequency\"][0])\n", | |
" label = \"PySM \" + channels[0]\n", | |
"\n", | |
"\n", | |
" pysm_low = hp.anafast(\n", | |
" pysm_emission,\n", | |
" lmax=int(1.5*pysm_nside), use_pixel_weights=True)[i_pol]\n", | |
" pysm_low *= hp.gauss_beam(chs[0][\"fwhm\"].to_value(u.rad), lmax=int(1.5*pysm_nside))**2\n", | |
" onecl[label] = 0\n", | |
" onecl[label][:len(pysm_low)] = pysm_low\n", | |
"\n", | |
" pysm_emission = sky.get_emission(\n", | |
" chs[-1][\"center_frequency\"],\n", | |
" )\n", | |
" label = \"PySM \" + channels[-1]\n", | |
"\n", | |
"\n", | |
" pysm_high = hp.anafast(\n", | |
" pysm_emission, \n", | |
" lmax=int(1.5*pysm_nside), use_pixel_weights=True)[i_pol]\n", | |
" pysm_high *= hp.gauss_beam(chs[-1][\"fwhm\"].to_value(u.rad), lmax=int(1.5*pysm_nside))**2\n", | |
" onecl[label] = 0\n", | |
" onecl[label][:len(pysm_high)] = pysm_high\n", | |
"\n", | |
" onecl = onecl[onecl.ell != 0]\n", | |
" if telescope == \"LAT\":\n", | |
" decim = np.concatenate([[0], np.logspace(0, 4, 1000, endpoint=False)])\n", | |
" onecl = onecl.iloc[decim,:] # decimate in log scale to make plots smaller\n", | |
"\n", | |
" onecl_long = onecl.melt(\"ell\", var_name=\"channel\")\n", | |
" onecl_long[onecl_long.value == 0] = np.nan\n", | |
" selection[component] = alt.selection_multi(fields=['channel'], bind=\"legend\")\n", | |
"\n", | |
" chart = alt.Chart(onecl_long, title=component + \" \" + pol_label).mark_line().encode(\n", | |
" x=alt.X(\"ell\", scale=alt.Scale(type='log', base=10, domain=[1,1e4])),\n", | |
" y=alt.Y(\"value\", scale=alt.Scale(type='log', base=10)),\n", | |
" color=alt.Color('channel', \n", | |
" sort=[\"PySM \" + channels[0]] + list(channels) + [\"PySM \" + channels[-1]]\n", | |
" ),\n", | |
" opacity=alt.condition(selection[component], alt.value(1), alt.value(0.2))\n", | |
" ).add_selection(selection[component]).interactive()\n", | |
" chart.display()\n", | |
" #chart.save(f\"verification/out_plot_cl/{component}_{input_telescope}_{pol}.json\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "0e4f93aa", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"# Make sure the notebook is saved\n", | |
"\n", | |
"from ipylab import JupyterFrontEnd\n", | |
"\n", | |
"app = JupyterFrontEnd()\n", | |
"app.commands.execute('docmanager:save')" | |
] | |
} | |
], | |
"metadata": { | |
"jupytext": { | |
"formats": "ipynb,py" | |
}, | |
"kernelspec": { | |
"display_name": "so", | |
"language": "python", | |
"name": "so" | |
}, | |
"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.10.11" | |
}, | |
"papermill": { | |
"default_parameters": {}, | |
"environment_variables": {}, | |
"input_path": "plot_cl.ipynb", | |
"output_path": "out_plot_cl/plot_cl_SAT_E.ipynb", | |
"parameters": { | |
"input_telescope": "SAT", | |
"pol": "E" | |
}, | |
"version": "2.4.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment