Visualizing Time Series Data with pywwt

Import dependencies.

In [ ]:
from astropy.coordinates import SkyCoord
from astropy.table import Table
from astropy.time import Time, TimeDelta
from astropy import units as u
from datetime import datetime
from pywwt.jupyter import WWTJupyterWidget

Retrieve a catalog of gamma ray bursts.

In [ ]:
bursts = Table.read('../data/grb_table_lite.ecsv', format='ascii.ecsv')
bursts  # print out out to get a sense of what the data are like

Adjust the date formatting to match what WWT accepts:

In [ ]:
bursts['dates_JD'] = Time(bursts['dates_JD'], format='jd').isot
bursts.rename_column('dates_JD', 'dates_ISO')
bursts

Upload the table to pywwt.

In [ ]:
wwt = WWTJupyterWidget()
wwt

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:

Right click and select "Create New View for Output"

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.

In [ ]:
lay = wwt.layers.add_table_layer(table=bursts, frame='Sky',
                                 lon_att='ra', lat_att='dec')
In [ ]:
lay.size_scale *= 20
In [ ]:
lay.time_series = True
lay.time_att = 'dates_ISO'
In [ ]:
lay.time_decay = 1 * u.yr
wwt.get_current_time()

Manipulate time and watch the gamma ray bursts appear.

In [ ]:
grb1 = bursts[0]
wwt.center_on_coordinates(SkyCoord(grb1['ra'], grb1['dec'],
                                   unit=u.deg))
In [ ]:
wwt.set_current_time( (Time(grb1['dates_ISO'], format='isot')
                       - TimeDelta(3 * u.second)))
In [ ]:
wwt.get_current_time()
In [ ]:
wwt.play_time(rate=3e6)

You can find out more about adding layers in our documentation and contact us with any comments or questions at the WorldWide Telescope Forum or by opening an issue or pull request at pywwt's main GitHub repository. Thank you for trying out this example notebook on visualizing time series data in pywwt.

Credits

This notebook was prepared by O. Justin Otor.