{ "cells": [ { "cell_type": "markdown", "id": "3b8c3776", "metadata": {}, "source": [ "[](https://colab.research.google.com/github/casangi/graphviper/blob/main/docs/graph_building_tutorial_image.ipynb)" ] }, { "cell_type": "markdown", "id": "ed122f09-ead5-4a22-a70b-7702d556e7fe", "metadata": {}, "source": [ "# GraphVIPER Tutorial: Image" ] }, { "cell_type": "code", "execution_count": 1, "id": "e7850f0a-f46a-48cc-98b1-fde794af919a", "metadata": { "ExecuteTime": { "end_time": "2026-03-10T06:41:09.345459Z", "start_time": "2026-03-10T06:41:08.884462Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "GraphVIPER version 0.0.39 already installed.\n" ] } ], "source": [ "import os\n", "import xradio\n", "\n", "from importlib.metadata import version\n", "\n", "try:\n", " import graphviper\n", "\n", " print(\"GraphVIPER version\", version(\"graphviper\"), \"already installed.\")\n", "except ImportError as e:\n", " print(e)\n", " print(\"Installing GraphVIPER\")\n", "\n", " os.system(\"pip install graphviper\")\n", "\n", " \n", "\n", " print(\"GraphVIPER version\", version(\"graphviper\"), \" installed.\")" ] }, { "cell_type": "markdown", "id": "e0aa8d3c-6fd9-474f-9223-6da8856ab948", "metadata": {}, "source": [ "## Download dataset" ] }, { "cell_type": "code", "execution_count": 2, "id": "d4f2b674-78e3-4dbb-9079-2b46825e1f3a", "metadata": { "ExecuteTime": { "end_time": "2026-03-10T06:41:11.581205Z", "start_time": "2026-03-10T06:41:11.540991Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[\u001b[38;2;128;05;128m2026-04-06 15:37:46,961\u001b[0m] \u001b[38;2;50;50;205m INFO\u001b[0m\u001b[38;2;112;128;144m toolviper: \u001b[0m Initializing download... \n" ] }, { "data": { "text/html": [ "
/Users/jsteeb/miniforge3/envs/zinc/lib/python3.13/site-packages/rich/live.py:260: UserWarning: install \"ipywidgets\"\n",
"for Jupyter support\n",
" warnings.warn('install \"ipywidgets\" for Jupyter support')\n",
"\n"
],
"text/plain": [
"/Users/jsteeb/miniforge3/envs/zinc/lib/python3.13/site-packages/rich/live.py:260: UserWarning: install \"ipywidgets\"\n",
"for Jupyter support\n",
" warnings.warn('install \"ipywidgets\" for Jupyter support')\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n"
],
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import toolviper\n",
"\n",
"toolviper.utils.data.download(file=\"demo_simulated.im\")"
]
},
{
"cell_type": "markdown",
"id": "2682bb1c-c377-47f2-9faa-271108954d8f",
"metadata": {},
"source": [
"## Setup Dask Cluster\n",
"To simplify things we are going to start of by just using a single thread (everything will run in serial)."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "f4e50179-3486-4454-9036-ff55d24346fc",
"metadata": {
"ExecuteTime": {
"end_time": "2026-03-10T06:41:13.810477Z",
"start_time": "2026-03-10T06:41:13.789712Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"<xarray.Dataset> Size: 20MB\n",
"Dimensions: (time: 1, frequency: 50, polarization: 4, l: 200,\n",
" m: 100, beam_params_label: 3)\n",
"Coordinates:\n",
" * time (time) float64 8B 5.154e+04\n",
" * frequency (frequency) float64 400B 1.415e+09 ... 1.415e+09\n",
" velocity (frequency) float64 400B 1.146e+06 ... 1.136e+06\n",
" * polarization (polarization) <U1 16B 'I' 'Q' 'U' 'V'\n",
" * l (l) float64 2kB 0.02909 0.0288 ... -0.02851 -0.0288\n",
" * m (m) float64 800B -0.01454 -0.01425 ... 0.01396 0.01425\n",
" right_ascension (l, m) float64 160kB 0.0291 0.0291 ... 6.254 6.254\n",
" declination (l, m) float64 160kB -0.01454 -0.01425 ... 0.01425\n",
" * beam_params_label (beam_params_label) <U5 60B 'major' 'minor' 'pa'\n",
"Data variables:\n",
" SKY (time, frequency, polarization, l, m) float32 16MB dask.array<chunksize=(1, 50, 4, 40, 20), meta=np.ndarray>\n",
" BEAM_FIT_PARAMS_SKY (time, frequency, polarization, beam_params_label) float64 5kB dask.array<chunksize=(1, 50, 4, 3), meta=np.ndarray>\n",
" FLAG_SKY (time, frequency, polarization, l, m) bool 4MB dask.array<chunksize=(1, 50, 4, 40, 20), meta=np.ndarray>\n",
"Attributes:\n",
" coordinate_system_info: {'reference_direction': {'attrs': {'frame': 'fk5...\n",
" type: image_dataset\n",
" data_groups: {'base': {'sky': 'SKY', 'beam_fit_params_sky': '...