.. _timeseries-times: Converting between different time representations ************************************************* .. |Time| replace:: :class:`~astropy.time.Time` .. |TimeDelta| replace:: :class:`~astropy.time.TimeDelta` .. |TimeSeries| replace:: :class:`~astropy_timeseries.TimeSeries` .. |BinnedTimeSeries| replace:: :class:`~astropy_timeseries.BinnedTimeSeries` In :ref:`timeseries-accessing-times`, we saw how to access the time columns/attributes of the |TimeSeries| and |BinnedTimeSeries| classes. Here we look in more detail at how to manipulate the resulting times. Converting times ================ Since the time column in time series is always a |Time| object, it is possible to use the usual attributes on |Time| to convert the time to different formats or scales. For example, to get the times as modified Julian Dates from a simple time series:: >>> from astropy import units as u >>> from astropy_timeseries import TimeSeries >>> ts = TimeSeries(time='2016-03-22T12:30:31', time_delta=3 * u.s, ... data={'flux': [1., 3., 4., 2., 4.]}) >>> ts.time.mjd # doctest: +FLOAT_CMP array([57469.52119213, 57469.52122685, 57469.52126157, 57469.5212963 , 57469.52133102]) or to convert the times to the Temps Atomique International (TAI) scale >>> ts.time.tai