{ "cells": [ { "cell_type": "markdown", "id": "54383333457ada66", "metadata": {}, "source": [ "[](https://colab.research.google.com/github/nrao/astrohack/blob/v1.0.1/docs/beamcut_tutorial.ipynb)" ] }, { "cell_type": "markdown", "id": "f4ce33ae2c4a0b61", "metadata": { "collapsed": true, "jupyter": { "outputs_hidden": true } }, "source": [ "" ] }, { "cell_type": "markdown", "id": "68e9cee71e47e521", "metadata": {}, "source": [ "# Beam cut analysis tutorial\n", "\n", "Beam cuts are a commonly used measurement to infer properties of the telescope beam without having to resort to a much more expensive full holography. With that in mind `astrohack.beamcut` was created with an intent to aid VLA operations and in the near future the commissioning of the ngVLA prototype antenna. In this tutorial we go through the astrohack reduction of a calibrated ms." ] }, { "cell_type": "code", "execution_count": 1, "id": "cd51135c1a9c538c", "metadata": { "ExecuteTime": { "end_time": "2026-02-10T16:51:07.392844902Z", "start_time": "2026-02-10T16:51:04.832433643Z" }, "execution": { "iopub.execute_input": "2026-03-19T21:38:57.408613Z", "iopub.status.busy": "2026-03-19T21:38:57.408482Z", "iopub.status.idle": "2026-03-19T21:38:59.535647Z", "shell.execute_reply": "2026-03-19T21:38:59.535105Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "AstroHACK version 1.0.1 already installed.\n" ] } ], "source": [ "import os\n", "\n", "try:\n", " import astrohack\n", "\n", " print(\"AstroHACK version\", astrohack.__version__, \"already installed.\")\n", "except ImportError as e:\n", " print(e)\n", " print(\"Installing AstroHACK\")\n", "\n", " os.system(\"pip install astrohack\")\n", "\n", " import astrohack\n", "\n", " print(\"astrohack version\", astrohack.__version__, \" installed.\")" ] }, { "cell_type": "markdown", "id": "e69e12b1c4a437f2", "metadata": {}, "source": [ "## Download tutorial data" ] }, { "cell_type": "code", "execution_count": 2, "id": "fe3dd386e7860dd0", "metadata": { "ExecuteTime": { "end_time": "2026-02-10T16:51:11.192069726Z", "start_time": "2026-02-10T16:51:07.396407775Z" }, "execution": { "iopub.execute_input": "2026-03-19T21:38:59.536919Z", "iopub.status.busy": "2026-03-19T21:38:59.536751Z", "iopub.status.idle": "2026-03-19T21:39:00.424230Z", "shell.execute_reply": "2026-03-19T21:39:00.423739Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[\u001b[38;2;128;05;128m2026-03-19 15:38:59,537\u001b[0m] \u001b[38;2;50;50;205m INFO\u001b[0m\u001b[38;2;112;128;144m astrohack: \u001b[0m Updating file metadata information ... \n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "3eda0ff389f3460a82ac91e1dcd9f846", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Output()" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n" ], "text/plain": [] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "[\u001b[38;2;128;05;128m2026-03-19 15:38:59,751\u001b[0m] \u001b[38;2;50;50;205m INFO\u001b[0m\u001b[38;2;112;128;144m astrohack: \u001b[0m Module path: \u001b[38;2;50;50;205m/export/home/arya/miniforge3/envs/casadev/lib/python3.12/site-packages/toolviper\u001b[0m \n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "[\u001b[38;2;128;05;128m2026-03-19 15:38:59,755\u001b[0m] \u001b[38;2;50;50;205m INFO\u001b[0m\u001b[38;2;112;128;144m astrohack: \u001b[0m Downloading from [cloudflare] .... \n" ] }, { "data": { "text/html": [ " \n",
" Download List \n",
" ──────────────────────── \n",
" kband_beamcut_small.ms \n",
" \n",
"\n"
],
"text/plain": [
" \n",
" \u001b[1m \u001b[0m\u001b[1mDownload List \u001b[0m\u001b[1m \u001b[0m \n",
" ──────────────────────── \n",
" \u001b[35mkband_beamcut_small.ms\u001b[0m \n",
" \n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f6165d4485a9476b8b41c1311f199e8f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n"
],
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Download data.\n",
"import toolviper\n",
"\n",
"basename = \"kband_beamcut_small\"\n",
"ms_name = f\"data/{basename}.ms\"\n",
"\n",
"toolviper.utils.data.update()\n",
"toolviper.utils.data.download(file=f\"{basename}.ms\", folder=\"data\")"
]
},
{
"cell_type": "markdown",
"id": "12afa92538ed8cc",
"metadata": {},
"source": [
"## Starting local Dask client"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "71a7acc19db8e999",
"metadata": {
"ExecuteTime": {
"end_time": "2026-02-10T16:51:11.261502550Z",
"start_time": "2026-02-10T16:51:11.194798840Z"
},
"execution": {
"iopub.execute_input": "2026-03-19T21:39:00.432998Z",
"iopub.status.busy": "2026-03-19T21:39:00.432881Z",
"iopub.status.idle": "2026-03-19T21:39:01.387109Z",
"shell.execute_reply": "2026-03-19T21:39:01.386626Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[\u001b[38;2;128;05;128m2026-03-19 15:39:00,448\u001b[0m] \u001b[38;2;50;50;205m INFO\u001b[0m\u001b[38;2;112;128;144m astrohack: \u001b[0m Module path: \u001b[38;2;50;50;205m/export/home/arya/miniforge3/envs/casadev/lib/python3.12/site-packages/toolviper\u001b[0m \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[\u001b[38;2;128;05;128m2026-03-19 15:39:00,452\u001b[0m] \u001b[38;2;255;160;0m WARNING\u001b[0m\u001b[38;2;112;128;144m astrohack: \u001b[0m It is recommended that the local cache directory be set using the \u001b[38;2;50;50;205mdask_local_dir\u001b[0m parameter. \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[\u001b[38;2;128;05;128m2026-03-19 15:39:01,384\u001b[0m] \u001b[38;2;50;50;205m INFO\u001b[0m\u001b[38;2;112;128;144m astrohack: \u001b[0m Client <xarray.DataTree 'cut_0'>\n",
"Group: /ant_ea17/ddi_0/cut_0\n",
" Dimensions: (lm_dist: 487, time: 487, lm: 2)\n",
" Coordinates:\n",
" * lm_dist (lm_dist) float64 4kB -0.002873 -0.002863 ... 0.002871\n",
" * time (time) float64 4kB 5.271e+09 5.271e+09 ... 5.271e+09 5.271e+09\n",
" Dimensions without coordinates: lm\n",
" Data variables:\n",
" LL_amp_fit (lm_dist) float64 4kB dask.array<chunksize=(487,), meta=np.ndarray>\n",
" LL_amplitude (lm_dist) float64 4kB dask.array<chunksize=(487,), meta=np.ndarray>\n",
" LL_phase (lm_dist) float64 4kB dask.array<chunksize=(487,), meta=np.ndarray>\n",
" LL_weight (lm_dist) float64 4kB dask.array<chunksize=(487,), meta=np.ndarray>\n",
" RR_amp_fit (lm_dist) float64 4kB dask.array<chunksize=(487,), meta=np.ndarray>\n",
" RR_amplitude (lm_dist) float64 4kB dask.array<chunksize=(487,), meta=np.ndarray>\n",
" RR_phase (lm_dist) float64 4kB dask.array<chunksize=(487,), meta=np.ndarray>\n",
" RR_weight (lm_dist) float64 4kB dask.array<chunksize=(487,), meta=np.ndarray>\n",
" lm_offsets (time, lm) float64 8kB dask.array<chunksize=(487, 2), meta=np.ndarray>\n",
" Attributes: (12/19)\n",
" LL_amp_fit_pars: [-0.0020771884159861693, 0.16536998921100482, ...\n",
" LL_first_side_lobe_ratio: 0.9506975351868078\n",
" LL_fit_succeeded: True\n",
" LL_n_peaks: 5\n",
" LL_pb_center: 2.0066879975923337e-05\n",
" LL_pb_fwhm: 0.0007089940968873998\n",
" ... ...\n",
" available_corrs: ['RR', 'LL']\n",
" direction: El. cut (S -> N)\n",
" lm_angle: 8.043802534404685e-06\n",
" scan_number: 8\n",
" time_string: 2025-11-25 23:16\n",
" xlabel: Elevation offsetfile.download.json ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0% -:--:--\n\n", "text/plain": "file.download.json \u001b[38;5;237m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[35m 0%\u001b[0m \u001b[36m-:--:--\u001b[0m\n" }, "metadata": {}, "output_type": "display_data" } ], "tabbable": null, "tooltip": null } }, "9e199913593742688c46fac12c3486c0": { "model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "2.0.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "2.0.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border_bottom": null, "border_left": null, "border_right": null, "border_top": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "d8144e36dcaa4825a67d85cc81dc1934": { "model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "2.0.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "2.0.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border_bottom": null, "border_left": null, "border_right": null, "border_top": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "f6165d4485a9476b8b41c1311f199e8f": { "model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/output", "_model_module_version": "1.0.0", "_model_name": "OutputModel", "_view_count": null, "_view_module": "@jupyter-widgets/output", "_view_module_version": "1.0.0", "_view_name": "OutputView", "layout": "IPY_MODEL_d8144e36dcaa4825a67d85cc81dc1934", "msg_id": "", "outputs": [ { "data": { "text/html": "
kband_beamcut_small.ms ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00\n\n", "text/plain": "kband_beamcut_small.ms \u001b[38;2;114;156;31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[35m100%\u001b[0m \u001b[36m0:00:00\u001b[0m\n" }, "metadata": {}, "output_type": "display_data" } ], "tabbable": null, "tooltip": null } } }, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 5 }