|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "<a id=\"top\"></a>\n", |
| 8 | + "# How to Inspect Long Tables with `mast-table`\n", |
| 9 | + "***\n", |
| 10 | + "## Learning Goals\n", |
| 11 | + "\n", |
| 12 | + "This is a beginner tutorial on viewing long data tables using [mast-table](https://https://github.com/spacetelescope/mast-table). We'll cover the basics of creating mast-tables and interacting with their data. By the end of this tutorial, you will:\n", |
| 13 | + "\n", |
| 14 | + "- Understand how to create mast-table widgets.\n", |
| 15 | + "- Be able to configure your mast-table length to fit your preferences in the Roman Research Nexus (RRN).\n", |
| 16 | + "- Know how to view mast-table in a \"popout\" window." |
| 17 | + ] |
| 18 | + }, |
| 19 | + { |
| 20 | + "cell_type": "markdown", |
| 21 | + "metadata": { |
| 22 | + "slideshow": { |
| 23 | + "slide_type": "slide" |
| 24 | + } |
| 25 | + }, |
| 26 | + "source": [ |
| 27 | + "## Table of Contents\n", |
| 28 | + "* [Introduction](#Introduction)\n", |
| 29 | + "* [Imports](#Imports)\n", |
| 30 | + "* [Inspecting Long mast-tables](#Inspecting-Long-mast-tables)\n", |
| 31 | + " * [Retrieving MAST Data](#Retrieving-MAST-Data)\n", |
| 32 | + " * [Creating a mast-table](#Creating-a-mast-table)\n", |
| 33 | + " * [Changing Table Length](#Changing-Table-Length)\n", |
| 34 | + " * [Using Table Popout](#Using-Table-Popout)\n", |
| 35 | + "\n", |
| 36 | + "## Introduction\n", |
| 37 | + "This tutorial familiarizes you with how to create and manipulate views of [mast-table](https://https://github.com/spacetelescope/mast-table), allowing you to adjust your notebook displays for your ideal table length. We use the package [astroquery](https://github.com/astropy/astroquery) to retrieve data from the [Mikulski Archive for Space Telescopes (MAST)](https://archive.stsci.edu/) for the mast-tables. For more information about using `MastMissions` (a Python wrapper for the [MAST Search API](https://mast.stsci.edu/search/docs/) that allows you to search for mission-specific dataset metadata and data products), see the notebook in `mast_notebooks/notebooks/multi_mission/missions_mast_search/missions_mast_search.ipynb`." |
| 38 | + ] |
| 39 | + }, |
| 40 | + { |
| 41 | + "cell_type": "markdown", |
| 42 | + "metadata": { |
| 43 | + "slideshow": { |
| 44 | + "slide_type": "slide" |
| 45 | + } |
| 46 | + }, |
| 47 | + "source": [ |
| 48 | + "## Imports\n", |
| 49 | + "We will leverage the `mast-table` package to create flexible app layouts, and we will use `astroquery` to populate the table widgets with example data.\n", |
| 50 | + "\n", |
| 51 | + "- `mast-table` to create table widgets\n", |
| 52 | + "- `astroquery` for retrieving example data to view" |
| 53 | + ] |
| 54 | + }, |
| 55 | + { |
| 56 | + "cell_type": "code", |
| 57 | + "execution_count": null, |
| 58 | + "metadata": { |
| 59 | + "slideshow": { |
| 60 | + "slide_type": "fragment" |
| 61 | + } |
| 62 | + }, |
| 63 | + "outputs": [], |
| 64 | + "source": [ |
| 65 | + "from mast_table import MastTable\n", |
| 66 | + "from astroquery.mast import MastMissions" |
| 67 | + ] |
| 68 | + }, |
| 69 | + { |
| 70 | + "cell_type": "markdown", |
| 71 | + "metadata": {}, |
| 72 | + "source": [ |
| 73 | + "***" |
| 74 | + ] |
| 75 | + }, |
| 76 | + { |
| 77 | + "cell_type": "markdown", |
| 78 | + "metadata": {}, |
| 79 | + "source": [ |
| 80 | + "## Inspecting Long mast-tables" |
| 81 | + ] |
| 82 | + }, |
| 83 | + { |
| 84 | + "cell_type": "markdown", |
| 85 | + "metadata": { |
| 86 | + "slideshow": { |
| 87 | + "slide_type": "slide" |
| 88 | + } |
| 89 | + }, |
| 90 | + "source": [ |
| 91 | + "### Retrieving MAST Data" |
| 92 | + ] |
| 93 | + }, |
| 94 | + { |
| 95 | + "cell_type": "markdown", |
| 96 | + "metadata": {}, |
| 97 | + "source": [ |
| 98 | + "First, we will get example MAST data from `astroquery` using the cell below. We are retrieving MAST data on Messier 1 from the [James Webb Space Telescope (JWST)]((https://www.stsci.edu/jwst))." |
| 99 | + ] |
| 100 | + }, |
| 101 | + { |
| 102 | + "cell_type": "code", |
| 103 | + "execution_count": null, |
| 104 | + "metadata": {}, |
| 105 | + "outputs": [], |
| 106 | + "source": [ |
| 107 | + "# Create MastMissions object to search for JWST datasets\n", |
| 108 | + "missions = MastMissions(mission='jwst')\n", |
| 109 | + "\n", |
| 110 | + "# Query for Messier 1 ('M1')\n", |
| 111 | + "results = missions.query_object('M1')" |
| 112 | + ] |
| 113 | + }, |
| 114 | + { |
| 115 | + "cell_type": "markdown", |
| 116 | + "metadata": {}, |
| 117 | + "source": [ |
| 118 | + "### Creating a mast-table" |
| 119 | + ] |
| 120 | + }, |
| 121 | + { |
| 122 | + "cell_type": "markdown", |
| 123 | + "metadata": { |
| 124 | + "slideshow": { |
| 125 | + "slide_type": "slide" |
| 126 | + } |
| 127 | + }, |
| 128 | + "source": [ |
| 129 | + "We will create an instance of `mast_table` using the cell below. We are displaying the widget inline below the cell." |
| 130 | + ] |
| 131 | + }, |
| 132 | + { |
| 133 | + "cell_type": "code", |
| 134 | + "execution_count": null, |
| 135 | + "metadata": {}, |
| 136 | + "outputs": [], |
| 137 | + "source": [ |
| 138 | + "# Create a mast-table instance\n", |
| 139 | + "mast_table = MastTable(results)\n", |
| 140 | + "\n", |
| 141 | + "# Display the widget below\n", |
| 142 | + "mast_table" |
| 143 | + ] |
| 144 | + }, |
| 145 | + { |
| 146 | + "cell_type": "markdown", |
| 147 | + "metadata": {}, |
| 148 | + "source": [ |
| 149 | + "You now have a `mast-table` instance displayed in-line above. By default, `mast-table` displays 5 rows perpage, so you should see the first 5 results displayed in the table.\n", |
| 150 | + "\n", |
| 151 | + "Using the arrow buttons on the bottom right of the table widget, change the page displayed so that you see the results \"11-15\"." |
| 152 | + ] |
| 153 | + }, |
| 154 | + { |
| 155 | + "cell_type": "markdown", |
| 156 | + "metadata": {}, |
| 157 | + "source": [ |
| 158 | + "---" |
| 159 | + ] |
| 160 | + }, |
| 161 | + { |
| 162 | + "cell_type": "markdown", |
| 163 | + "metadata": {}, |
| 164 | + "source": [ |
| 165 | + "### Changing Table Length" |
| 166 | + ] |
| 167 | + }, |
| 168 | + { |
| 169 | + "cell_type": "markdown", |
| 170 | + "metadata": {}, |
| 171 | + "source": [ |
| 172 | + "Though `mast-table` defaults to displaying 5 rows per page, you can adjust the number of rows displayed using the \"Rows per page\" dropdown menu on the bottom right of the table. Using this menu, adjust the `mast-table` instance above to display 10 rows, 15 rows, and then all rows." |
| 173 | + ] |
| 174 | + }, |
| 175 | + { |
| 176 | + "cell_type": "markdown", |
| 177 | + "metadata": {}, |
| 178 | + "source": [ |
| 179 | + "---" |
| 180 | + ] |
| 181 | + }, |
| 182 | + { |
| 183 | + "cell_type": "markdown", |
| 184 | + "metadata": {}, |
| 185 | + "source": [ |
| 186 | + "\n", |
| 187 | + "We are interacting with well over 200 rows of data, which is not the easiest to view in chunks of 5 to 10 rows or by displaying \"all rows\". \n", |
| 188 | + "\n", |
| 189 | + "\n", |
| 190 | + "Users can specify `items_per_page` to any length they desire when creating a `mast-table` instance. Let's say that increments of 50 fit nicely on your screen. Using the cell below, create a `mast-table` that shows 50 rows per page." |
| 191 | + ] |
| 192 | + }, |
| 193 | + { |
| 194 | + "cell_type": "code", |
| 195 | + "execution_count": null, |
| 196 | + "metadata": {}, |
| 197 | + "outputs": [], |
| 198 | + "source": [ |
| 199 | + "# Create a mast-tableinstance\n", |
| 200 | + "mast_table_50 = MastTable(\n", |
| 201 | + " results,\n", |
| 202 | + " items_per_page=50\n", |
| 203 | + ")\n", |
| 204 | + "\n", |
| 205 | + "# Display the widget below\n", |
| 206 | + "mast_table_50" |
| 207 | + ] |
| 208 | + }, |
| 209 | + { |
| 210 | + "cell_type": "markdown", |
| 211 | + "metadata": {}, |
| 212 | + "source": [ |
| 213 | + "Take a moment now to scroll through the pages of data displayed (using the buttons on the bottom right of the widget) or set your own custom `items_per_page` to fit your screen." |
| 214 | + ] |
| 215 | + }, |
| 216 | + { |
| 217 | + "cell_type": "markdown", |
| 218 | + "metadata": {}, |
| 219 | + "source": [ |
| 220 | + "---" |
| 221 | + ] |
| 222 | + }, |
| 223 | + { |
| 224 | + "cell_type": "markdown", |
| 225 | + "metadata": {}, |
| 226 | + "source": [ |
| 227 | + "### Using Table Popout" |
| 228 | + ] |
| 229 | + }, |
| 230 | + { |
| 231 | + "cell_type": "markdown", |
| 232 | + "metadata": {}, |
| 233 | + "source": [ |
| 234 | + "Displaying `mast-table` inline can still make your workflow more challenging if you need to scroll to interact with other parts of the notebook. `mast-table` offers a \"popout\" button that opens the widget in a separate browser window. You can then adjust the browser window dimensions to fit your screen and keep you `mast-table` visible while you work elsewhere in the notebook. Below, outlined in red, is the popout button. Click the button for `mast_table_50` and customize your browser window so that you can see this notebook and the table. \n", |
| 235 | + "\n", |
| 236 | + "\"" |
| 237 | + ] |
| 238 | + }, |
| 239 | + { |
| 240 | + "cell_type": "markdown", |
| 241 | + "metadata": { |
| 242 | + "slideshow": { |
| 243 | + "slide_type": "slide" |
| 244 | + } |
| 245 | + }, |
| 246 | + "source": [ |
| 247 | + "## About this Notebook\n", |
| 248 | + "\n", |
| 249 | + "**Author(s):** Celia Parts <br>\n", |
| 250 | + "**Keyword(s):** Tutorial, mast-table, introduction <br>\n", |
| 251 | + "**First published:** June 2026 <br>\n", |
| 252 | + "**Last updated:** June 2026 <br>\n", |
| 253 | + "\n", |
| 254 | + "***\n", |
| 255 | + "[Top of Page](#top)\n", |
| 256 | + "<img style=\"float: right;\" src=\"https://raw.githubusercontent.com/spacetelescope/style-guides/master/guides/images/stsci-logo.png\" alt=\"Space Telescope Logo\" width=\"200px\"/> " |
| 257 | + ] |
| 258 | + }, |
| 259 | + { |
| 260 | + "cell_type": "code", |
| 261 | + "execution_count": null, |
| 262 | + "metadata": {}, |
| 263 | + "outputs": [], |
| 264 | + "source": [] |
| 265 | + } |
| 266 | + ], |
| 267 | + "metadata": { |
| 268 | + "kernelspec": { |
| 269 | + "display_name": "Python 3 (ipykernel)", |
| 270 | + "language": "python", |
| 271 | + "name": "python3" |
| 272 | + }, |
| 273 | + "language_info": { |
| 274 | + "codemirror_mode": { |
| 275 | + "name": "ipython", |
| 276 | + "version": 3 |
| 277 | + }, |
| 278 | + "file_extension": ".py", |
| 279 | + "mimetype": "text/x-python", |
| 280 | + "name": "python", |
| 281 | + "nbconvert_exporter": "python", |
| 282 | + "pygments_lexer": "ipython3", |
| 283 | + "version": "3.11.11" |
| 284 | + } |
| 285 | + }, |
| 286 | + "nbformat": 4, |
| 287 | + "nbformat_minor": 4 |
| 288 | +} |
0 commit comments