-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdt.py
More file actions
31 lines (24 loc) · 672 Bytes
/
dt.py
File metadata and controls
31 lines (24 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from astropy.time import Time
def deltat(time_strings):
"""
Get dt
Parameters
----------
time_strings : array of strings
iso format strings of utc or local times in timetable
Returns
-------
dt : '~astropy.units.quantity.Quantity'
differential tot_time length
"""
return (Time(time_strings[1]) - Time(time_strings[0])).to('hour').round(2)
def test_deltat():
import astropy.units as u
times = Time(['2018-01-01 12:00:00', '2018-01-01 12:30:00'])
dt = deltat(times)
print('dt =', dt)
assert dt == 0.5 * u.h
print('Test successful!')
return
if __name__=='__main__':
test_deltat()