Visualizing Time Series Data: Fermi Gamma Ray Bursts in WWT

Python Setup
In [1]:
from astropy.table import Table,Column
from astropy.time import Time
from astropy import units
from astropy.coordinates import SkyCoord
from astroquery.vizier import Vizier
from astropy import units as u
In [2]:
#Create Vizier object, turn off default row limit
v = Vizier()
v.ROW_LIMIT = -1
WWT Setup
In [17]:
from pywwt.mods import *
In [19]:
#Connect to WWT
wwt = WWTClient(host="127.0.0.1") #Can pass a IP address here if WWT is running on a remote machine

Gamma Ray Bursts

For out data catalog we'll choose The second Fermi/GBM GRB catalog (4yr) (von Kienlin+, 2014) Vizier catalog: J/ApJS/211/13/GBM Which contains Fermi events from July 2007 to July 2012

In [3]:
Cats = v.get_catalogs('J/ApJS/211/13/GBM')
grbCat=Cats[0]
grbCat.keep_columns(["GRB","RAJ2000","DEJ2000","Time","ObsTime","Fl.w","Fl.n"])
grbCat.rename_column('RAJ2000', 'RA')
grbCat.rename_column('DEJ2000', 'dec')
C:\Anaconda\lib\site-packages\astroquery\vizier\core.py:556: UserWarning: VOTABLE parsing raised exception: 
  warnings.warn("VOTABLE parsing raised exception: {0}".format(ex))
In [4]:
#Set up matplotlib
%config InlineBackend.rc = {}
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn
In [6]:
#Plot the Catalog
coordsCol=SkyCoord(grbCat['RA'],grbCat['dec'],unit=(u.degree, u.degree), frame= 'icrs')
fig = plt.figure (figsize=(12,6))
ax = fig.add_subplot(111,projection="mollweide")
ax.grid(True)
ax.get_xaxis().tick_bottom()
ax.scatter(coordsCol.galactic.l.wrap_at(180.*units.degree).radian,\
           coordsCol.galactic.b.radian,s=6,lw=0,c='purple')
Out[6]:
<matplotlib.collections.PathCollection at 0x18847eb8>
In [23]:
coordsCol=SkyCoord(grbCat['RA'],grbCat['dec'],unit=(u.degree, u.degree), frame= 'icrs')
In [22]:
del coordsCol

Extracting the event time from this table is tricky. The time of day is in the ObsTime column, but the date is embedded in the GRB name. We'll extract the date from the GRB name and combine that with ObsTime to make a astropy time object.

In [21]:
timeList=[]
grbList=grbCat['GRB']
for i in range(len(grbList)):
    timeString= grbList[i][2:4]+'/'+grbList[i][4:6]+'/'+'20'+grbList[i][0:2]+' '+grbCat['ObsTime'][i]
    timeList.append(timeString)
Export Catalog to WWT

WWT contains its own time format, unfortunately one that astropy cannot write, so we'll have to create our own custom string.

In [22]:
grbList=grbCat['GRB']
timeList=[]
for i in range(len(grbList)):
    timeString= grbList[i][2:4]+'/'+grbList[i][4:6]+'/'+'20'+grbList[i][0:2]+' '+grbCat['ObsTime'][i]
    timeList.append(timeString)
grbCat.add_column(Column(timeList,name='TimeAndDate'))
grbCat
Out[22]:
GRBObsTimeRAdecTimeFl.wFl.nTimeAndDate
"h:m:s"degdegmsmJ / m2mJ / m2
080714B02:04:12.053441.98.55126.8e-073.5e-0707/14/2008 02:04:12.0534
080714C10:12:01.8376187.5-74.040961.8e-069.8e-0707/14/2008 10:12:01.8376
080714A17:52:54.0234188.1-60.210246.3e-063.3e-0607/14/2008 17:52:54.0234
080715A22:48:40.1634214.79.92565e-062.5e-0607/15/2008 22:48:40.1634
080717A13:02:35.2207147.3-70.040964.5e-062.4e-0607/17/2008 13:02:35.2207
080719A12:41:40.9578153.2-61.340967.7e-073.9e-0707/19/2008 12:41:40.9578
080720A07:35:35.547698.5-43.98192----07/20/2008 07:35:35.5476
080723B13:22:21.3751176.8-60.22567.2e-053.9e-0507/23/2008 13:22:21.3751
080723C21:55:23.0583113.3-19.7641.3e-077.5e-0807/23/2008 21:55:23.0583
080723D23:37:42.7083105.371.15123.1e-051.6e-0507/23/2008 23:37:42.7083
080724A09:37:40.6034358.332.92561.6e-058.7e-0607/24/2008 09:37:40.6034
........................
120701B15:41:48.3152182.7-45.71288.4e-084.9e-0807/01/2012 15:41:48.3152
120702A21:23:19.1712227.836.85121.6e-061e-0607/02/2012 21:23:19.1712
120703B10:01:11.688269.534.710241.1e-055.5e-0607/03/2012 10:01:11.6882
120703C11:56:56.8702210.546.310242.6e-061.5e-0607/03/2012 11:56:56.8702
120703A17:25:17.0323339.4-29.720488.3e-064.3e-0607/03/2012 17:25:17.0323
120707A19:12:17.4295291.1-34.440969.4e-055.2e-0507/07/2012 19:12:17.4295
120709A21:11:40.3666318.4-50.1641.4e-056.3e-0607/09/2012 21:11:40.3666
120710A02:23:17.0507120.4-31.12565.3e-062.7e-0607/10/2012 02:23:17.0507
120711A02:44:53.294394.7-71.02560.000196.6e-0507/11/2012 02:44:53.2943
120711C10:42:54.5709127.9-31.810241.9e-061e-0607/11/2012 10:42:54.5709
In [23]:
#Set up WWT layer
grb_layer = wwt.new_layer("Dynamic Universe", "Gamma Ray Bursts", grbCat.colnames)
#Set visualization parameters in WWT
props_dict = {"CoordinatesType":"Spherical",\
              "MarkerScale":"Screen",\
              "PointScaleType":"Constant",\
              "ScaleFactor":"64",\
              "ShowFarSide":"True",\
              "RaUnits":"Degrees",\
              "PlotType":"Gaussian",\
              "ColorValue":"ARGBColor:255:255:255:255",\
              "TimeSeries":"False"}
grb_layer.set_properties(props_dict)
#Send data to WWT client
grb_layer.update(data=grbCat, purge_all=True, no_purge=False, show=True)

Now inside WWT we can choose how we visualize the data, we can show all the data at once or playback the events as they happen watching the GRB’s go off like popcorn across the sky.