Getting Started

To get started, make sure you have a time series that you want to make an interactive figure of, and read it in using the astropy.timeseries package. Here we will adopt the same example as in the astropy.timeseries documentation, and start by retrieving a Kepler lightcurve (which you can also download here):

[1]:
from astropy.utils.data import get_pkg_data_filename
filename = get_pkg_data_filename('timeseries/kplr010666592-2009131110544_slc.fits')

and reading it in:

[2]:
from astropy.timeseries import TimeSeries
ts = TimeSeries.read(filename, format='kepler.fits')

Let’s take a look at the five first lines to see what the data looks like:

[3]:
ts[:5]
[3]:
TimeSeries length=5
timetimecorrcadencenosap_fluxsap_flux_errsap_bkgsap_bkg_errpdcsap_fluxpdcsap_flux_errsap_qualitypsf_centr1psf_centr1_errpsf_centr2psf_centr2_errmom_centr1mom_centr1_errmom_centr2mom_centr2_errpos_corr1pos_corr2
delectron / selectron / selectron / selectron / selectron / selectron / spixpixpixpixpixpixpixpixpixpix
objectfloat32int32float32float32float32float32float32float32int32float64float32float64float32float64float32float64float32float32float32
2009-05-02T00:41:40.3386.630610e-0455001.0270451e+061.4041933e+023.7480554e+032.2283568e+001.0346376e+062.4780812e+020nannannannan1041.560401.3623475e-04613.479971.7336856e-041.5822421e-03-1.4463664e-03
2009-05-02T00:42:39.1886.630857e-0455011.0271844e+061.4042902e+023.7491572e+032.2283657e+001.0347789e+062.4594159e+020nannannannan1041.558341.3624557e-04613.481641.7334183e-041.5743829e-03-1.4540013e-03
2009-05-02T00:43:38.0456.631103e-0455021.0270762e+061.4038968e+023.7502588e+032.2283745e+001.0346701e+062.4408449e+020nannannannan1041.557511.3616899e-04613.478661.7328140e-041.5665225e-03-1.4616371e-03
2009-05-02T00:44:36.8946.631350e-0455031.0271414e+061.4042482e+023.7513606e+032.2283831e+001.0347365e+062.4229922e+020nannannannan1041.558981.3622017e-04613.479471.7331526e-041.5586632e-03-1.4692718e-03
2009-05-02T00:45:35.7526.631597e-0455041.0271569e+061.4039404e+023.7524626e+032.2283916e+001.0347527e+062.4051416e+020nannannannan1041.557051.3621294e-04613.480851.7329821e-041.5508028e-03-1.4769078e-03

We now take a look at how to make an interactive figure of this lightcurve. To initialize a figure, use the InteractiveTimeSeriesFigure class:

[4]:
from aas_timeseries import InteractiveTimeSeriesFigure
fig = InteractiveTimeSeriesFigure()

We can now add markers using:

[5]:
markers = fig.add_markers(time_series=ts, column='sap_flux', label='SAP Flux')

The first argument is the whole time series object, while the second is the name of the column to use for the specific markers, while the latter is used in the legend of the plot. Let’s customize the axis labels:

[6]:
fig.xlabel = 'Time (UTC)'
fig.ylabel = 'Flux (electron/s)'

At this point, you could also add other time series, model overlays, define different views, and so on - we will look at these shortly, but for now let’s assume we want to save the interactive figure. At this point, if you are using the Jupyter Notebook or Jupyter Lab, you can see a preview of your interactive figure by doing:

[7]:
fig.preview_interactive()

To learn more about the different kinds of layers that can be added to interactive plots, see Adding and modifying layers