Note
This page was generated from examples/notebooks/temporal.ipynb.
Temporal#
[2]:
import starepandas
import pystare
import pandas
import astropy.time
import datetime
[11]:
dates = ['2021-09-03', '2021-07-17 11:16']
dates = pandas.to_datetime(dates, format='ISO8601')
df = starepandas.STAREDataFrame({'dates': dates})
df
[11]:
| dates | |
|---|---|
| 0 | 2021-09-03 00:00:00 |
| 1 | 2021-07-17 11:16:00 |
[12]:
series = df['dates']
[13]:
times = astropy.time.Time(series,
scale='utc',
format='datetime64')
times.jd1
[13]:
array([2459460., 2459413.])
[14]:
tivs = starepandas.tivs_from_timeseries(df['dates'])
[15]:
# Pystare
[16]:
times = ['2021-09-03', '2021-07-17 11:16']
times = astropy.time.Time(series, scale='utc', format='datetime64')
tivs = pystare.from_julian_date(times.jd1, times.jd2, scale='utc', forward_res=48, reverse_res=48)
tivs
[16]:
array([2276059438861267137, 2275939265676325057])
[17]:
mss = pystare.to_ms_since_epoch_utc(tivs)
dts = [datetime.datetime.utcfromtimestamp(ms/1000) for ms in mss]
[dt.isoformat() for dt in dts]
[17]:
['2021-09-03T00:00:00', '2021-07-17T11:16:00']
[18]:
jd = pystare.to_julian_date(tivs, scale='utc')
times = astropy.time.Time(val=jd[0], val2=jd[1], format='jd')
times.to_datetime()
[18]:
array([datetime.datetime(2021, 9, 3, 0, 0),
datetime.datetime(2021, 7, 17, 11, 16)], dtype=object)
[ ]: