Merge pull request #34 from pkgw/reorganize

Big reorganization
This commit is contained in:
Peter Williams 2020-02-12 11:51:55 -05:00 коммит произвёл GitHub
Родитель a40553cfe3 bf82583aae
Коммит f8404c645f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
31 изменённых файлов: 1763 добавлений и 696 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -1,2 +1,3 @@
.ipynb_checkpoints/
Untitled*.ipynb
figure.zip

Просмотреть файл

@ -0,0 +1,276 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Creating Interactive Figures\n",
"\n",
"This notebook will demonstrate how you can use pywwt to create [interactive figures](https://journals.aas.org/graphics-guide/#interactive_figures) suitable for submission to a journal such as [*The Astrophysical Journal*](https://apj.aas.org/)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Step 1: Starting up pywwt\n",
"\n",
"The first thing to do is to open up pywwt in this notebook. *Due to current technical limitations, the procedure is somewhat different than the one that we recommend for general usage.* However, the beginning is the same as usual: a `pywwt.jupyter` import:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pywwt.jupyter import WWTJupyterWidget"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We'll also set up a utility function to help us locate data files stored alongside this notebook:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def datapath(*args):\n",
" from os.path import join\n",
" return join('data', *args)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, well create a viewer widget and display it inline. (That's why the final line is a bare `wwt`.)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt = WWTJupyterWidget()\n",
"wwt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*It might look like you got a black screen but it's probably OK.* Click your mouse in the widget view and drag to either side. You should see the Milky Way scroll into view!\n",
"\n",
"**Unlike usual**, we won't separate the viewer into its own pane, because that currently breaks the functionality demonstrated here. If you get annoyed with scrolling back and forth, you can drag the above cell down as you work your way through the notebook."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Step 2: Inserting Some Data\n",
"\n",
"An interactive figure should presumably have some data in it to show off. Here, we'll just load up some of the data used in the other tutorials to show the general principles.\n",
"\n",
"We'll start by displaying a WISE 12µm image towards the [Westerhout 5 star forming region](https://en.wikipedia.org/wiki/Westerhout_5):\n",
"\n",
"<!-- TODO: get data table export working and add the GRB table! -->"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"w5_img = wwt.layers.add_image_layer(datapath('w5.fits'))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now is a good time to play around with the visualization parameters of the image, if you'd like. Executing the following line will create some UI elements that let you tune the colormap, stretch, and so on:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"w5_img.controls"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Likewise you can control the settings used for the all-sky contextual imagery:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.layer_controls"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Step 3: Exporting to standalone HTML\n",
"\n",
"pywwt, like all Jupyter widgets, is at its heart web-based. We've been working on building the technology to extract the visualizations that you create from Jupyter into standalone web assets that can be included anywhere that you can host HTML + JavaScript + CSS. This trio of technologies is exactly how [interactive figures](https://journals.aas.org/graphics-guide/#interactive_figures) in the AAS journals work!\n",
"\n",
"Once you've set up your viewer, exporting is easy:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.save_as_html_bundle('figure.zip')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"After a few seconds, you should see a file named `figure.zip` appear in the folder view sidebar to the left of this notebook. What's cool is that *even if you're running this notebook in the cloud*, you can right-click that file and select \"Download\" to save the Zip bundle to your local machine.\n",
"\n",
"If you were to open up this Zip file and inspect its contents, you'd see that it contains an `index.html` file, some JavaScript, and a `data` directory containing a FITS file correspond to the image that you just loaded into your view."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Example 1: Submitting the figure to a journal\n",
"\n",
"Its a bit beyond the scope of this notebook to describe the full submission process here. But the key thing is that the `figure.zip` file has virtually everything you need to include an interacting figure in an [AAS journal](journals.aas.org/). See [this blog post by Peter Williams](https://newton.cx/~peter/2019/creating-aas-interactive-figures/) for a detailed guide involving similar files created with the [AAS Timeseries Tool](https://aas-timeseries.readthedocs.io/)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Example 2: Including the figure on a personal website\n",
"\n",
"The same files that you submit to a journal can also be included on your own website, if your authoring platform allows you to upload arbitrary files and use HTML [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe) tags. Heres a minimal sample HTML file, assuming that you have unpacked your Zip bundle into a directory named `my_figure`:\n",
"\n",
"```html\n",
"<!DOCTYPE html>\n",
"\n",
"<html lang=\"en\">\n",
" <head>\n",
" <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n",
" <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n",
" <style type=\"text/css\">\n",
" .intfig { width: 600px; height: 400px; }\n",
" </style>\n",
" </head>\n",
" <body>\n",
" <h1>Welcome to My Personal Webpage</h1>\n",
" <p>Explore the data from my latest paper!</p>\n",
" <iframe class=\"intfig\" src=\"my_figure/index.html\">\n",
" <p>Unfortunately your browser doesnt support iframes.</p>\n",
" </iframe>\n",
" </body>\n",
"</html>\n",
"```\n",
"\n",
"Most of this is just boilerplate — the key is the `<iframe>` line and the CSS styling that sets it to the correct size."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Example 3: Playing with a figure on your own computer\n",
"\n",
"If you have [Node.js](https://nodejs.org/en/) installed on your computer, you can view your exported interactive figure in a relatively straightforward way:\n",
"\n",
"1. Unpack the Zip file\n",
"2. In a terminal, `cd` to the unpacked directory (the one containing `index.html`).\n",
"3. Run: `npx http-server`\n",
"4. Open a browser to the URL printed by the program.\n",
"\n",
"**Note**: alas, we have a race condition bug that sometimes pops up here. You might need to reload the page for all of your data to appear.\n",
"\n",
"Other one-liner web servers might work, but not all of them serve files with the correct `Content-Type` headers, which is needed for everything to work here."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Next Steps\n",
"\n",
"To learn more about how to load image data into pywwt, check out the [Visualizing Imagery](./Visualizing%20Imagery.ipynb) tutorial."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Credits\n",
"\n",
"This notebook was prepared by:\n",
"\n",
"- O. Justin Otor\n",
"- Thomas Robitaille\n",
"- Peter K. G. Williams"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

378
First Steps.ipynb Normal file
Просмотреть файл

@ -0,0 +1,378 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# First Steps With pywwt\n",
"\n",
"This notebook walks you through how to open a [pywwt] viewer \"widget\" in your Jupyter notebook or JupyterLab environment, and the basic ways that you can control the viewer. [pywwt] visualizes astronomical data and imagery in context using the [AAS] [WorldWide Telescope] rendering engine.\n",
"\n",
"[pywwt]: https://pywwt.readthedocs.io/\n",
"[AAS]: https://aas.org/\n",
"[WorldWide Telescope]: http://worldwidetelescope.org/"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Creating the Widget\n",
"\n",
"If you want to use `pywwt` in a notebook, the first step is always to import the [WWTJupyterWidget] class:\n",
"\n",
"[WWTJupyterWidget]: https://pywwt.readthedocs.io/en/stable/api/pywwt.jupyter.WWTJupyterWidget.html"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pywwt.jupyter import WWTJupyterWidget"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you're running this notebook in the cloud, this command should *definitely* work — which, in this case, means that it will run without printing any error messages or warnings. If you get an `ImportError` error, your notebook session isn't able to load the `pywwt` Python module for some reason. The most straightforward reason might be that you haven't installed it — if that's the case, visit [the pywwt installation instructions](https://pywwt.readthedocs.io/en/stable/installation.html).\n",
"\n",
"Next we create an instance of the widget and assign it to a variable, conventionally named `wwt`. Youll use this variable to control the viewer programmatically:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt = WWTJupyterWidget()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"(If the first command succeeded, this one *really* ought to work. If an error occurs, [file an issue on the pywwt GitHub repository](https://github.com/WorldWideTelescope/pywwt/issues/new) and someone will help you.)\n",
"\n",
"To actually create a WWT viewer, just “run” a notebook cell containing the widget variable and nothing else:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A window should appear that looks like a big black box. It might look like something isn't working, but if you click-and-drag inside the window, you should eventually see the galaxy swing into view. WWT is running inside your browser!\n",
"\n",
"If instead you just see a line of text that looks something like:\n",
"```\n",
"WWTJupyterWidget()\n",
"```\n",
"that means that the `pywwt` widget framework is not properly set up within your Jupyter environment — at the moment, additional setup needs to occur beyond simply installing the `pywwt` module. See [the pywwt installation instructions](https://pywwt.readthedocs.io/en/stable/installation.html) for guidance about how to set up the integration.\n",
"\n",
"## Side-By-Side Code and Viz\n",
"\n",
"*If you're using [JupyterLab](https://jupyterlab.readthedocs.io/)* and not just a plain Jupyter notebook, you can move the WWT view to a separate window pane. This is **extremely** useful since it lets you keep on typing code without scrolling WWT out of view. Here's how you do that:\n",
"\n",
"![Right click and select \"Create New View for Output\"](data/separate-pane-instructions.jpg)\n",
"\n",
"If you don't get a menu when you right-click, or the menu doesn't look like the one pictured, you are using a plain Jupyter notebook and will have to scroll back and forth.\n",
"\n",
"You can then click-and-drag the tab corresponding to the new pywwt viewer and stick it to any side of your browser window that you wish.\n",
"\n",
"Finally, if you click the blue bar next to the viewer back in this notebook, you will hide it, decluttering your code."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Navigating the pywwt Viewer\n",
"\n",
"Here are the ways you can navigate around inside the pywwt viewer:\n",
"\n",
"- To pan around, click-and-drag the mouse like you would in an app like Google Maps\n",
" - Or, you can pan around by pressing the keys `i`, `j`, `k`, and `l`\n",
"- To zoom in and out, you can use the scroll wheel on your mouse, if you have one\n",
" - Or you can use a two-finger scroll on a Mac mouse or touchpad\n",
" - Or you can press the keys `z` and `x` to zoom in and out, respectively\n",
" - Or in some cases the Page-Up and Page-Down keys should work\n",
"- In the standard sky exploration mode, you can *roll* the angle of the viewer by holding down the Control key and then click-and-dragging.\n",
"- In the planet viewer mode, the Control-click-drag action will change the angle of the camera relative to the planetary surface\n",
"\n",
"If you ever get your viewer into a funky state that you can't escape, try:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.reset_view()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Or close your widget window and create a new `wwt` variable."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Changing the Background Imagery\n",
"\n",
"By default, the pywwt viewer opens in a 2D \"sky mode\" showing a terapixel optical map of the entire sky, derived from the [Digitized Sky Survey](https://en.wikipedia.org/wiki/Digitized_Sky_Survey). Running the following cell will create some controls in your notebook that will let you choose a different all-sky map, or even blend between two maps:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.layer_controls"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Changing the Viewer Mode\n",
"\n",
"The pywwt viewer can do more than just 2D sky exploration, however. This command will change the view to the 3D “Solar System” mode, which is actually a misnomer since it allows 3D exploration of much more than just the Solar System:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.set_view('solar system')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Once you enter this mode, keep on zooming out as far as you can go. The view will seem to stall once the solar system shrinks into a dot, but if you keep on going, youll eventually see the local stars move in 3D, then an artists conception of the Milky Way, then relatively nearby galaxies from the SDSS catalog. (The last of these might take some time to appear since the viewer needs to first download all of the galaxy data, then create a fairly intensive 3D rendering data structure.)\n",
"\n",
"To get back to the 2D sky mode, use:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.set_view('sky')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can also view the major planets as 3D spheres:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.set_view('earth')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This mode allows you to overlay data on planetary surfaces and view topography with [DEM](https://en.wikipedia.org/wiki/Digital_elevation_model) maps. Check out Mars!"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.set_view('mars')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Controlling the View Position\n",
"\n",
"You can command the pywwt viewer to look at a specific location. To demonstrate this, let's switch back to Sky Mode:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.set_view('sky')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can set the location using [AstroPy SkyCoord](https://docs.astropy.org/en/stable/coordinates/index.html) objects, so all of the flexibility of those objects is available for free:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from astropy.coordinates import SkyCoord\n",
"\n",
"wwt.center_on_coordinates(SkyCoord.from_name('M31'))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Or:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from astropy import units as u\n",
"\n",
"wwt.center_on_coordinates(\n",
" SkyCoord(ra = 13.1284*u.deg, dec = 56.6241*u.deg), \n",
" fov = 3*u.deg, # specifies the zoom level by setting the viewer's angular height\n",
" instant = False, # pan smoothly instead of moving abruptly\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Controlling the Clock\n",
"\n",
"We say that the pywwt viewer is actually four-dimensional, not just three-dimensional, since it has an internal clock that is integrated into the simulation: planet positions are calculated to high accuracy and data rendering can take into account the current time.\n",
"\n",
"To demonstrate this, lets switch back to the Solar System Mode:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.set_view('solar system')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can set the time using [AstroPy Time](https://docs.astropy.org/en/stable/time/) objects:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from astropy.time import Time\n",
"\n",
"wwt.set_current_time(Time('1999-01-01'))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can change the rate at which the clock runs:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.play_time(rate=3000000) # advance the WWT clock at 3,000,000 times realtime"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And you can pause it altogether:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.pause_time()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Next Steps\n",
"\n",
"Now that youve been introduced to the basics of the pywwt viewer, how about going back to the [Start Here](./Start%20Here.ipynb) notebook and trying some of our more in-depth tutorials?"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

320
GRBs Over Time.ipynb Normal file
Просмотреть файл

@ -0,0 +1,320 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# The Time Axis: GRBs Over Time\n",
"\n",
"This notebook will demonstrate some of what you can do with WWTs clock using a dataset of [gamma-ray burst](https://en.wikipedia.org/wiki/Gamma-ray_burst) events."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Step 1: Starting up pywwt\n",
"\n",
"The first thing to do is to open up a pywwt window in this notebook session. As is generally the case, we have to start with some Python imports:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pywwt.jupyter import WWTJupyterWidget"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We'll also set up a utility function:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def datapath(*args):\n",
" from os.path import join\n",
" return join('data', *args)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, create a widget and display it inline. (That's why the final line is a bare `wwt`.)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt = WWTJupyterWidget()\n",
"wwt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If everything is working correctly, the above command should create a pywwt viewer that looks mostly like a black box. If youre using the JupyterLab environment rather than a plain Jupyter notebook, it is *strongly recommended* that you move the viewer to its own window pane so that you can have your code and viz side-by-side:\n",
"\n",
"![Right click and select \"Create New View for Output\"](data/separate-pane-instructions.jpg)\n",
"\n",
"If you don't get a menu or the menu doesnt look like the one pictured, you are probably not using JupyterLab and will have to move the viewer cell down as you work your way through the notebook. See the [First Steps](./First%20Steps.ipynb) notebook for more information and troubleshooting tips if you dont get a viewer at all."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Step 2: Loading tabular data with a time-series axis\n",
"\n",
"Now that the viewer is set up, we need some data. First, some imports:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from astropy.coordinates import SkyCoord\n",
"from astropy.table import Table\n",
"from astropy.time import Time, TimeDelta\n",
"from astropy import units as u\n",
"from datetime import datetime"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now, we'll load up a table of GRB data. We'll print out the first few rows to get a sense of the data structure. In this case it's pretty simple."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"bursts = Table.read(datapath('grb_table_lite.ecsv'), format='ascii.ecsv')\n",
"bursts[:5]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The WWT engine doesn't know enough to know that the Julian Date values above are actually dates (and not just some random floating-point measurements), so we convert them to the ISO8601 format:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"bursts['dates_ISOT'] = Time(bursts['dates_JD'], format='jd').isot\n",
"bursts[:5]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Step 3: Plotting Data in (2+1)D\n",
"\n",
"To start showing the data, we create a \"table layer\":"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"layer = wwt.layers.add_table_layer(\n",
" table = bursts, \n",
" frame = 'Sky', \n",
" lon_att = 'ra', # treat the column named \"ra\" as a longitude coordinate\n",
" lat_att = 'dec', # likewise for the column named \"dec\"\n",
" size_scale=200\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now let's tell the engine that we want to pay attention to the time axis of the table. **This will make all of the points disappear**, since the engine's clock is synchronized to your computer — it's plotting data for the current year, and our GRBs only go up to 2014."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"layer.time_series = True\n",
"layer.time_att = 'dates_ISOT'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can check the engine's clock using the `get_current_time()` method:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.get_current_time()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's demonstrate that things are actually working by centering on the first GRB in both space *and* time — setting the WWT clock to just before it goes off."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"first_grb = bursts[0]\n",
"start_pos = SkyCoord(first_grb['ra'], first_grb['dec'], unit=u.deg)\n",
"start_time = Time(first_grb['dates_ISOT'], format='isot') - TimeDelta(5 * u.second)\n",
"\n",
"wwt.center_on_coordinates(start_pos)\n",
"wwt.set_current_time(start_time)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You should see a white dot appear in the screen center after five seconds!\n",
"\n",
"The WWT timeseries support has the concept of a \"decay time\". Points that appear on the screen slowly fade over the decay timescale — according to the WWT simulation clock, that is, not wallclock time. The default is 16 days. That's a bit short for visualizing GRBs, so let's make it longer:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"layer.time_decay = 1 * u.yr"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now, let's speed time up to see the GRBs pop off over time. If you find the right patch of the sky (namely, the ecliptic), you might also see the Sun and planets moving around at enhanced speed."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.play_time(rate=3e6)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Once you've had your fill, the following function call will reset the clock to run at real time:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.play_time()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"How much time passed inside WWT?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.get_current_time() - start_time"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Credits\n",
"\n",
"This notebook was prepared by:\n",
"\n",
"- O. Justin Otor\n",
"- Peter K. G. Williams\n",
"\n",
"With thanks to Mark SubbaRao for creating the first version of this demonstration."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

Просмотреть файл

@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Visualizing the NASA exoplanet archive"
"# Visualizing the NASA Exoplanet Archive"
]
},
{
@ -18,7 +18,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Loading the tabular data\n",
"---\n",
"\n",
"## Step 1: Loading the tabular data\n",
"\n",
"We start off by loading the table using the [astropy.table](https://docs.astropy.org/en/stable/table/) module:"
]
@ -31,7 +33,8 @@
"source": [
"import os\n",
"from astropy.table import Table\n",
"exoplanets = Table.read(os.path.join('..', 'data', 'planets_2019.09.30_16.25.03.votable'))"
"\n",
"exoplanets = Table.read(os.path.join('data', 'planets_2019.09.30_16.25.03.votable'))"
]
},
{
@ -54,7 +57,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Setting up the WWT widget\n",
"---\n",
"\n",
"## Step 2: Setting up the WWT widget\n",
"\n",
"We now import the ``WWTJupyterWidget`` class:"
]
@ -72,7 +77,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"and we use this class to create the widget (note that the second ``wwt`` is needed to actually show the contents of the widget):"
"and we use this class to create the pywwt \"widget\". Crucially, the second line (containing just `wwt`) is needed to insert the widget into the notebook, and not just assign it to a variable."
]
},
{
@ -89,7 +94,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Adding a tabular data layer\n",
"*If you're using JupyterLab* and not just a plain Jupyter notebook, you can move the WWT view to a separate window pane. This is **extremely** useful since it lets you keep on typing code without scrolling WWT out of view. Here's how you do that:\n",
"\n",
"![Right click and select \"Create New View for Output\"](data/separate-pane-instructions.jpg)\n",
"\n",
"If you don't get a menu when you right-click, or the menu doesn't look like the one pictured, you are using a plain Jupyter notebook and will have to scroll back and forth.\n",
"\n",
"---\n",
"\n",
"## Step 3: Adding a tabular data layer\n",
"\n",
"We are now ready to add the data to WWT. We start off by calling ``add_table_layer`` to create the layer:"
]
@ -296,6 +309,19 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## What's Next\n",
"\n",
"To see how to plot a data table that contains a time axis, check out the [GRBs Over Time](./GRBs%20Over%20Time.ipynb) tutorial."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Credits\n",
"\n",
"This notebook was prepared by Thomas Robitaille."
@ -318,9 +344,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

Просмотреть файл

@ -11,9 +11,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook shows how to show data in the WorldWide Telescope Jupyter widget, specifically on the surface of a planet. You can find out more about using pywwt in the [documentation](http://pywwt.readthedocs.io).\n",
"This notebook shows how to plot tabular data on the surface of a planet using the AAS WorldWide Telescope through [pywwt](https://pywwt.readthedocs.io/). You can find out more about using pywwt in the [documentation](https://pywwt.readthedocs.io).\n",
"\n",
"We start off by importing the ``WWTJupyterWidget`` class:"
"Start off by importing the `WWTJupyterWidget` class:"
]
},
{
@ -29,15 +29,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We then use this class to create the widget (note that the second ``wwt`` is needed to actually show the contents of the widget):"
"We use this class to create the pywwt \"widget\". Crucially, the second line below (containing just `wwt`) is needed to insert the widget into the notebook, and not just assign it to a variable:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"wwt = WWTJupyterWidget()\n",
@ -48,7 +46,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Once the widget appears, you can then use the ``wwt`` object to change the current view to the Earth:"
"*If you're using JupyterLab* and not just a plain Jupyter notebook, you can move the WWT view to a separate window pane. This is **extremely** useful since it lets you keep on typing code without scrolling WWT out of view. Here's how you do that:\n",
"\n",
"![Right click and select \"Create New View for Output\"](data/separate-pane-instructions.jpg)\n",
"\n",
"If you don't get a menu when you right-click, or the menu doesn't look like the one pictured, you are using a plain Jupyter notebook and will have to scroll back and forth.\n",
"\n",
"Once the widget appears, you can then use the `wwt` object to change the current view to the Earth:"
]
},
{
@ -113,9 +117,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

Просмотреть файл

@ -2,19 +2,16 @@
This repository contains example notebooks for the
[pywwt](https://pywwt.readthedocs.org) package, which provides access to the
[AAS] [WorldWide Telescope] inside Python and Jupyter environments. Clicking
any of the following links will launch an example notebook in the cloud:
[AAS] [WorldWide Telescope] inside Python and Jupyter environments.
[AAS]: https://aas.org/
[WorldWide Telescope]: http://www.worldwidetelescope.org/
* [Add a simple overlaid annotation](http://binder.wwt-forum.org/v2/gh/WorldWideTelescope/pywwt-notebooks/master?urlpath=lab/tree/first-tutorials/basic.ipynb)
* [Visualizing the NASA exoplanet archive](http://binder.wwt-forum.org/v2/gh/WorldWideTelescope/pywwt-notebooks/master?urlpath=lab/tree/first-tutorials/NASA_Exoplanet_Archive.ipynb)
* [Explore which parts of the sky have been observed by the NASA K2 mission](http://binder.wwt-forum.org/v2/gh/WorldWideTelescope/pywwt-notebooks/master?urlpath=lab/tree/first-tutorials/kepler2_fovs.ipynb)
* [Plot earthquake data on the surface of the Earth](http://binder.wwt-forum.org/v2/gh/WorldWideTelescope/pywwt-notebooks/master?urlpath=lab/tree/first-tutorials/planet_layers.ipynb)
* [Animate the motions of the Solar System planets in 3D](http://binder.wwt-forum.org/v2/gh/WorldWideTelescope/pywwt-notebooks/master?urlpath=lab/tree/first-tutorials/solar_system_simulation.ipynb)
🚀🚀 [**Click here to run these examples in the cloud!**][launch] 🚀🚀
*Note: it is usually fast to launch these notebooks, but if updates were
[launch]: http://binder.wwt-forum.org/v2/gh/WorldWideTelescope/pywwt-notebooks/master?urlpath=lab/tree/Start%20Here.ipynb
*Note: it is usually fast to launch a notebook server, but if updates were
recently merged into this repository, you may have to wait a few minutes for
the backing software images to be rebuilt.*

Просмотреть файл

@ -0,0 +1,127 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# A Simple Solar System Simulation\n",
"\n",
"This notebook demonstrates some basic controls of the [pywwt] Jupyter widget in its 3D (really, 4D) Solar System mode.\n",
"\n",
"[pywwt]: https://pywwt.readthedocs.io/\n",
"\n",
"First, we import the necessary modules:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pywwt.jupyter import WWTJupyterWidget\n",
"from astropy.coordinates import SkyCoord\n",
"from astropy import units as u\n",
"from astropy.time import Time"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, we create the interactive pywwt \"widget\" and show it in the notebook:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt = WWTJupyterWidget()\n",
"wwt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Turn on the 3D Solar System mode and adjust a few view parameters, including significantly exaggerating the size of the planets to make them more visible:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.set_view('Solar System')\n",
"wwt.solar_system.scale = 99 # scale up the planet size very unrealistically!\n",
"wwt.solar_system.track_object('sun')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Choose a nice angle that will show several planets:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.center_on_coordinates(SkyCoord(339.32980758, 20.78999814, unit=u.deg), fov=.6*u.deg)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally, set the time of WWT's internal clock and adjust its rate to make the planets move at a nice pace:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.set_current_time(Time('2019-07-01'))\n",
"wwt.play_time(rate=300000) # 300,000 times faster than real time"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Credits\n",
"\n",
"This notebook was prepared by O. Justin Otor with contributions from Thomas Robitaille and Peter K. G. Williams."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

122
Start Here.ipynb Normal file
Просмотреть файл

@ -0,0 +1,122 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![AAS WorldWide Telescope logo](data/wwt-logo_stacked_406x158_black-on-transparent.png)\n",
"\n",
"# Example notebooks for pywwt\n",
"\n",
"Welcome! Here youll find notebooks for the [pywwt] package, which provides access to the [AAS] [WorldWide Telescope] inside Python and Jupyter environments.\n",
"\n",
"[pywwt]: https://pywwt.readthedocs.org/ \n",
"[AAS]: https://aas.org/\n",
"[WorldWide Telescope]: http://www.worldwidetelescope.org/\n",
"\n",
"### Feature Tutorials\n",
"\n",
"These notebooks tour some of the features of [pywwt]:\n",
"\n",
"* [**First Steps**][first-steps] — getting acquainted with the basics of the pywwt viewer\n",
"* [**Visualizing Data Tables: the NASA Exoplanet Archive**][nasa-exo] — plotting data in 2D and 3D\n",
"* [**Visualizing Imagery: W5 and SN2011fe**][imagery] — visualizing FITS data\n",
"* [**The Time Axis: Gamma-Ray Bursts**][grbs] — adding a time axis to your data tables\n",
"* [**Creating Interactive Figures**][int-figs] — export your visualizations to be viewable anywhere!\n",
"* [**Visualizing Planetary Data: Earthquakes**][earthquakes] — plotting data on a planetary surface\n",
"* [**Animating the Motions of the Solar System Planets in 3D**][sol-sys-sim] — a quick demonstration of the WWT clock\n",
"\n",
"[first-steps]: ./First%20Steps.ipynb\n",
"[nasa-exo]: ./NASA%20Exoplanet%20Archive.ipynb\n",
"[imagery]: ./Visualizing%20Imagery.ipynb\n",
"[grbs]: ./GRBs%20Over%20Time.ipynb\n",
"[int-figs]: ./Creating%20Interactive%20Figures.ipynb\n",
"[earthquakes]: ./Planet%20Layers.ipynb\n",
"[sol-sys-sim]: ./Solar%20System%20Simulation.ipynb\n",
"\n",
"### Video Tutorials\n",
"\n",
"A selection of our notebooks come with YouTube videos showing how they were created!\n",
"\n",
"- **Timeseries Data Tables**: [video](https://youtu.be/cL9Hd7cKnNU), [notebook](./Videos/2019.10%20-%20Timeseries%20Tables%20in%20pywwt.ipynb) (Oct 2019)\n",
"- **Opening FITS Images**: [video](https://www.youtube.com/watch?v=ZxKvIAAjCeU), [notebook](./Videos/2019.09%20-%20Opening%20FITS%20images%20with%20pywwt.ipynb) (Sep 2019)\n",
"\n",
"*Please note that, since producing each video takes a lot of work, these materials are not frequently updated, so you may run into issues with older ones.*\n",
"\n",
"### Workshop Tutorials\n",
"\n",
"These notebooks were created for WWT instructional workshops presented at various conferences:\n",
"\n",
"- [**AAS 235**](./Workshops/2020.01%20-%20AAS235.ipynb) (Jan 2020; Honolulu, HI, USA)\n",
"- [**Petabytes to Science 3**](./Workshops/2019.11%20-%20Petabytes%20to%20Science%203.ipynb) (Nov 2019; Cambridge, MA, USA)\n",
"- [**ADASS 29**](./Workshops/2019.10%20-%20ADASS29.ipynb) (Oct 2019; Groningen, NL)\n",
"- [**AAS 234**](./Workshops/2019.06%20-%20AAS234.ipynb) (Jun 2019; St. Louis, MO, USA)\n",
"- [**AAS 233**](./Workshops/2019.01%20-%20AAS233.ipynb) (Jan 2019; Seattle, WA, USA)\n",
"- [**AAS 231**](./Workshops/2018.01%20-%20AAS231.ipynb) (Jan 2018; Washington, DC, USA)\n",
"\n",
"*Please note that these notebooks are being preserved for posterity but are not updated as pywwt evolves, so you may run into issues with older ones.*\n",
"\n",
"---\n",
"\n",
"## Credits\n",
"\n",
"Authorship information for each notebook is included in a statement at the end of each. If you [contribute][github] improvements to an existing notebook, you are strongly encouraged to add your name!\n",
"\n",
"---\n",
"\n",
"## Taking the Next Step\n",
"\n",
"Want to get more involved in the AAS WorldWide Telescope community? Here are some next steps you can take:\n",
"\n",
"- Want to stay up to date? Sign up for our newsletter: <https://bit.ly/wwt-signup>\n",
"- ... or follow us on social media:\n",
" - [@wwtelescope](https://twitter.com/wwtelescope) on Twitter\n",
" - [AASWorldWideTelescope](http://www.youtube.com/c/AASWorldWideTelescope) on YouTube\n",
" - [@wwtelescope](http://www.youtube.com/c/AASWorldWideTelescope) on Facebook\n",
"- Have questions or want to share ideas? Join our discussion forum: <https://wwt-forum.org/>\n",
"- Want to explore WWT technology in depth? Visit the WWT Contributor Hub: <https://worldwidetelescope.github.io/>\n",
"- To contribute to this notebook collection, visit the [WorldWideTelescope/pywwt-notebooks][github] repository on GitHub.\n",
"\n",
"[github]: https://github.com/WorldWideTelescope/pywwt-notebooks/\n",
"\n",
"---\n",
"\n",
"## Acknowledgments\n",
"\n",
"The AAS WorldWide Telescope system is a [.NET Foundation] project managed by\n",
"the non-profit [American Astronomical Society] (AAS). Work on WWT has been\n",
"supported by the AAS, the US [National Science Foundation] (grants [1550701]\n",
"and [1642446]), the [Gordon and Betty Moore Foundation], and [Microsoft].\n",
"\n",
"[.NET Foundation]: https://dotnetfoundation.org/\n",
"[American Astronomical Society]: https://aas.org/\n",
"[National Science Foundation]: https://www.nsf.gov/\n",
"[1550701]: https://www.nsf.gov/awardsearch/showAward?AWD_ID=1550701\n",
"[1642446]: https://www.nsf.gov/awardsearch/showAward?AWD_ID=1642446\n",
"[Gordon and Betty Moore Foundation]: https://www.moore.org/\n",
"[Microsoft]: https://www.microsoft.com/\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

Просмотреть файл

@ -11,7 +11,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Loading and manipulating FITS files with `pywwt`."
"# Loading and manipulating FITS files with `pywwt`"
]
},
{
@ -42,7 +42,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"_We download a FITS image of a galaxy in the infrared using `astroquery`._"
"We download a FITS image of a galaxy in the infrared using `astroquery`."
]
},
{
@ -87,9 +87,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"*If you're using JupyterLab, right-click to the side of the viewer after it loads and select \"Create New View for Output.\"*\n",
"<br>\n",
"*Then, examine the area around the image by clicking and dragging the viewer or by pressing 'I', 'J', 'K', and 'L' as directional keys. Pinch in/out or press 'Z'/'X' to zoom.*"
"If you're using JupyterLab, right-click to the side of the viewer after it loads and select \"Create New View for Output.\":\n",
"\n",
"![](../data/separate-pane-instructions.jpg)\n",
"\n",
"Examine the area around the image by clicking and dragging the viewer or by pressing 'I', 'J', 'K', and 'L' as directional keys. Pinch in/out or press 'Z'/'X' to zoom."
]
},
{
@ -115,7 +117,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"*It's also possible to upload a local FITS image by providing the relative path to the file as the argument for* `add_image_layer()` -- *see the additional content at the end of the notebook for an example.*"
"It's also possible to upload a local FITS image by providing the relative path to the file as the argument for `add_image_layer()` — see the additional content at the end of the notebook for an example."
]
},
{
@ -124,7 +126,7 @@
"source": [
"## Manipulate the image in `pywwt`.\n",
"\n",
"_We test different values for each of the image layer's attributes. We end by choosing background layers that help visualize the galaxy in three wavelengths at once._"
"We test different values for each of the image layer's attributes. We end by choosing background layers that help visualize the galaxy in three wavelengths at once."
]
},
{
@ -258,7 +260,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"_This file was also created with `astroquery` through the following code:_\n",
"This file was also created with `astroquery` with the following code:\n",
"\n",
"```\n",
"img_list2 = SkyView.get_images(position='SN 2011FE', survey='SwiftXRTCnt', pixels=140)`\n",
"img_list2[0].writeto('data/m101_swift')\n",
@ -285,9 +288,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If you're on our [BinderHub website](http://binder.wwt-forum.org/v2/gh/WorldWideTelescope/pywwt-notebooks/master?urlpath=lab/) or have pulled our [`pywwt-notebooks` GitHub repository](https://github.com/WorldWideTelescope/pywwt-notebooks/) to your local machine, [try this notebook](../aas-tutorials/aas234_tutorial.ipynb) on using `astropy` `Tables` to create data layers in `pywwt` next.\n",
"\n",
"Otherwise, you can find out more about adding layers [in our documentation](https://pywwt.readthedocs.io/en/stable/layers.html) and contact us with any comments or questions at the [WorldWide Telescope Forum](https://wwt-forum.org/) or by opening an issue or pull request at [`pywwt`'s main GitHub repository](https://github.com/WorldWideTelescope/pywwt). Thank you for trying out this example notebook on working with FITS images in `pywwt`."
"You can find out more about adding layers [in our documentation](https://pywwt.readthedocs.io/en/stable/layers.html) and contact us with any comments or questions at the [WorldWide Telescope Forum](https://wwt-forum.org/) or by opening an issue or pull request at [`pywwt`'s main GitHub repository](https://github.com/WorldWideTelescope/pywwt). Thank you for trying out this example notebook on working with FITS images in `pywwt`."
]
},
{
@ -316,7 +317,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.6"
}
},
"nbformat": 4,

Просмотреть файл

@ -11,7 +11,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Visualizing time series data with `pywwt`."
"# Visualizing Time Series Data with `pywwt`"
]
},
{
@ -48,9 +48,15 @@
"metadata": {},
"outputs": [],
"source": [
"bursts = Table.read('../data/grb_table_lite.ecsv',\n",
" format='ascii.ecsv')\n",
"bursts"
"bursts = Table.read('../data/grb_table_lite.ecsv', format='ascii.ecsv')\n",
"bursts # print out out to get a sense of what the data are like"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Adjust the date formatting to match what WWT accepts:"
]
},
{
@ -81,6 +87,17 @@
"wwt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*If you're using JupyterLab* and not just a plain Jupyter notebook, you can move the WWT view to a separate window pane. This is **extremely** useful since it lets you keep on typing code without scrolling WWT out of view. Here's how you do that:\n",
"\n",
"![Right click and select \"Create New View for Output\"](data/separate-pane-instructions.jpg)\n",
"\n",
"If you don't get a menu when you right-click, or the menu doesn't look like the one pictured, you are using a plain Jupyter notebook and will have to scroll back and forth."
]
},
{
"cell_type": "code",
"execution_count": null,
@ -170,9 +187,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If you're on our [BinderHub website](http://binder.wwt-forum.org/v2/gh/WorldWideTelescope/pywwt-notebooks/master?urlpath=lab/) or have pulled our [`pywwt-notebooks` GitHub repository](https://github.com/WorldWideTelescope/pywwt-notebooks/) to your local machine, try the example in [this notebook](../aas-tutorials/aas233_tutorial.ipynb) on plotting K2's footprint and yield in `pywwt` next. (The notebook you just read is an updated version of the second example in that file.)\n",
"\n",
"Otherwise, you can find out more about adding layers [in our documentation](https://pywwt.readthedocs.io/en/stable/layers.html) and contact us with any comments or questions at the [WorldWide Telescope Forum](https://wwt-forum.org/) or by opening an issue or pull request at [`pywwt`'s main GitHub repository](https://github.com/WorldWideTelescope/pywwt). Thank you for trying out this example notebook on visualizing time series data in `pywwt`."
"You can find out more about adding layers [in our documentation](https://pywwt.readthedocs.io/en/stable/layers.html) and contact us with any comments or questions at the [WorldWide Telescope Forum](https://wwt-forum.org/) or by opening an issue or pull request at [`pywwt`'s main GitHub repository](https://github.com/WorldWideTelescope/pywwt). Thank you for trying out this example notebook on visualizing time series data in `pywwt`."
]
},
{
@ -201,7 +216,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.6"
}
},
"nbformat": 4,

357
Visualizing Imagery.ipynb Normal file
Просмотреть файл

@ -0,0 +1,357 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Visualizing Image Data\n",
"\n",
"This notebook will demonstrate how to load and visualize astronomical images in the pywwt viewer."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Step 1: Starting up pywwt\n",
"\n",
"The first thing to do is to open up a pywwt window in this notebook session. As is generally the case, we have to start with some Python imports:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pywwt.jupyter import WWTJupyterWidget"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We'll also set up a utility function to help us load data files stored alongside this notebook:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def datapath(*args):\n",
" from os.path import join\n",
" return join('data', *args)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, create a widget and display it inline. (That's why the final line is a bare `wwt`.)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt = WWTJupyterWidget()\n",
"wwt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If everything is working correctly, the above command should create a pywwt viewer that looks mostly like a black box. If youre using the JupyterLab environment rather than a plain Jupyter notebook, it is *strongly recommended* that you move the viewer to its own window pane so that you can have your code and viz side-by-side:\n",
"\n",
"![Right click and select \"Create New View for Output\"](data/separate-pane-instructions.jpg)\n",
"\n",
"If you don't get a menu or the menu doesnt look like the one pictured, you are probably not using JupyterLab and will have to move the viewer cell down as you work your way through the notebook. See the [First Steps](./First%20Steps.ipynb) notebook for more information and troubleshooting tips if you dont get a viewer at all."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Step 2: Visualizing a Local FITS file\n",
"\n",
"We'll start by visualizing a WISE 12µm image towards the [Westerhout 5 star forming region](https://en.wikipedia.org/wiki/Westerhout_5) and taking a look at some of the advanced visualization options.\n",
"\n",
"Images, like data tables, are represented in WWT as \"layers\" that can be added to the view. With a standard FITS file, all you need to do is provide a pathname:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"layer = wwt.layers.add_image_layer(datapath('w5.fits'))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The viewer will automatically center and zoom to the image you've loaded. You may get a warning from the `reproject` module; this can safely be ignored.\n",
"\n",
"\"Printing\" the following variable will create a set of widgets that let you adjust how the data are visualized:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"layer.controls"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The image color scaling is controlled by the sliders in the \"Fine min/max\" row; the \"Coarse min/max\" boxes control the bounds that are placed on the range of those sliders.\n",
"\n",
"You should try sliding the image opacity back and forth to check the agreement between the morphology of the W5 image and the WWT all-sky map.\n",
"\n",
"All of the parameters that are controlled by the widgets above can be manipulated programmatically as well. Let's set a bunch of them at once:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"layer.cmap = 'plasma'\n",
"layer.vmin = 400\n",
"layer.vmax = 1000\n",
"layer.stretch = 'sqrt'\n",
"layer.opacity = 0.9"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that the settings in the widgets adjusted automatically to match what you entered. Fancy!\n",
"\n",
"After you're done playing around, let's reset the WWT widget:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.reset()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Step 3: Loading data from remote sources\n",
"\n",
"Because pywwt is a Python module, not a standalone application, it gains a lot of power by being able to integrate with other components of the modern, Web-oriented astronomical software ecosystem.\n",
"\n",
"For instance, it is easy to use the Python module [astroquery](https://astroquery.readthedocs.io/en/latest/) to load in data directly from archive queries, without the requirement to save any files locally. Let's fetch 2MASS Ks-band images of the field of supernova 2011fe. This might take a little while since the Python kernel needs to download the data from MAST."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from astroquery.skyview import SkyView\n",
"\n",
"img_list = SkyView.get_images(\n",
" position='SN 2011FE', \n",
" survey='2MASS-K', \n",
" pixels=500 # you can adjust the size if you want\n",
")\n",
"assert len(img_list) == 1 # there's only one matching item in this example\n",
"twomass_img = img_list[0]\n",
"twomass_img.info()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"Once the FITS data are available, we can display them in pywwt using the same command as before:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"twomass_layer = wwt.layers.add_image_layer(twomass_img)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Once again you should see the view automatically center on your image. Let's adjust the background imagery to be more relevant:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.background = wwt.imagery.ir.twomass\n",
"wwt.foreground_opacity = 0"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"pywwt provides interactive controls to let you adjust the parameters of the contextual imagery that's being shown. Try choosing different sets of all-sky imagery and adjusting the blend between them:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.layer_controls"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here are some settings that we like:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.background = wwt.imagery.visible.sdss\n",
"wwt.foreground = wwt.imagery.gamma.fermi\n",
"wwt.foreground_opacity = .5"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we'll load up another image of the same field that came from *Swift*, this time stored as a local file as in the previous step:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"swift_layer = wwt.layers.add_image_layer(datapath('m101_swiftx.fits'))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create controls to adjust all of the visualization parameters. If you want to go wild, you can overlay data from four different wavelengths in this one view!"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.layer_controls"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"twomass_layer.controls"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"swift_layer.controls"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Next Steps\n",
"\n",
"To learn how to display data tables along with your imagery, start with the [NASA Exoplanet Archive](./NASA%20Exoplanet%20Archive.ipynb) tutorial"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Credits\n",
"\n",
"This notebook was prepared by:\n",
"\n",
"- O. Justin Otor\n",
"- Thomas Robitaille\n",
"- Peter K. G. Williams"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

Просмотреть файл

@ -1,5 +1,14 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# AAS231 WWT Workshop Notebook (January 2018; Washington, DC)\n",
"\n",
"*Please note: these notebooks are preserved for posterity but not kept up-to-date, so you might run into issues with older notebooks.*"
]
},
{
"cell_type": "code",
"execution_count": null,
@ -17,9 +26,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"wwt"
@ -31,7 +38,6 @@
"metadata": {},
"outputs": [],
"source": [
"print(layers.keys())\n",
"print(type(sorted(wwt._available_layers)))"
]
},
@ -131,8 +137,8 @@
"metadata": {},
"outputs": [],
"source": [
"available_layers = {}\n",
"#available_layers['visible'] = {'twomass': {'full_name': '2mass survey', 'thumbnail': None},'iras': {'full_name': 'iras', 'thumbnail': None}}\n",
"#available_layers = {}\n",
"available_layers['visible'] = {'twomass': {'full_name': '2mass survey', 'thumbnail': None},'iras': {'full_name': 'iras', 'thumbnail': None}}\n",
" \n",
"class ImageryLayers:\n",
" def __init__(self, layers_dict):\n",
@ -456,9 +462,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

Просмотреть файл

@ -1,5 +1,14 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# AAS233 WWT Workshop Notebook (January 2019; Seattle, WA)\n",
"\n",
"*Please note: these notebooks are preserved for posterity but not kept up-to-date, so you might run into issues with older notebooks.*"
]
},
{
"cell_type": "markdown",
"metadata": {},
@ -72,8 +81,8 @@
"metadata": {},
"outputs": [],
"source": [
"xarch = NasaExoplanetArchive.get_confirmed_planets_table()\n",
"xarch.keep_columns(['pl_hostname', 'pl_letter', 'st_dist', 'ra', 'dec'])"
"# xarch = NasaExoplanetArchive.get_confirmed_planets_table()\n",
"# xarch.keep_columns(['pl_hostname', 'pl_letter', 'st_dist', 'ra', 'dec'])"
]
},
{
@ -82,8 +91,7 @@
"metadata": {},
"outputs": [],
"source": [
"#xarch = Table.read('https://raw.githubusercontent.com/WorldWideTelescope/pywwt-notebooks/master/aas-tutorials/data/k2_table.ecsv',\n",
"# format='ascii.ecsv')"
"xarch = Table.read('../data/k2_table.ecsv', format='ascii.ecsv')"
]
},
{
@ -279,15 +287,12 @@
"metadata": {},
"outputs": [],
"source": [
"bursts = Table.read('https://raw.githubusercontent.com/WorldWideTelescope/pywwt-notebooks/master/aas-tutorials/data/grb_table.ecsv',\n",
" format='ascii.ecsv')"
"bursts = Table.read('../data/grb_table.ecsv', format='ascii.ecsv')"
]
},
{
"cell_type": "markdown",
"metadata": {
"scrolled": false
},
"metadata": {},
"source": [
"*(Again, open a new cell above this one and see what the table looks like by entering `bursts` and running it.)*"
]
@ -527,9 +532,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

Просмотреть файл

@ -1,5 +1,14 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# AAS234 WWT Workshop Notebook (June 2019; St. Loui, MO)\n",
"\n",
"*Please note: these notebooks are preserved for posterity but not kept up-to-date, so you might run into issues with older notebooks.*"
]
},
{
"cell_type": "markdown",
"metadata": {},
@ -43,15 +52,6 @@
"from pywwt.jupyter import WWTJupyterWidget"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**If you're using Jupyter Lab, after running the next cell to create the `wwt` object, right-click the white area to the right of the viewer and select \"Create New View for Output.\"**\n",
"\n",
"This will create a new area with a viewer that you can view at all times, even as you can scroll through the rest of notebook. Try to avoid having both viewers on the screen at the same time to avoid glitchiness."
]
},
{
"cell_type": "code",
"execution_count": null,
@ -62,6 +62,17 @@
"wwt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*If you're using JupyterLab* and not just a plain Jupyter notebook, you can move the WWT view to a separate window pane. This is **extremely** useful since it lets you keep on typing code without scrolling WWT out of view. Here's how you do that:\n",
"\n",
"![Right click and select \"Create New View for Output\"](../data/separate-pane-instructions.jpg)\n",
"\n",
"If you don't get a menu when you right-click, or the menu doesn't look like the one pictured, you are using a plain Jupyter notebook and will have to scroll back and forth."
]
},
{
"cell_type": "markdown",
"metadata": {},
@ -86,8 +97,8 @@
"metadata": {},
"outputs": [],
"source": [
"xarch = NasaExoplanetArchive.get_confirmed_planets_table()\n",
"xarch.keep_columns(['pl_hostname', 'pl_letter', 'st_dist', 'ra', 'dec'])"
"#xarch = NasaExoplanetArchive.get_confirmed_planets_table()\n",
"#xarch.keep_columns(['pl_hostname', 'pl_letter', 'st_dist', 'ra', 'dec'])"
]
},
{
@ -96,9 +107,9 @@
"metadata": {},
"outputs": [],
"source": [
"#xarch = Table.read('https://raw.githubusercontent.com/WorldWideTelescope/'\n",
"# 'pywwt-notebooks/master/aas-tutorials/data/k2_table.ecsv',\n",
"# format='ascii.ecsv')"
"xarch = Table.read('https://raw.githubusercontent.com/WorldWideTelescope/'\n",
" 'pywwt-notebooks/master/aas-tutorials/data/k2_table.ecsv',\n",
" format='ascii.ecsv')"
]
},
{
@ -765,9 +776,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

Просмотреть файл

@ -6,6 +6,10 @@
"source": [
"# Welcome to the ADASS29 interactive visualization tutorial!\n",
"\n",
"## Oct 2019; Groningen, NL\n",
"\n",
"*Please note: these notebooks are preserved for posterity but not kept up-to-date, so you might run into issues with older notebooks.*\n",
"\n",
"Here are some helpful links:\n",
"\n",
"- [The tutorial landing page](https://wwt-forum.org/t/researcher-workshop-wwt-adass29-groningen-netherlands-2019-october-6/70)\n",
@ -23,7 +27,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -39,7 +43,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -57,29 +61,9 @@
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true,
"jupyter": {
"outputs_hidden": true
}
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"WWTJupyterWidget(layout=Layout(align_self='stretch', height='400px'))"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt = WWTJupyterWidget()\n",
"wwt"
@ -98,6 +82,8 @@
"3. Still in this notebook pane, left-click on the blue bar next to the WWT widget area. It should hide.\n",
"4. If you like, click-and-drag the notebook tab that says \"Output View\" to move it to a different area of the screen. I like it at the top.\n",
"\n",
"![Right click and select \"Create New View for Output\"](../data/separate-pane-instructions.jpg)\n",
"\n",
"Stop here so we can bring it back together and introduce the first activity.\n",
"\n",
"---"
@ -674,19 +660,9 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Filename: (No file associated with this HDUList)\n",
"No. Name Ver Type Cards Dimensions Format\n",
" 0 PRIMARY 1 PrimaryHDU 141 (500, 500) float32 \n"
]
}
],
"outputs": [],
"source": [
"from astroquery.skyview import SkyView\n",
"\n",
@ -705,18 +681,9 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/a/lib/python3.7/site-packages/reproject/interpolation/core_celestial.py:26: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n",
" if not np.issubdtype(array.dtype, np.float):\n"
]
}
],
"outputs": [],
"source": [
"twomass_layer = wwt.layers.add_image_layer(twomass_img)"
]
@ -835,24 +802,9 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "50a95d0baf1b4860b1c6f4f1984ad755",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"WWTJupyterWidget(layout=Layout(align_self='stretch', height='400px'))"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"wwt2 = WWTJupyterWidget()\n",
"wwt2"
@ -869,18 +821,9 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/a/lib/python3.7/site-packages/reproject/interpolation/core_celestial.py:26: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n",
" if not np.issubdtype(array.dtype, np.float):\n"
]
}
],
"outputs": [],
"source": [
"twomass_layer2 = wwt2.layers.add_image_layer(twomass_img)\n",
"swift_layer2 = wwt2.layers.add_image_layer(datapath('m101_swiftx.fits'), opacity=0.5, cmap='plasma')"
@ -897,7 +840,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -1017,7 +960,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.6"
}
},
"nbformat": 4,

Просмотреть файл

@ -6,6 +6,10 @@
"source": [
"# Welcome to the Petabytes-3 WWT vizualization tutorial!\n",
"\n",
"## Nov 2019; Cambridge, MA, USA\n",
"\n",
"*Please note: these notebooks are preserved for posterity but not kept up-to-date, so you might run into issues with older notebooks.*\n",
"\n",
"Here are some helpful links:\n",
"\n",
"- [The tutorial landing page](https://wwt-forum.org/t/researcher-workshop-wwt-petabytes-to-science-3-boston-usa-2019-nov-8/86/2)\n",
@ -78,6 +82,8 @@
"3. Still in this notebook pane, left-click on the blue bar next to the WWT widget area. It should hide.\n",
"4. If you like, click-and-drag the notebook tab that says \"Output View\" to move it to a different area of the screen. I like it at the top.\n",
"\n",
"![Right click and select \"Create New View for Output\"](../data/separate-pane-instructions.jpg)\n",
"\n",
"Stop here so we can bring it back together and introduce the first activity.\n",
"\n",
"---"
@ -954,7 +960,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.6"
}
},
"nbformat": 4,

Просмотреть файл

@ -6,6 +6,10 @@
"source": [
"# Welcome to the AAS235 pyWWT tutorial!\n",
"\n",
"## Jan 2020; Honolulu, HI, USA\n",
"\n",
"*Please note: these notebooks are preserved for posterity but not kept up-to-date, so you might run into issues with older notebooks.*\n",
"\n",
"Here are some helpful links:\n",
"\n",
"- [The tutorial landing page](https://wwt-forum.org/t/researcher-workshop-wwt-aas235-honolulu-usa-2020-january-5/71)\n",
@ -44,8 +48,8 @@
"outputs": [],
"source": [
"def datapath(*args):\n",
" from os.path import join\n",
" return join('..', 'data', *args)"
" from os.path import join, pardir\n",
" return join(pardir, 'data', *args)"
]
},
{
@ -78,6 +82,8 @@
"3. Still in this notebook pane, left-click on the blue bar next to the WWT widget area. It should hide.\n",
"4. If you like, click-and-drag the notebook tab that says \"Output View\" to move it to a different area of the screen. I like it at the top.\n",
"\n",
"![Right click and select \"Create New View for Output\"](../data/separate-pane-instructions.jpg)\n",
"\n",
"Stop here so we can bring it back together and introduce the first activity.\n",
"\n",
"---"
@ -858,7 +864,7 @@
"\n",
"**Note**: alas, we *also* have a race condition bug that sometimes pops up here. You might need to reload the page for the images to appear.\n",
"\n",
"Other one-liner web servers might work, but not all of them serve file with the correct `Content-Type` headers, which is needed for everything to work here.\n",
"Other one-liner web servers might work, but not all of them serve files with the correct `Content-Type` headers, which is needed for everything to work here.\n",
"\n",
"---"
]

Просмотреть файл

Просмотреть файл

Просмотреть файл

0
data/grb_table_lite.ecsv Executable file → Normal file
Просмотреть файл

Просмотреть файл

Двоичные данные
data/separate-pane-instructions.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 69 KiB

Просмотреть файл

Двоичные данные
data/wwt-logo_stacked_406x158_black-on-transparent.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 35 KiB

Просмотреть файл

@ -1,137 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Visualizing FITS images on the sky\n",
"\n",
"In this notebook, we will visualize a WISE 12µm image towards the [Westerhout 5 star forming region](https://en.wikipedia.org/wiki/Westerhout_5), and we will take a look at some of the advanced visualization options.\n",
"\n",
"### Setting up the WWT widget\n",
"\n",
"We first import the ``WWTJupyterWidget`` class:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pywwt.jupyter import WWTJupyterWidget"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"and we use this class to create the widget (note that the second ``wwt`` is needed to actually show the contents of the widget):"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt = WWTJupyterWidget()\n",
"wwt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Adding an image data layer\n",
"\n",
"We are now ready to add the image data to WWT. We start off by calling ``add_image_layer`` to create the layer, and specify the name of the file:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"layer = wwt.layers.add_image_layer(os.path.join('..', 'data', 'w5.fits'))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"WWT will automatically pan to the image. We can now show some controls to help us fine tune the appearance of the image:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"layer.controls"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here you can change the colormap, stretch, opacity (which you can use to compare the image to the background, or to another image). You can then also set the min/max of the stretch, and use the slider at the bottom to fine tune these values.\n",
"\n",
"If you prefer, you can also change these parameters programmatically:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"layer.cmap = 'plasma'\n",
"layer.vmin = 400\n",
"layer.vmax = 2000\n",
"layer.stretch = 'sqrt'\n",
"layer.opacity = 0.9"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that when you make the change programmatically, the control widgets update to mirror what you did. Fancy!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Credits\n",
"\n",
"This notebook was prepared by Thomas Robitaille."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

Просмотреть файл

@ -1,97 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Using WorldWide Telescope inside the Jupyter notebook"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook shows how to start up the WorldWide Telescope Jupyter widget, and how to subsequently modify its properties. You can find out more about using pywwt in the [documentation](http://pywwt.readthedocs.io).\n",
"\n",
"We start off by importing the ``WWTJupyterWidget`` class:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pywwt.jupyter import WWTJupyterWidget"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We then use this class to create the widget (note that the second ``wwt`` is needed to actually show the contents of the widget):"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"wwt = WWTJupyterWidget()\n",
"wwt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Once the widget appears, you can then use the ``wwt`` object to change the visual settings, interact with WorldWide Telescope, and create annotations:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from astropy import units as u\n",
"from astropy.coordinates import SkyCoord\n",
"M31 = SkyCoord('00h42m44.330s +41d16m07.50s')\n",
"wwt.center_on_coordinates(M31, fov=10 * u.deg)\n",
"wwt.add_circle(M31, radius=1 * u.deg)\n",
"wwt.constellation_figures = True"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can find out more about interacting with the ``wwt`` object in [Basic controls](http://pywwt.readthedocs.io/en/latest/settings.html) and [Showing annotations](http://pywwt.readthedocs.io/en/latest/annotations.html)."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

Просмотреть файл

@ -1,114 +0,0 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pywwt.jupyter import WWTJupyterWidget\n",
"from astropy.coordinates import SkyCoord, concatenate \n",
"from astropy import units as u\n",
"import requests\n",
"wwt = WWTJupyterWidget()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"wwt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"k2_json = requests.get('https://github.com/KeplerGO/K2FootprintFiles/raw/master/json/k2-footprint.json')\n",
"k2_dict = k2_json.json()\n",
"channels = k2_dict['c12']['channels']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#wwt.clear_annotations()\n",
"\n",
"for index in channels:\n",
" ras = channels[str(index)]['corners_ra']\n",
" decs = channels[str(index)]['corners_dec']\n",
" corners = SkyCoord(ras, decs, unit=u.deg,)\n",
" wwt.add_polygon(corners, line_width=1.5*u.pixel, fill=True,\n",
" fill_color='silver', opacity=.1)\n",
" \n",
"wwt.center_on_coordinates(corners[0], fov = 30 * u.deg)\n",
"wwt.crosshairs = False"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.background = 'Digitized Sky Survey (Color)'\n",
"#wwt.background = 'Tycho (Synthetic, Optical)' # for zoom\n",
"wwt.foreground = 'Planck Dust & Gas'\n",
"wwt.foreground_opacity = .5"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"k2_138 = SkyCoord('23:15:47.77','-10:50:58.91',unit=(u.hourangle,u.deg))\n",
"print(corners[0], k2_138)\n",
"#wwt.center_on_coordinates(k2_138, fov=60*u.deg, instant=False)\n",
"wwt.center_on_coordinates(k2_138, fov=1*u.deg, instant=False)\n",
"wwt.add_circle(k2_138, fill=False, radius = 10*u.arcsec)\n",
"#wwt.render('k2_138.png')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Credits\n",
"\n",
"This notebook was prepared by O. Justin Otor with contributions from Thomas Robitaille."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

Просмотреть файл

@ -1,95 +0,0 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pywwt.jupyter import WWTJupyterWidget\n",
"from astropy.coordinates import SkyCoord, concatenate\n",
"from astropy import units as u\n",
"from astropy.time import Time\n",
"import time\n",
"wwt = WWTJupyterWidget()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.set_view('Solar System')\n",
"wwt.solar_system.scale = 99\n",
"wwt.solar_system.track_object('sun')\n",
"wwt.solar_system.orbits = False"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt.center_on_coordinates(SkyCoord(339.32980758, 20.78999814, unit=u.deg), fov=.6*u.deg)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# show three earth months of the SS in 2019\n",
"tm = Time('2019-07-01')\n",
"tm.format = 'jd'\n",
"start = tm.value\n",
"\n",
"while(tm.value - start <= 92):\n",
" wwt.set_current_time(tm)\n",
" time.sleep(.1)\n",
" tm = Time(tm.value + .5, format='jd')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Credits\n",
"\n",
"This notebook was prepared by O. Justin Otor with contributions from Thomas Robitaille."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

Просмотреть файл

@ -1,91 +0,0 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from astropy import units as u\n",
"from astropy.coordinates import SkyCoord\n",
"from astropy.table import Table"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pywwt.qt import WWTQtClient"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data = Table.read('data/spitzer.tbl', format='ascii.ipac')\n",
"\n",
"modes = sorted(set(data['Instrument/Mode']))\n",
"\n",
"colors = ['blue', 'purple', 'pink', 'red', 'green']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wwt = WWTQtClient(block_until_ready=True)\n",
"wwt.foreground_opacity = 1.0\n",
"wwt.center_on_coordinates(SkyCoord.from_name('M31'), fov=5 * u.deg)\n",
"\n",
"for row in data[::5]:\n",
" coords = SkyCoord([row['ra1'], row['ra2'], row['ra3'], row['ra4']],\n",
" [row['dec1'], row['dec2'], row['dec3'], row['dec4']], unit='deg')\n",
" poly = wwt.add_polygon(coords)\n",
" poly.line_color = colors[modes.index(row['Instrument/Mode'])]\n",
" poly.fill_color = colors[modes.index(row['Instrument/Mode'])]\n",
" poly.fill = True\n",
" poly.opacity = 0.1\n",
" poly.hover_label = True\n",
" poly.label = 'AOR {}'.format(row['AORKEY'])\n",
"\n",
"wwt.wait()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Credits\n",
"\n",
"This notebook was prepared by O. Justin Otor with contributions from Thomas Robitaille."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}