Skip to content

Instantly share code, notes, and snippets.

@zonca
Created February 28, 2025 21:06
Show Gist options
  • Save zonca/f5d7957219e47d61dd5cb0cfa0dcd1ab to your computer and use it in GitHub Desktop.
Save zonca/f5d7957219e47d61dd5cb0cfa0dcd1ab to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "f43b84dd",
"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": "f1f127b6",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:21.106428Z",
"iopub.status.busy": "2025-02-28T21:06:21.106064Z",
"iopub.status.idle": "2025-02-28T21:06:22.746139Z",
"shell.execute_reply": "2025-02-28T21:06:22.745701Z"
},
"papermill": {
"duration": 1.645588,
"end_time": "2025-02-28T21:06:22.747298",
"exception": false,
"start_time": "2025-02-28T21:06:21.101710",
"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": "6328ce46",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.754255Z",
"iopub.status.busy": "2025-02-28T21:06:22.753812Z",
"iopub.status.idle": "2025-02-28T21:06:22.758668Z",
"shell.execute_reply": "2025-02-28T21:06:22.758341Z"
},
"papermill": {
"duration": 0.009117,
"end_time": "2025-02-28T21:06:22.759444",
"exception": false,
"start_time": "2025-02-28T21:06:22.750327",
"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": "1833cd25",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.766516Z",
"iopub.status.busy": "2025-02-28T21:06:22.766317Z",
"iopub.status.idle": "2025-02-28T21:06:22.768376Z",
"shell.execute_reply": "2025-02-28T21:06:22.768044Z"
},
"papermill": {
"duration": 0.005888,
"end_time": "2025-02-28T21:06:22.769058",
"exception": false,
"start_time": "2025-02-28T21:06:22.763170",
"status": "completed"
},
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"pol = \"T\""
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "94d21fcb",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.775261Z",
"iopub.status.busy": "2025-02-28T21:06:22.775021Z",
"iopub.status.idle": "2025-02-28T21:06:22.776888Z",
"shell.execute_reply": "2025-02-28T21:06:22.776564Z"
},
"papermill": {
"duration": 0.005837,
"end_time": "2025-02-28T21:06:22.777568",
"exception": false,
"start_time": "2025-02-28T21:06:22.771731",
"status": "completed"
},
"tags": [
"injected-parameters"
]
},
"outputs": [],
"source": [
"# Parameters\n",
"pol = \"T\"\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "11091606",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.783666Z",
"iopub.status.busy": "2025-02-28T21:06:22.783473Z",
"iopub.status.idle": "2025-02-28T21:06:22.785528Z",
"shell.execute_reply": "2025-02-28T21:06:22.785188Z"
},
"papermill": {
"duration": 0.005904,
"end_time": "2025-02-28T21:06:22.786212",
"exception": false,
"start_time": "2025-02-28T21:06:22.780308",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"selection = {}\n",
"cl = {}\n",
"i_pol = \"TEB\".index(pol)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "c97cda87",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.792147Z",
"iopub.status.busy": "2025-02-28T21:06:22.791953Z",
"iopub.status.idle": "2025-02-28T21:06:22.794991Z",
"shell.execute_reply": "2025-02-28T21:06:22.794632Z"
},
"papermill": {
"duration": 0.006783,
"end_time": "2025-02-28T21:06:22.795739",
"exception": false,
"start_time": "2025-02-28T21:06:22.788956",
"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": "c41b8439",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.802213Z",
"iopub.status.busy": "2025-02-28T21:06:22.801995Z",
"iopub.status.idle": "2025-02-28T21:06:22.804331Z",
"shell.execute_reply": "2025-02-28T21:06:22.803979Z"
},
"papermill": {
"duration": 0.006433,
"end_time": "2025-02-28T21:06:22.805078",
"exception": false,
"start_time": "2025-02-28T21:06:22.798645",
"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": "2b9d4181",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.811518Z",
"iopub.status.busy": "2025-02-28T21:06:22.811216Z",
"iopub.status.idle": "2025-02-28T21:06:22.813361Z",
"shell.execute_reply": "2025-02-28T21:06:22.813015Z"
},
"papermill": {
"duration": 0.006208,
"end_time": "2025-02-28T21:06:22.814096",
"exception": false,
"start_time": "2025-02-28T21:06:22.807888",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"from astropy.table import QTable"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "311a9a17",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.820592Z",
"iopub.status.busy": "2025-02-28T21:06:22.820402Z",
"iopub.status.idle": "2025-02-28T21:06:22.825634Z",
"shell.execute_reply": "2025-02-28T21:06:22.825289Z"
},
"papermill": {
"duration": 0.009404,
"end_time": "2025-02-28T21:06:22.826463",
"exception": false,
"start_time": "2025-02-28T21:06:22.817059",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"chs = QTable.read(\"instrument_model/instrument_model.tbl\", format=\"ascii.ipac\")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "90769ced",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.832831Z",
"iopub.status.busy": "2025-02-28T21:06:22.832637Z",
"iopub.status.idle": "2025-02-28T21:06:22.836584Z",
"shell.execute_reply": "2025-02-28T21:06:22.836260Z"
},
"papermill": {
"duration": 0.007899,
"end_time": "2025-02-28T21:06:22.837271",
"exception": false,
"start_time": "2025-02-28T21:06:22.829372",
"status": "completed"
},
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<div><i>QTable length=5</i>\n",
"<table id=\"table23447043437056\" class=\"table-striped table-bordered table-condensed\">\n",
"<thead><tr><th>telescope</th><th>band</th><th>fwhm</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>arcmin</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>float64</th><th>int64</th><th>str15</th><th>str11</th></tr></thead>\n",
"<tr><td>WMAP</td><td>K</td><td>52.8</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>39.6</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>30.6</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>21.0</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>13.2</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 fwhm center_frequency nside bandpass_file beam_file \n",
" arcmin GHz \n",
" str4 str2 float64 float64 int64 str15 str11 \n",
"--------- ---- ------- ------------------ ----- --------------- -----------\n",
" WMAP K 52.8 22.451910974502667 512 bandpass_K.tbl beam_K.tbl\n",
" WMAP Ka 39.6 32.706607212937314 512 bandpass_Ka.tbl beam_Ka.tbl\n",
" WMAP Q 30.6 40.36343387766631 512 bandpass_Q.tbl beam_Q.tbl\n",
" WMAP V 21.0 60.07932358223898 512 bandpass_V.tbl beam_V.tbl\n",
" WMAP W 13.2 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": "7fe8a7c3",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.843798Z",
"iopub.status.busy": "2025-02-28T21:06:22.843605Z",
"iopub.status.idle": "2025-02-28T21:06:22.846234Z",
"shell.execute_reply": "2025-02-28T21:06:22.845924Z"
},
"papermill": {
"duration": 0.006653,
"end_time": "2025-02-28T21:06:22.846985",
"exception": false,
"start_time": "2025-02-28T21:06:22.840332",
"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": "3a87be63",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.853983Z",
"iopub.status.busy": "2025-02-28T21:06:22.853725Z",
"iopub.status.idle": "2025-02-28T21:06:22.856379Z",
"shell.execute_reply": "2025-02-28T21:06:22.856055Z"
},
"papermill": {
"duration": 0.007056,
"end_time": "2025-02-28T21:06:22.857168",
"exception": false,
"start_time": "2025-02-28T21:06:22.850112",
"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": "829916f1",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.864363Z",
"iopub.status.busy": "2025-02-28T21:06:22.864157Z",
"iopub.status.idle": "2025-02-28T21:06:22.866173Z",
"shell.execute_reply": "2025-02-28T21:06:22.865841Z"
},
"papermill": {
"duration": 0.006451,
"end_time": "2025-02-28T21:06:22.866915",
"exception": false,
"start_time": "2025-02-28T21:06:22.860464",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"import pysm3 as pysm\n",
"from pysm3 import units as u"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "d2fbc2bd",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.874025Z",
"iopub.status.busy": "2025-02-28T21:06:22.873827Z",
"iopub.status.idle": "2025-02-28T21:06:22.879691Z",
"shell.execute_reply": "2025-02-28T21:06:22.879362Z"
},
"papermill": {
"duration": 0.010402,
"end_time": "2025-02-28T21:06:22.880566",
"exception": false,
"start_time": "2025-02-28T21:06:22.870164",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"import mapsims"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "e9cac359",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.887692Z",
"iopub.status.busy": "2025-02-28T21:06:22.887454Z",
"iopub.status.idle": "2025-02-28T21:06:22.889437Z",
"shell.execute_reply": "2025-02-28T21:06:22.889100Z"
},
"papermill": {
"duration": 0.00643,
"end_time": "2025-02-28T21:06:22.890196",
"exception": false,
"start_time": "2025-02-28T21:06:22.883766",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"pol_label = [\"TT\", \"EE\", \"BB\"][i_pol]"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "c1af4986",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.897067Z",
"iopub.status.busy": "2025-02-28T21:06:22.896876Z",
"iopub.status.idle": "2025-02-28T21:06:22.898865Z",
"shell.execute_reply": "2025-02-28T21:06:22.898531Z"
},
"papermill": {
"duration": 0.006115,
"end_time": "2025-02-28T21:06:22.899544",
"exception": false,
"start_time": "2025-02-28T21:06:22.893429",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"from glob import glob"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "147470f3",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.906749Z",
"iopub.status.busy": "2025-02-28T21:06:22.906521Z",
"iopub.status.idle": "2025-02-28T21:06:22.908720Z",
"shell.execute_reply": "2025-02-28T21:06:22.908382Z"
},
"papermill": {
"duration": 0.006596,
"end_time": "2025-02-28T21:06:22.909407",
"exception": false,
"start_time": "2025-02-28T21:06:22.902811",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"toml_files = glob(\"*.toml\")"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "24df26ae",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.916603Z",
"iopub.status.busy": "2025-02-28T21:06:22.916413Z",
"iopub.status.idle": "2025-02-28T21:06:22.918391Z",
"shell.execute_reply": "2025-02-28T21:06:22.918058Z"
},
"papermill": {
"duration": 0.006485,
"end_time": "2025-02-28T21:06:22.919124",
"exception": false,
"start_time": "2025-02-28T21:06:22.912639",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"toml_files.remove(\"common.toml\")"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "bdb97c61",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.926160Z",
"iopub.status.busy": "2025-02-28T21:06:22.925970Z",
"iopub.status.idle": "2025-02-28T21:06:22.927977Z",
"shell.execute_reply": "2025-02-28T21:06:22.927643Z"
},
"papermill": {
"duration": 0.006373,
"end_time": "2025-02-28T21:06:22.928743",
"exception": false,
"start_time": "2025-02-28T21:06:22.922370",
"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": "994b441a",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.935965Z",
"iopub.status.busy": "2025-02-28T21:06:22.935774Z",
"iopub.status.idle": "2025-02-28T21:06:22.937758Z",
"shell.execute_reply": "2025-02-28T21:06:22.937426Z"
},
"papermill": {
"duration": 0.006546,
"end_time": "2025-02-28T21:06:22.938504",
"exception": false,
"start_time": "2025-02-28T21:06:22.931958",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"toml_files.sort()"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "b36f3112",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.945925Z",
"iopub.status.busy": "2025-02-28T21:06:22.945683Z",
"iopub.status.idle": "2025-02-28T21:06:22.947747Z",
"shell.execute_reply": "2025-02-28T21:06:22.947407Z"
},
"papermill": {
"duration": 0.00658,
"end_time": "2025-02-28T21:06:22.948469",
"exception": false,
"start_time": "2025-02-28T21:06:22.941889",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"pysm_nside = 2048"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "fe0424ef",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.955777Z",
"iopub.status.busy": "2025-02-28T21:06:22.955587Z",
"iopub.status.idle": "2025-02-28T21:06:22.958206Z",
"shell.execute_reply": "2025-02-28T21:06:22.957898Z"
},
"papermill": {
"duration": 0.007154,
"end_time": "2025-02-28T21:06:22.958955",
"exception": false,
"start_time": "2025-02-28T21:06:22.951801",
"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": "b490366e",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.966886Z",
"iopub.status.busy": "2025-02-28T21:06:22.966643Z",
"iopub.status.idle": "2025-02-28T21:06:22.969292Z",
"shell.execute_reply": "2025-02-28T21:06:22.968979Z"
},
"papermill": {
"duration": 0.007662,
"end_time": "2025-02-28T21:06:22.970075",
"exception": false,
"start_time": "2025-02-28T21:06:22.962413",
"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": "303a2747",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.977636Z",
"iopub.status.busy": "2025-02-28T21:06:22.977394Z",
"iopub.status.idle": "2025-02-28T21:06:22.979476Z",
"shell.execute_reply": "2025-02-28T21:06:22.979136Z"
},
"papermill": {
"duration": 0.00662,
"end_time": "2025-02-28T21:06:22.980214",
"exception": false,
"start_time": "2025-02-28T21:06:22.973594",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"channels = chs[\"band\"]"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "34c9e288",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.988007Z",
"iopub.status.busy": "2025-02-28T21:06:22.987817Z",
"iopub.status.idle": "2025-02-28T21:06:22.991220Z",
"shell.execute_reply": "2025-02-28T21:06:22.990918Z"
},
"papermill": {
"duration": 0.008221,
"end_time": "2025-02-28T21:06:22.991968",
"exception": false,
"start_time": "2025-02-28T21:06:22.983747",
"status": "completed"
},
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<div><i>QTable length=5</i>\n",
"<table id=\"table23447043437056\" class=\"table-striped table-bordered table-condensed\">\n",
"<thead><tr><th>telescope</th><th>band</th><th>fwhm</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>arcmin</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>float64</th><th>int64</th><th>str15</th><th>str11</th></tr></thead>\n",
"<tr><td>WMAP</td><td>K</td><td>52.8</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>39.6</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>30.6</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>21.0</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>13.2</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 fwhm center_frequency nside bandpass_file beam_file \n",
" arcmin GHz \n",
" str4 str2 float64 float64 int64 str15 str11 \n",
"--------- ---- ------- ------------------ ----- --------------- -----------\n",
" WMAP K 52.8 22.451910974502667 512 bandpass_K.tbl beam_K.tbl\n",
" WMAP Ka 39.6 32.706607212937314 512 bandpass_Ka.tbl beam_Ka.tbl\n",
" WMAP Q 30.6 40.36343387766631 512 bandpass_Q.tbl beam_Q.tbl\n",
" WMAP V 21.0 60.07932358223898 512 bandpass_V.tbl beam_V.tbl\n",
" WMAP W 13.2 92.82552325276862 512 bandpass_W.tbl beam_W.tbl"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"chs"
]
},
{
"cell_type": "markdown",
"id": "5ffc56ee",
"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": "69ba65db",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-28T21:06:22.999999Z",
"iopub.status.busy": "2025-02-28T21:06:22.999628Z",
"iopub.status.idle": "2025-02-28T21:06:38.433210Z",
"shell.execute_reply": "2025-02-28T21:06:38.432383Z"
},
"papermill": {
"duration": 15.438451,
"end_time": "2025-02-28T21:06:38.433990",
"exception": true,
"start_time": "2025-02-28T21:06:22.995539",
"status": "failed"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ame_a1\n"
]
},
{
"ename": "ValueError",
"evalue": "cannot set using a slice indexer with a different length than the value",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[26], line 31\u001b[0m\n\u001b[1;32m 27\u001b[0m pysm_low \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 28\u001b[0m hp\u001b[38;5;241m.\u001b[39mgauss_beam(chs[\u001b[38;5;241m0\u001b[39m][\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfwhm\u001b[39m\u001b[38;5;124m\"\u001b[39m]\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[0;32m---> 31\u001b[0m \u001b[43monecl\u001b[49m\u001b[43m[\u001b[49m\u001b[43mlabel\u001b[49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mlen\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mpysm_low\u001b[49m\u001b[43m)\u001b[49m\u001b[43m]\u001b[49m \u001b[38;5;241m=\u001b[39m pysm_low\n\u001b[1;32m 33\u001b[0m pysm_emission \u001b[38;5;241m=\u001b[39m sky\u001b[38;5;241m.\u001b[39mget_emission(\n\u001b[1;32m 34\u001b[0m chs[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m][\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcenter_frequency\u001b[39m\u001b[38;5;124m\"\u001b[39m],\n\u001b[1;32m 35\u001b[0m )\n\u001b[1;32m 36\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;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m]\n",
"File \u001b[0;32m~/micromamba/envs/cmb/lib/python3.12/site-packages/pandas/core/series.py:1295\u001b[0m, in \u001b[0;36mSeries.__setitem__\u001b[0;34m(self, key, value)\u001b[0m\n\u001b[1;32m 1293\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(key, \u001b[38;5;28mslice\u001b[39m):\n\u001b[1;32m 1294\u001b[0m indexer \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mindex\u001b[38;5;241m.\u001b[39m_convert_slice_indexer(key, kind\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mgetitem\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m-> 1295\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_set_values\u001b[49m\u001b[43m(\u001b[49m\u001b[43mindexer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalue\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mwarn\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mwarn\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1297\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 1298\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_set_with_engine(key, value, warn\u001b[38;5;241m=\u001b[39mwarn)\n",
"File \u001b[0;32m~/micromamba/envs/cmb/lib/python3.12/site-packages/pandas/core/series.py:1419\u001b[0m, in \u001b[0;36mSeries._set_values\u001b[0;34m(self, key, value, warn)\u001b[0m\n\u001b[1;32m 1416\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(key, (Index, Series)):\n\u001b[1;32m 1417\u001b[0m key \u001b[38;5;241m=\u001b[39m key\u001b[38;5;241m.\u001b[39m_values\n\u001b[0;32m-> 1419\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_mgr \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_mgr\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msetitem\u001b[49m\u001b[43m(\u001b[49m\u001b[43mindexer\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkey\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalue\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mvalue\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mwarn\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mwarn\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1420\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_maybe_update_cacher()\n",
"File \u001b[0;32m~/micromamba/envs/cmb/lib/python3.12/site-packages/pandas/core/internals/managers.py:415\u001b[0m, in \u001b[0;36mBaseBlockManager.setitem\u001b[0;34m(self, indexer, value, warn)\u001b[0m\n\u001b[1;32m 411\u001b[0m \u001b[38;5;66;03m# No need to split if we either set all columns or on a single block\u001b[39;00m\n\u001b[1;32m 412\u001b[0m \u001b[38;5;66;03m# manager\u001b[39;00m\n\u001b[1;32m 413\u001b[0m \u001b[38;5;28mself\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcopy()\n\u001b[0;32m--> 415\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mapply\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43msetitem\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mindexer\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mindexer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalue\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mvalue\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/micromamba/envs/cmb/lib/python3.12/site-packages/pandas/core/internals/managers.py:363\u001b[0m, in \u001b[0;36mBaseBlockManager.apply\u001b[0;34m(self, f, align_keys, **kwargs)\u001b[0m\n\u001b[1;32m 361\u001b[0m applied \u001b[38;5;241m=\u001b[39m b\u001b[38;5;241m.\u001b[39mapply(f, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m 362\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 363\u001b[0m applied \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mgetattr\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mb\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mf\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 364\u001b[0m result_blocks \u001b[38;5;241m=\u001b[39m extend_blocks(applied, result_blocks)\n\u001b[1;32m 366\u001b[0m out \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mtype\u001b[39m(\u001b[38;5;28mself\u001b[39m)\u001b[38;5;241m.\u001b[39mfrom_blocks(result_blocks, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maxes)\n",
"File \u001b[0;32m~/micromamba/envs/cmb/lib/python3.12/site-packages/pandas/core/internals/blocks.py:1403\u001b[0m, in \u001b[0;36mBlock.setitem\u001b[0;34m(self, indexer, value, using_cow)\u001b[0m\n\u001b[1;32m 1400\u001b[0m values \u001b[38;5;241m=\u001b[39m values\u001b[38;5;241m.\u001b[39mT\n\u001b[1;32m 1402\u001b[0m \u001b[38;5;66;03m# length checking\u001b[39;00m\n\u001b[0;32m-> 1403\u001b[0m \u001b[43mcheck_setitem_lengths\u001b[49m\u001b[43m(\u001b[49m\u001b[43mindexer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalue\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalues\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1405\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdtype \u001b[38;5;241m!=\u001b[39m _dtype_obj:\n\u001b[1;32m 1406\u001b[0m \u001b[38;5;66;03m# GH48933: extract_array would convert a pd.Series value to np.ndarray\u001b[39;00m\n\u001b[1;32m 1407\u001b[0m value \u001b[38;5;241m=\u001b[39m extract_array(value, extract_numpy\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n",
"File \u001b[0;32m~/micromamba/envs/cmb/lib/python3.12/site-packages/pandas/core/indexers/utils.py:177\u001b[0m, in \u001b[0;36mcheck_setitem_lengths\u001b[0;34m(indexer, value, values)\u001b[0m\n\u001b[1;32m 174\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m is_list_like(value):\n\u001b[1;32m 175\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(value) \u001b[38;5;241m!=\u001b[39m length_of_indexer(indexer, values) \u001b[38;5;129;01mand\u001b[39;00m values\u001b[38;5;241m.\u001b[39mndim \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m1\u001b[39m:\n\u001b[1;32m 176\u001b[0m \u001b[38;5;66;03m# In case of two dimensional value is used row-wise and broadcasted\u001b[39;00m\n\u001b[0;32m--> 177\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m 178\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcannot set using a slice indexer with a \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 179\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdifferent length than the value\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 180\u001b[0m )\n\u001b[1;32m 181\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(value):\n\u001b[1;32m 182\u001b[0m no_op \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n",
"\u001b[0;31mValueError\u001b[0m: cannot set using a slice indexer with a different length than the value"
]
}
],
"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": "d5ab0c7d",
"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": "1a985f00",
"metadata": {
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"tags": []
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "a6c83c59",
"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.24676,
"end_time": "2025-02-28T21:06:39.256506",
"environment_variables": {},
"exception": true,
"input_path": "plot_cl.ipynb",
"output_path": "out_plot_cl_T.ipynb",
"parameters": {
"pol": "T"
},
"start_time": "2025-02-28T21:06:20.009746",
"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