{ "cells": [ { "cell_type": "markdown", "id": "54383333457ada66", "metadata": {}, "source": [ "[](https://colab.research.google.com/github/nrao/astrohack/blob/v1.0.2/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-06-08T22:29:50.850907Z", "iopub.status.busy": "2026-06-08T22:29:50.850746Z", "iopub.status.idle": "2026-06-08T22:29:52.162589Z", "shell.execute_reply": "2026-06-08T22:29:52.162098Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "AstroHACK version 1.0.2 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-06-08T22:29:52.163594Z", "iopub.status.busy": "2026-06-08T22:29:52.163528Z", "iopub.status.idle": "2026-06-08T22:29:53.136480Z", "shell.execute_reply": "2026-06-08T22:29:53.135842Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[\u001b[38;2;128;05;128m2026-06-08 16:29:52,165\u001b[0m] \u001b[38;2;50;50;205m INFO\u001b[0m\u001b[38;2;112;128;144m toolviper: \u001b[0m Updating file metadata information... \n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "4b110bd8e1b84068a1bcf242622eed57", "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-06-08 16:29:52,374\u001b[0m] \u001b[38;2;50;50;205m INFO\u001b[0m\u001b[38;2;112;128;144m toolviper: \u001b[0m Initializing download... \n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "699e8b26843c4ac3b1db24db8d7cfb2c", "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-06-08T22:29:53.143391Z", "iopub.status.busy": "2026-06-08T22:29:53.143334Z", "iopub.status.idle": "2026-06-08T22:29:53.994931Z", "shell.execute_reply": "2026-06-08T22:29:53.994514Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[\u001b[38;2;128;05;128m2026-06-08 16:29:53,154\u001b[0m] \u001b[38;2;255;160;0m WARNING\u001b[0m\u001b[38;2;112;128;144m client: \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-06-08 16:29:53,992\u001b[0m] \u001b[38;2;50;50;205m INFO\u001b[0m\u001b[38;2;112;128;144m client: \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.002077188416236446, 0.16536998916703435, 0...\n",
" LL_first_side_lobe_ratio: 0.9506975352626932\n",
" LL_fit_succeeded: True\n",
" LL_n_peaks: 5\n",
" LL_pb_center: 2.0066879978481143e-05\n",
" LL_pb_fwhm: 0.0007089940968770643\n",
" ... ...\n",
" available_corrs: ['RR', 'LL']\n",
" direction: El. cut (S -> N)\n",
" lm_angle: 8.043802534404697e-06\n",
" scan_number: 8\n",
" time_string: 2025-11-25 23:16\n",
" xlabel: Elevation offset⠙ Working on download manifest update ...\n\n", "text/plain": "\u001b[32m⠙\u001b[0m \u001b[1;32mWorking on download manifest update ...\u001b[0m\n" }, "metadata": {}, "output_type": "display_data" } ], "tabbable": null, "tooltip": null } }, "699e8b26843c4ac3b1db24db8d7cfb2c": { "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_811d9b45c7784e9187f757bf30df1994", "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 } }, "811d9b45c7784e9187f757bf30df1994": { "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 } }, "b0d390f58c1642dd8c4119653c1971c1": { "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 } } }, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 5 }