Absolute times, relative times, and phases

Types of time axes

So far, the examples we’ve looked at all involve time series with absolute time on the x axis. However, it is also possible to show relative times, or even phases. To take a look at this, we will use a dataset that consists of radial velocities as a function of time:

[1]:
from astropy.timeseries import TimeSeries
[2]:
ts = TimeSeries.read('https://aperiosoftware.github.io/timeseries.js/examples/data/phase.csv', format='ascii.csv')
[3]:
ts
[3]:
TimeSeries length=26
timerelativephasefluxerrorflux_loflux_hi
objectint64float64float64float64float64float64
2016-03-22T12:30:28.00000.00.980.150.971.0
2016-03-22T12:30:38.000100.11.020.151.01.03
2016-03-22T12:30:48.000200.21.010.151.01.02
2016-03-22T12:30:58.000300.30.870.150.850.89
2016-03-22T12:31:08.000400.40.750.150.720.76
2016-03-22T12:31:18.000500.50.70.150.690.71
2016-03-22T12:31:28.000600.60.710.150.70.72
2016-03-22T12:31:38.000700.70.820.150.8050.835
2016-03-22T12:31:48.000800.80.970.150.960.985
2016-03-22T12:31:58.000900.91.020.151.011.04
.....................
2016-03-22T12:33:08.0001600.60.690.150.650.75
2016-03-22T12:33:18.0001700.70.730.150.680.78
2016-03-22T12:33:28.0001800.80.860.150.80.91
2016-03-22T12:33:38.0001900.91.00.150.981.02
2016-03-22T12:33:48.0002001.00.990.150.971.02
2016-03-22T12:33:58.0002100.11.010.151.01.02
2016-03-22T12:34:00.0002120.121.0070.151.01.024
2016-03-22T12:34:05.0002170.171.0110.150.9951.025
2016-03-22T12:34:16.0002280.280.940.150.891.01
2016-03-22T12:34:20.0002320.320.840.150.780.9

This time series contains an absolute time column, but it also contains a relative time (since the start of the observations) and a pre-computed phase for a given period and epoch. You could also for example compute these on-the-fly and add them to an existing TimeSeries object.

Before we proceed, we need to update the TimeSeries object to include information about the units for the relative time column - we can do this using:

[4]:
from astropy import units as u
relative = ts['relative']
ts.remove_column('relative')
ts['relative'] = relative * u.s

We can now create a figure that shows relative time instead of absolute time by specifing time_mode when creating a figure:

[5]:
from aas_timeseries import InteractiveTimeSeriesFigure
fig = InteractiveTimeSeriesFigure(title='Radial Velocity Curve', time_mode='relative')
fig.add_markers(time_series=ts, time_column='relative', column='flux', color='orange', size=50)
fig.ylabel='Radial Velocity (km/s)'
fig.preview_interactive()

Similarly, we can create a figure showing the velocities as a function of phase using:

[6]:
fig = InteractiveTimeSeriesFigure(title='Radial Velocity Curve', time_mode='phase')
fig.add_markers(time_series=ts, time_column='phase', column='flux', color='orange', size=50)
fig.ylabel='Radial Velocity (km/s)'
fig.preview_interactive()

The time_mode can also be passed when creating views, so we can make a figure that shows absolute time by default, and have a view with the relative time and the phase axes:

[7]:
fig = InteractiveTimeSeriesFigure(title='Radial Velocity Curve', time_mode='absolute')
fig.ylabel='Radial Velocity (km/s)'

fig.add_markers(time_series=ts, time_column='time', column='flux', color='orange', size=50)

view1 = fig.add_view(title='By phase', empty=True, time_mode='phase')
view1.add_markers(time_series=ts, time_column='phase', column='flux', color='orange', size=50)

view2 = fig.add_view(title='By relative time', empty=True, time_mode='relative')
view2.add_markers(time_series=ts, time_column='relative', column='flux', color='orange', size=50)

fig.preview_interactive()

Formatting of time axes

For each of the different types of time axes, it is possible to customize the format of the axes, by using the time_format setting. For a figure/view with absolute time, time_format can be set to 'jd', 'mjd', 'unix', 'iso', or 'auto':

[8]:
fig = InteractiveTimeSeriesFigure(title='Radial Velocity Curve', time_mode='absolute')
fig.add_markers(time_series=ts, time_column='time', column='flux', color='orange', size=50)
fig.time_format = 'jd'
fig.preview_interactive()

For figures/views with relative times, the time_format can be set to 'seconds', 'hours', 'days', or 'years':

[9]:
fig = InteractiveTimeSeriesFigure(title='Radial Velocity Curve', time_mode='relative')
fig.add_markers(time_series=ts, time_column='relative', column='flux', color='orange', size=50)
fig.time_format = 'hours'
fig.preview_interactive()

And finally, for phases, this can be set to 'unity', 'radians', or 'degrees':

[10]:
fig = InteractiveTimeSeriesFigure(title='Radial Velocity Curve', time_mode='phase')
fig.add_markers(time_series=ts, time_column='phase', column='flux', color='orange', size=50)
fig.time_format = 'radians'
fig.preview_interactive()