Skip to content

Instantly share code, notes, and snippets.

@zonca
Created February 28, 2025 20:53
Show Gist options
  • Save zonca/621bd304d626ab4312280a0374fb4f64 to your computer and use it in GitHub Desktop.
Save zonca/621bd304d626ab4312280a0374fb4f64 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "aaef19e6",
"metadata": {
"tags": [
"papermill-error-cell-tag"
]
},
"source": [
"<span style=\"color:red; font-family:Helvetica Neue, Helvetica, Arial, sans-serif; font-size:2em;\">An Exception was encountered at '<a href=\"#papermill-error-cell\">In [26]</a>'.</span>"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "d96d8bae",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:16.432345Z",
"iopub.status.busy": "2025-02-28T20:53:16.432117Z",
"iopub.status.idle": "2025-02-28T20:53:18.047542Z",
"shell.execute_reply": "2025-02-28T20:53:18.047106Z"
},
"papermill": {
"duration": 1.62068,
"end_time": "2025-02-28T20:53:18.048857",
"exception": false,
"start_time": "2025-02-28T20:53:16.428177",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"import healpy as hp\n",
"import numpy as np\n",
"import pickle\n",
"import h5py\n",
"import altair as alt\n",
"\n",
"alt.renderers.enable(\"html\")\n",
"import pandas as pd\n",
"import warnings\n",
"\n",
"warnings.filterwarnings(\"ignore\")\n",
"import pysm3.units as u"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "743d3b96",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.055976Z",
"iopub.status.busy": "2025-02-28T20:53:18.055425Z",
"iopub.status.idle": "2025-02-28T20:53:18.060538Z",
"shell.execute_reply": "2025-02-28T20:53:18.060185Z"
},
"papermill": {
"duration": 0.009248,
"end_time": "2025-02-28T20:53:18.061341",
"exception": false,
"start_time": "2025-02-28T20:53:18.052093",
"status": "completed"
},
"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": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from IPython.display import HTML\n",
"\n",
"HTML(\n",
" \"\"\"<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>\"\"\"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "ac3ed625",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.068340Z",
"iopub.status.busy": "2025-02-28T20:53:18.068138Z",
"iopub.status.idle": "2025-02-28T20:53:18.070209Z",
"shell.execute_reply": "2025-02-28T20:53:18.069869Z"
},
"papermill": {
"duration": 0.005787,
"end_time": "2025-02-28T20:53:18.070903",
"exception": false,
"start_time": "2025-02-28T20:53:18.065116",
"status": "completed"
},
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"pol = \"T\""
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "7dcba704",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.076935Z",
"iopub.status.busy": "2025-02-28T20:53:18.076727Z",
"iopub.status.idle": "2025-02-28T20:53:18.078721Z",
"shell.execute_reply": "2025-02-28T20:53:18.078390Z"
},
"papermill": {
"duration": 0.005817,
"end_time": "2025-02-28T20:53:18.079441",
"exception": false,
"start_time": "2025-02-28T20:53:18.073624",
"status": "completed"
},
"tags": [
"injected-parameters"
]
},
"outputs": [],
"source": [
"# Parameters\n",
"pol = \"T\"\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "126c8b66",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.085273Z",
"iopub.status.busy": "2025-02-28T20:53:18.085080Z",
"iopub.status.idle": "2025-02-28T20:53:18.087159Z",
"shell.execute_reply": "2025-02-28T20:53:18.086828Z"
},
"papermill": {
"duration": 0.005826,
"end_time": "2025-02-28T20:53:18.087885",
"exception": false,
"start_time": "2025-02-28T20:53:18.082059",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"selection = {}\n",
"cl = {}\n",
"i_pol = \"TEB\".index(pol)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "704f5152",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.094067Z",
"iopub.status.busy": "2025-02-28T20:53:18.093822Z",
"iopub.status.idle": "2025-02-28T20:53:18.096760Z",
"shell.execute_reply": "2025-02-28T20:53:18.096424Z"
},
"papermill": {
"duration": 0.006787,
"end_time": "2025-02-28T20:53:18.097422",
"exception": false,
"start_time": "2025-02-28T20:53:18.090635",
"status": "completed"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"/mnt/home/azonca/p/software/map_based_simulations/mbs-s0019-20250221\n"
]
}
],
"source": [
"%cd .."
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "071d3dc3",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.103511Z",
"iopub.status.busy": "2025-02-28T20:53:18.103317Z",
"iopub.status.idle": "2025-02-28T20:53:18.105709Z",
"shell.execute_reply": "2025-02-28T20:53:18.105370Z"
},
"papermill": {
"duration": 0.006305,
"end_time": "2025-02-28T20:53:18.106435",
"exception": false,
"start_time": "2025-02-28T20:53:18.100130",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"import os\n",
"\n",
"if os.path.basename(os.getcwd()) == \"verification\":\n",
" %cd .."
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "951a0d92",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.112507Z",
"iopub.status.busy": "2025-02-28T20:53:18.112313Z",
"iopub.status.idle": "2025-02-28T20:53:18.114334Z",
"shell.execute_reply": "2025-02-28T20:53:18.113997Z"
},
"papermill": {
"duration": 0.005957,
"end_time": "2025-02-28T20:53:18.115093",
"exception": false,
"start_time": "2025-02-28T20:53:18.109136",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"from astropy.table import QTable"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "a5423ba2",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.121295Z",
"iopub.status.busy": "2025-02-28T20:53:18.121099Z",
"iopub.status.idle": "2025-02-28T20:53:18.127898Z",
"shell.execute_reply": "2025-02-28T20:53:18.127581Z"
},
"papermill": {
"duration": 0.010876,
"end_time": "2025-02-28T20:53:18.128771",
"exception": false,
"start_time": "2025-02-28T20:53:18.117895",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"chs = QTable.read(\"instrument_model/instrument_model.tbl\", format=\"ascii.ipac\")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "62bb61e9",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.134937Z",
"iopub.status.busy": "2025-02-28T20:53:18.134735Z",
"iopub.status.idle": "2025-02-28T20:53:18.138578Z",
"shell.execute_reply": "2025-02-28T20:53:18.138241Z"
},
"papermill": {
"duration": 0.007858,
"end_time": "2025-02-28T20:53:18.139342",
"exception": false,
"start_time": "2025-02-28T20:53:18.131484",
"status": "completed"
},
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<div><i>QTable length=5</i>\n",
"<table id=\"table23447026094000\" class=\"table-striped table-bordered table-condensed\">\n",
"<thead><tr><th>telescope</th><th>band</th><th>center_frequency</th><th>nside</th><th>bandpass_file</th><th>beam_file</th></tr></thead>\n",
"<thead><tr><th></th><th></th><th>GHz</th><th></th><th></th><th></th></tr></thead>\n",
"<thead><tr><th>str4</th><th>str2</th><th>float64</th><th>int64</th><th>str15</th><th>str11</th></tr></thead>\n",
"<tr><td>WMAP</td><td>K</td><td>22.451910974502667</td><td>512</td><td>bandpass_K.tbl</td><td>beam_K.tbl</td></tr>\n",
"<tr><td>WMAP</td><td>Ka</td><td>32.706607212937314</td><td>512</td><td>bandpass_Ka.tbl</td><td>beam_Ka.tbl</td></tr>\n",
"<tr><td>WMAP</td><td>Q</td><td>40.36343387766631</td><td>512</td><td>bandpass_Q.tbl</td><td>beam_Q.tbl</td></tr>\n",
"<tr><td>WMAP</td><td>V</td><td>60.07932358223898</td><td>512</td><td>bandpass_V.tbl</td><td>beam_V.tbl</td></tr>\n",
"<tr><td>WMAP</td><td>W</td><td>92.82552325276862</td><td>512</td><td>bandpass_W.tbl</td><td>beam_W.tbl</td></tr>\n",
"</table></div>"
],
"text/plain": [
"<QTable length=5>\n",
"telescope band center_frequency nside bandpass_file beam_file \n",
" GHz \n",
" str4 str2 float64 int64 str15 str11 \n",
"--------- ---- ------------------ ----- --------------- -----------\n",
" WMAP K 22.451910974502667 512 bandpass_K.tbl beam_K.tbl\n",
" WMAP Ka 32.706607212937314 512 bandpass_Ka.tbl beam_Ka.tbl\n",
" WMAP Q 40.36343387766631 512 bandpass_Q.tbl beam_Q.tbl\n",
" WMAP V 60.07932358223898 512 bandpass_V.tbl beam_V.tbl\n",
" WMAP W 92.82552325276862 512 bandpass_W.tbl beam_W.tbl"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"chs"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "e03144cc",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.145853Z",
"iopub.status.busy": "2025-02-28T20:53:18.145644Z",
"iopub.status.idle": "2025-02-28T20:53:18.148314Z",
"shell.execute_reply": "2025-02-28T20:53:18.147990Z"
},
"papermill": {
"duration": 0.006795,
"end_time": "2025-02-28T20:53:18.149016",
"exception": false,
"start_time": "2025-02-28T20:53:18.142221",
"status": "completed"
},
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"DataTransformerRegistry.enable('default')"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"alt.data_transformers.enable(\"default\")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "dc97f511",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.155724Z",
"iopub.status.busy": "2025-02-28T20:53:18.155529Z",
"iopub.status.idle": "2025-02-28T20:53:18.158228Z",
"shell.execute_reply": "2025-02-28T20:53:18.157923Z"
},
"papermill": {
"duration": 0.006878,
"end_time": "2025-02-28T20:53:18.158958",
"exception": false,
"start_time": "2025-02-28T20:53:18.152080",
"status": "completed"
},
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"DataTransformerRegistry.enable('default')"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"alt.data_transformers.disable_max_rows()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "12942bf0",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.165513Z",
"iopub.status.busy": "2025-02-28T20:53:18.165321Z",
"iopub.status.idle": "2025-02-28T20:53:18.167304Z",
"shell.execute_reply": "2025-02-28T20:53:18.166969Z"
},
"papermill": {
"duration": 0.006109,
"end_time": "2025-02-28T20:53:18.168060",
"exception": false,
"start_time": "2025-02-28T20:53:18.161951",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"import pysm3 as pysm\n",
"from pysm3 import units as u"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "c81ecf7b",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.175005Z",
"iopub.status.busy": "2025-02-28T20:53:18.174673Z",
"iopub.status.idle": "2025-02-28T20:53:18.180489Z",
"shell.execute_reply": "2025-02-28T20:53:18.180146Z"
},
"papermill": {
"duration": 0.010139,
"end_time": "2025-02-28T20:53:18.181234",
"exception": false,
"start_time": "2025-02-28T20:53:18.171095",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"import mapsims"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "30e0a8c3",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.187985Z",
"iopub.status.busy": "2025-02-28T20:53:18.187794Z",
"iopub.status.idle": "2025-02-28T20:53:18.189894Z",
"shell.execute_reply": "2025-02-28T20:53:18.189556Z"
},
"papermill": {
"duration": 0.006374,
"end_time": "2025-02-28T20:53:18.190621",
"exception": false,
"start_time": "2025-02-28T20:53:18.184247",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"pol_label = [\"TT\", \"EE\", \"BB\"][i_pol]"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "7690d12f",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.197349Z",
"iopub.status.busy": "2025-02-28T20:53:18.197156Z",
"iopub.status.idle": "2025-02-28T20:53:18.199233Z",
"shell.execute_reply": "2025-02-28T20:53:18.198903Z"
},
"papermill": {
"duration": 0.006283,
"end_time": "2025-02-28T20:53:18.199957",
"exception": false,
"start_time": "2025-02-28T20:53:18.193674",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"from glob import glob"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "80f202fa",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.206594Z",
"iopub.status.busy": "2025-02-28T20:53:18.206397Z",
"iopub.status.idle": "2025-02-28T20:53:18.208686Z",
"shell.execute_reply": "2025-02-28T20:53:18.208358Z"
},
"papermill": {
"duration": 0.006407,
"end_time": "2025-02-28T20:53:18.209347",
"exception": false,
"start_time": "2025-02-28T20:53:18.202940",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"toml_files = glob(\"*.toml\")"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "a15e850b",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.216357Z",
"iopub.status.busy": "2025-02-28T20:53:18.216108Z",
"iopub.status.idle": "2025-02-28T20:53:18.218052Z",
"shell.execute_reply": "2025-02-28T20:53:18.217736Z"
},
"papermill": {
"duration": 0.006305,
"end_time": "2025-02-28T20:53:18.218752",
"exception": false,
"start_time": "2025-02-28T20:53:18.212447",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"toml_files.remove(\"common.toml\")"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "de27c3ea",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.225543Z",
"iopub.status.busy": "2025-02-28T20:53:18.225348Z",
"iopub.status.idle": "2025-02-28T20:53:18.227466Z",
"shell.execute_reply": "2025-02-28T20:53:18.227129Z"
},
"papermill": {
"duration": 0.006327,
"end_time": "2025-02-28T20:53:18.228180",
"exception": false,
"start_time": "2025-02-28T20:53:18.221853",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"toml_files.remove(\"co_co1.toml\")\n",
"toml_files.remove(\"co_co3.toml\")"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "159f8f99",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.235319Z",
"iopub.status.busy": "2025-02-28T20:53:18.234993Z",
"iopub.status.idle": "2025-02-28T20:53:18.236993Z",
"shell.execute_reply": "2025-02-28T20:53:18.236666Z"
},
"papermill": {
"duration": 0.006346,
"end_time": "2025-02-28T20:53:18.237679",
"exception": false,
"start_time": "2025-02-28T20:53:18.231333",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"toml_files.sort()"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "16d7b005",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.244587Z",
"iopub.status.busy": "2025-02-28T20:53:18.244395Z",
"iopub.status.idle": "2025-02-28T20:53:18.246368Z",
"shell.execute_reply": "2025-02-28T20:53:18.246028Z"
},
"papermill": {
"duration": 0.006327,
"end_time": "2025-02-28T20:53:18.247120",
"exception": false,
"start_time": "2025-02-28T20:53:18.240793",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"pysm_nside = 2048"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "bdd38da3",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.254364Z",
"iopub.status.busy": "2025-02-28T20:53:18.254122Z",
"iopub.status.idle": "2025-02-28T20:53:18.256615Z",
"shell.execute_reply": "2025-02-28T20:53:18.256312Z"
},
"papermill": {
"duration": 0.006989,
"end_time": "2025-02-28T20:53:18.257312",
"exception": false,
"start_time": "2025-02-28T20:53:18.250323",
"status": "completed"
},
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"astropy.table.table.QTable"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(chs)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "313fc094",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.264601Z",
"iopub.status.busy": "2025-02-28T20:53:18.264408Z",
"iopub.status.idle": "2025-02-28T20:53:18.266958Z",
"shell.execute_reply": "2025-02-28T20:53:18.266660Z"
},
"papermill": {
"duration": 0.007031,
"end_time": "2025-02-28T20:53:18.267678",
"exception": false,
"start_time": "2025-02-28T20:53:18.260647",
"status": "completed"
},
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"5"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(chs)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "8dad97da",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.274988Z",
"iopub.status.busy": "2025-02-28T20:53:18.274793Z",
"iopub.status.idle": "2025-02-28T20:53:18.276895Z",
"shell.execute_reply": "2025-02-28T20:53:18.276554Z"
},
"papermill": {
"duration": 0.006525,
"end_time": "2025-02-28T20:53:18.277568",
"exception": false,
"start_time": "2025-02-28T20:53:18.271043",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"channels = chs[\"band\"]"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "67023290",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.284825Z",
"iopub.status.busy": "2025-02-28T20:53:18.284635Z",
"iopub.status.idle": "2025-02-28T20:53:18.287962Z",
"shell.execute_reply": "2025-02-28T20:53:18.287659Z"
},
"papermill": {
"duration": 0.007837,
"end_time": "2025-02-28T20:53:18.288718",
"exception": false,
"start_time": "2025-02-28T20:53:18.280881",
"status": "completed"
},
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<div><i>QTable length=5</i>\n",
"<table id=\"table23447026094000\" class=\"table-striped table-bordered table-condensed\">\n",
"<thead><tr><th>telescope</th><th>band</th><th>center_frequency</th><th>nside</th><th>bandpass_file</th><th>beam_file</th></tr></thead>\n",
"<thead><tr><th></th><th></th><th>GHz</th><th></th><th></th><th></th></tr></thead>\n",
"<thead><tr><th>str4</th><th>str2</th><th>float64</th><th>int64</th><th>str15</th><th>str11</th></tr></thead>\n",
"<tr><td>WMAP</td><td>K</td><td>22.451910974502667</td><td>512</td><td>bandpass_K.tbl</td><td>beam_K.tbl</td></tr>\n",
"<tr><td>WMAP</td><td>Ka</td><td>32.706607212937314</td><td>512</td><td>bandpass_Ka.tbl</td><td>beam_Ka.tbl</td></tr>\n",
"<tr><td>WMAP</td><td>Q</td><td>40.36343387766631</td><td>512</td><td>bandpass_Q.tbl</td><td>beam_Q.tbl</td></tr>\n",
"<tr><td>WMAP</td><td>V</td><td>60.07932358223898</td><td>512</td><td>bandpass_V.tbl</td><td>beam_V.tbl</td></tr>\n",
"<tr><td>WMAP</td><td>W</td><td>92.82552325276862</td><td>512</td><td>bandpass_W.tbl</td><td>beam_W.tbl</td></tr>\n",
"</table></div>"
],
"text/plain": [
"<QTable length=5>\n",
"telescope band center_frequency nside bandpass_file beam_file \n",
" GHz \n",
" str4 str2 float64 int64 str15 str11 \n",
"--------- ---- ------------------ ----- --------------- -----------\n",
" WMAP K 22.451910974502667 512 bandpass_K.tbl beam_K.tbl\n",
" WMAP Ka 32.706607212937314 512 bandpass_Ka.tbl beam_Ka.tbl\n",
" WMAP Q 40.36343387766631 512 bandpass_Q.tbl beam_Q.tbl\n",
" WMAP V 60.07932358223898 512 bandpass_V.tbl beam_V.tbl\n",
" WMAP W 92.82552325276862 512 bandpass_W.tbl beam_W.tbl"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"chs"
]
},
{
"cell_type": "markdown",
"id": "ac1cfd58",
"metadata": {
"tags": [
"papermill-error-cell-tag"
]
},
"source": [
"<span id=\"papermill-error-cell\" style=\"color:red; font-family:Helvetica Neue, Helvetica, Arial, sans-serif; font-size:2em;\">Execution using papermill encountered an exception here and stopped:</span>"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "f53d3c50",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T20:53:18.296184Z",
"iopub.status.busy": "2025-02-28T20:53:18.295988Z",
"iopub.status.idle": "2025-02-28T20:53:34.004610Z",
"shell.execute_reply": "2025-02-28T20:53:34.003822Z"
},
"papermill": {
"duration": 15.71331,
"end_time": "2025-02-28T20:53:34.005427",
"exception": true,
"start_time": "2025-02-28T20:53:18.292117",
"status": "failed"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ame_a1\n"
]
},
{
"ename": "KeyError",
"evalue": "'fwhm'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
"File \u001b[0;32m~/micromamba/envs/cmb/lib/python3.12/site-packages/astropy/table/row.py:54\u001b[0m, in \u001b[0;36mRow.__getitem__\u001b[0;34m(self, item)\u001b[0m\n\u001b[1;32m 50\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 51\u001b[0m \u001b[38;5;66;03m# Try the most common use case of accessing a single column in the Row.\u001b[39;00m\n\u001b[1;32m 52\u001b[0m \u001b[38;5;66;03m# Bypass the TableColumns __getitem__ since that does more testing\u001b[39;00m\n\u001b[1;32m 53\u001b[0m \u001b[38;5;66;03m# and allows a list of tuple or str, which is not the right thing here.\u001b[39;00m\n\u001b[0;32m---> 54\u001b[0m out \u001b[38;5;241m=\u001b[39m \u001b[43mOrderedDict\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[38;5;21;43m__getitem__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_table\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcolumns\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mitem\u001b[49m\u001b[43m)\u001b[49m[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_index]\n\u001b[1;32m 55\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (\u001b[38;5;167;01mKeyError\u001b[39;00m, \u001b[38;5;167;01mTypeError\u001b[39;00m):\n",
"\u001b[0;31mKeyError\u001b[0m: 'fwhm'",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[26], line 28\u001b[0m\n\u001b[1;32m 22\u001b[0m label \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mPySM \u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m+\u001b[39m channels[\u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m 24\u001b[0m pysm_low \u001b[38;5;241m=\u001b[39m hp\u001b[38;5;241m.\u001b[39manafast(\n\u001b[1;32m 25\u001b[0m pysm_emission, lmax\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mint\u001b[39m(\u001b[38;5;241m1.5\u001b[39m \u001b[38;5;241m*\u001b[39m pysm_nside), use_pixel_weights\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[1;32m 26\u001b[0m )[i_pol]\n\u001b[1;32m 27\u001b[0m pysm_low \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m=\u001b[39m (\n\u001b[0;32m---> 28\u001b[0m hp\u001b[38;5;241m.\u001b[39mgauss_beam(\u001b[43mchs\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mfwhm\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[38;5;241m.\u001b[39mto_value(u\u001b[38;5;241m.\u001b[39mrad), lmax\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mint\u001b[39m(\u001b[38;5;241m1.5\u001b[39m \u001b[38;5;241m*\u001b[39m pysm_nside)) \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m \u001b[38;5;241m2\u001b[39m\n\u001b[1;32m 29\u001b[0m )\n\u001b[1;32m 30\u001b[0m onecl[label] \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m\n\u001b[1;32m 31\u001b[0m onecl[label][: \u001b[38;5;28mlen\u001b[39m(pysm_low)] \u001b[38;5;241m=\u001b[39m pysm_low\n",
"File \u001b[0;32m~/micromamba/envs/cmb/lib/python3.12/site-packages/astropy/table/row.py:64\u001b[0m, in \u001b[0;36mRow.__getitem__\u001b[0;34m(self, item)\u001b[0m\n\u001b[1;32m 61\u001b[0m out \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mtuple\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mvalues())[item]\n\u001b[1;32m 62\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 63\u001b[0m \u001b[38;5;66;03m# This is only to raise an exception\u001b[39;00m\n\u001b[0;32m---> 64\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[43m_table\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcolumns\u001b[49m\u001b[43m[\u001b[49m\u001b[43mitem\u001b[49m\u001b[43m]\u001b[49m[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_index]\n\u001b[1;32m 65\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m out\n",
"File \u001b[0;32m~/micromamba/envs/cmb/lib/python3.12/site-packages/astropy/table/table.py:267\u001b[0m, in \u001b[0;36mTableColumns.__getitem__\u001b[0;34m(self, item)\u001b[0m\n\u001b[1;32m 256\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Get items from a TableColumns object.\u001b[39;00m\n\u001b[1;32m 257\u001b[0m \n\u001b[1;32m 258\u001b[0m \u001b[38;5;124;03m::\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 264\u001b[0m \u001b[38;5;124;03m tc[1:3] # <TableColumns names=('b', 'c')>\u001b[39;00m\n\u001b[1;32m 265\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 266\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(item, \u001b[38;5;28mstr\u001b[39m):\n\u001b[0;32m--> 267\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mOrderedDict\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[38;5;21;43m__getitem__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mitem\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 268\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(item, (\u001b[38;5;28mint\u001b[39m, np\u001b[38;5;241m.\u001b[39minteger)):\n\u001b[1;32m 269\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mlist\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mvalues())[item]\n",
"\u001b[0;31mKeyError\u001b[0m: 'fwhm'"
]
}
],
"source": [
"for config_file in toml_files:\n",
" mapsim = mapsims.from_config(\n",
" [\"common.toml\", config_file], override={\"channels\": \"all\"}\n",
" )\n",
" component = config_file.split(\".\")[0]\n",
" print(component)\n",
" filename = f\"output/C_ell/C_ell_{component}.pkl\"\n",
" with open(filename, \"rb\") as f:\n",
" cl[component] = pickle.load(f)\n",
" sky = pysm.Sky(\n",
" nside=pysm_nside,\n",
" preset_strings=[mapsim.pysm_components_string],\n",
" output_unit=u.uK_CMB,\n",
" )\n",
" onecl = (\n",
" pd.DataFrame({ch: pd.Series(cl[component][ch][i_pol]) for ch in channels})\n",
" .reset_index()\n",
" .rename(columns={\"index\": \"ell\"})\n",
" )\n",
"\n",
" pysm_emission = sky.get_emission(chs[\"center_frequency\"][0])\n",
" label = \"PySM \" + channels[0]\n",
"\n",
" pysm_low = hp.anafast(\n",
" pysm_emission, lmax=int(1.5 * pysm_nside), use_pixel_weights=True\n",
" )[i_pol]\n",
" pysm_low *= (\n",
" hp.gauss_beam(chs[0][\"fwhm\"].to_value(u.rad), lmax=int(1.5 * pysm_nside)) ** 2\n",
" )\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",
" pysm_high = hp.anafast(\n",
" pysm_emission, lmax=int(1.5 * pysm_nside), use_pixel_weights=True\n",
" )[i_pol]\n",
" pysm_high *= (\n",
" hp.gauss_beam(chs[-1][\"fwhm\"].to_value(u.rad), lmax=int(1.5 * pysm_nside)) ** 2\n",
" )\n",
" onecl[label] = 0\n",
" onecl[label][: len(pysm_high)] = pysm_high\n",
"\n",
" onecl = onecl[onecl.ell != 0]\n",
" decim = np.concatenate(\n",
" [[0], np.logspace(0, np.log10(len(onecl)), 100, endpoint=False)]\n",
" )\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 = (\n",
" alt.Chart(onecl_long, title=component + \" \" + pol_label)\n",
" .mark_line()\n",
" .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(\n",
" \"channel\",\n",
" sort=[\"PySM \" + channels[0]]\n",
" + list(channels)\n",
" + [\"PySM \" + channels[-1]],\n",
" ),\n",
" opacity=alt.condition(selection[component], alt.value(1), alt.value(0.2)),\n",
" )\n",
" .add_selection(selection[component])\n",
" .interactive()\n",
" )\n",
" chart.display()\n",
" # chart.save(f\"verification/out_plot_cl/{component}_{input_telescope}_{pol}.json\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8a0b83d4",
"metadata": {
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"tags": []
},
"outputs": [],
"source": [
"len(onecl)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1ad0f49e",
"metadata": {
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"tags": []
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "30487b87",
"metadata": {
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"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": "cmb",
"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.12.7"
},
"papermill": {
"default_parameters": {},
"duration": 19.232804,
"end_time": "2025-02-28T20:53:34.728259",
"environment_variables": {},
"exception": true,
"input_path": "plot_cl.ipynb",
"output_path": "out_plot_cl_T.ipynb",
"parameters": {
"pol": "T"
},
"start_time": "2025-02-28T20:53:15.495455",
"version": "2.6.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment