|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "(under construction)\n", |
| 8 | + "\n", |
| 9 | + "Adapted from [a notebook](https://nbviewer.jupyter.org/github/marksubbarao/pyWWT_AAS225/blob/master/SgrStream.ipynb) by Mark SubbaRao that uses files from [here](http://www.astro.virginia.edu/~srm4n/Sgr/data.html) and visualizes the tidal disruption of the Sagittarius Dwarf Galaxy described in [Law & Majewski 2010](https://iopscience.iop.org/article/10.1088/0004-637X/714/1/229)." |
| 10 | + ] |
| 11 | + }, |
| 12 | + { |
| 13 | + "cell_type": "code", |
| 14 | + "execution_count": null, |
| 15 | + "metadata": {}, |
| 16 | + "outputs": [], |
| 17 | + "source": [ |
| 18 | + "import time\n", |
| 19 | + "\n", |
| 20 | + "from astropy.coordinates import SkyCoord\n", |
| 21 | + "from astropy import units as u\n", |
| 22 | + "from astropy.table import Table, Column\n", |
| 23 | + "from astropy.time import Time, TimeDelta\n", |
| 24 | + "\n", |
| 25 | + "import numpy as np\n", |
| 26 | + "\n", |
| 27 | + "from astroquery.vizier import Vizier\n", |
| 28 | + "from astroquery.nasa_exoplanet_archive import NasaExoplanetArchive\n", |
| 29 | + "\n", |
| 30 | + "from pywwt.jupyter import WWTJupyterWidget" |
| 31 | + ] |
| 32 | + }, |
| 33 | + { |
| 34 | + "cell_type": "code", |
| 35 | + "execution_count": null, |
| 36 | + "metadata": {}, |
| 37 | + "outputs": [], |
| 38 | + "source": [ |
| 39 | + "wwt = WWTJupyterWidget()\n", |
| 40 | + "#wwt" |
| 41 | + ] |
| 42 | + }, |
| 43 | + { |
| 44 | + "cell_type": "code", |
| 45 | + "execution_count": null, |
| 46 | + "metadata": {}, |
| 47 | + "outputs": [], |
| 48 | + "source": [ |
| 49 | + "# import and manipulate a table with stellar stream data\n", |
| 50 | + "stars = Table.read('https://raw.githubusercontent.com/WorldWideTelescope/pywwt-notebooks/137d6a398b4ba0b6de332cd4603e8e40c74bedcf/tutorials/data/SgrTriax_DYN.dat',\n", |
| 51 | + " format='ascii.basic')\n", |
| 52 | + "#stars = Table.read('SgrTriax_DYN.dat', format='ascii.basic')\n", |
| 53 | + "stars.keep_columns([\"ra\",\"dec\",\"dist\",\"Pcol\"])\n", |
| 54 | + "stars['ra'].unit = u.deg\n", |
| 55 | + "stars['dec'].unit = u.deg\n", |
| 56 | + "stars['dist'] *= 1000\n", |
| 57 | + "stars['dist'].unit = u.pc\n", |
| 58 | + "#stars.rename_column('dist','distance')\n", |
| 59 | + "\n", |
| 60 | + "# add a column of colors for each point for pywwt to read\n", |
| 61 | + "stars['colormap'] = '#000000'\n", |
| 62 | + "for i, val in enumerate(stars['Pcol']):\n", |
| 63 | + " if val == -1:\n", |
| 64 | + " stars['colormap'][i] = '#c0c0c0' # silver\n", |
| 65 | + " elif val == 0 or val == 1:\n", |
| 66 | + " stars['colormap'][i] = '#ffa500' # orange\n", |
| 67 | + " elif val == 2 or val == 3:\n", |
| 68 | + " stars['colormap'][i] = '#ff00ff' # magenta\n", |
| 69 | + " elif val == 4 or val == 5:\n", |
| 70 | + " stars['colormap'][i] = '#00ffff' # cyan\n", |
| 71 | + " elif val == 6 or val == 7:\n", |
| 72 | + " stars['colormap'][i] = '#228b22' # forest green" |
| 73 | + ] |
| 74 | + }, |
| 75 | + { |
| 76 | + "cell_type": "code", |
| 77 | + "execution_count": null, |
| 78 | + "metadata": {}, |
| 79 | + "outputs": [], |
| 80 | + "source": [ |
| 81 | + "stars" |
| 82 | + ] |
| 83 | + }, |
| 84 | + { |
| 85 | + "cell_type": "code", |
| 86 | + "execution_count": null, |
| 87 | + "metadata": {}, |
| 88 | + "outputs": [], |
| 89 | + "source": [ |
| 90 | + "# display the stellar streams in the viewer\n", |
| 91 | + "star_ly = wwt.layers.add_data_layer(table=stars, frame='Sky',\n", |
| 92 | + " lon_att='ra', lat_att='dec',\n", |
| 93 | + " alt_att='dist', alt_type='distance',\n", |
| 94 | + " cmap_att='depth', size_scale=20)\n", |
| 95 | + "\n", |
| 96 | + "star_ly.far_side_visible = True" |
| 97 | + ] |
| 98 | + }, |
| 99 | + { |
| 100 | + "cell_type": "code", |
| 101 | + "execution_count": null, |
| 102 | + "metadata": {}, |
| 103 | + "outputs": [], |
| 104 | + "source": [ |
| 105 | + "# import and manipulate a table containing Sgr Dwarf's orbital data\n", |
| 106 | + "orbit = Table.read('https://raw.githubusercontent.com/WorldWideTelescope/pywwt-notebooks/137d6a398b4ba0b6de332cd4603e8e40c74bedcf/tutorials/data/SgrTriax_orbit.dat',\n", |
| 107 | + " format='ascii.basic')\n", |
| 108 | + "#orbit = Table.read('SgrTriax_orbit.dat', format='ascii.basic')\n", |
| 109 | + "orbit.keep_columns(['time', 'ra', 'dec', 'dist'])\n", |
| 110 | + "orbit['ra'].unit = u.deg\n", |
| 111 | + "orbit['dec'].unit = u.deg\n", |
| 112 | + "orbit['time'].unit = u.Gyr\n", |
| 113 | + "orbit['dist'] *= 1000\n", |
| 114 | + "#orbit.rename_column('dist', 'distance')" |
| 115 | + ] |
| 116 | + }, |
| 117 | + { |
| 118 | + "cell_type": "code", |
| 119 | + "execution_count": null, |
| 120 | + "metadata": {}, |
| 121 | + "outputs": [], |
| 122 | + "source": [ |
| 123 | + "# translate times from gigayears, which are too large for pywwt, ...\n", |
| 124 | + "# to days -- so 1 day in the viewer translates to 1 gigayear real-time\n", |
| 125 | + "base = Time('2019-01-01', format='iso').jd\n", |
| 126 | + "orbit['wwt_times'] = base\n", |
| 127 | + "orbit['wwt_times'] += orbit['time']" |
| 128 | + ] |
| 129 | + }, |
| 130 | + { |
| 131 | + "cell_type": "code", |
| 132 | + "execution_count": null, |
| 133 | + "metadata": {}, |
| 134 | + "outputs": [], |
| 135 | + "source": [ |
| 136 | + "orbit" |
| 137 | + ] |
| 138 | + }, |
| 139 | + { |
| 140 | + "cell_type": "code", |
| 141 | + "execution_count": null, |
| 142 | + "metadata": {}, |
| 143 | + "outputs": [], |
| 144 | + "source": [ |
| 145 | + "# display Sgr Dwarf in the viewer\n", |
| 146 | + "orb_ly = wwt.layers.add_data_layer(table=orbit[:300], frame='Sky',\n", |
| 147 | + " lon_att='ra', lat_att='dec',\n", |
| 148 | + " alt_att='dist', alt_type='distance',\n", |
| 149 | + " size_scale=20)\n", |
| 150 | + "\n", |
| 151 | + "orb_ly.far_side_visible = True" |
| 152 | + ] |
| 153 | + } |
| 154 | + ], |
| 155 | + "metadata": { |
| 156 | + "kernelspec": { |
| 157 | + "display_name": "Python 3", |
| 158 | + "language": "python", |
| 159 | + "name": "python3" |
| 160 | + }, |
| 161 | + "language_info": { |
| 162 | + "codemirror_mode": { |
| 163 | + "name": "ipython", |
| 164 | + "version": 3 |
| 165 | + }, |
| 166 | + "file_extension": ".py", |
| 167 | + "mimetype": "text/x-python", |
| 168 | + "name": "python", |
| 169 | + "nbconvert_exporter": "python", |
| 170 | + "pygments_lexer": "ipython3", |
| 171 | + "version": "3.6.3" |
| 172 | + } |
| 173 | + }, |
| 174 | + "nbformat": 4, |
| 175 | + "nbformat_minor": 2 |
| 176 | +} |
0 commit comments