/
time.py
51 lines (39 loc) · 1.59 KB
/
time.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Adds the BKJD and BTJD time format for use by Astropy's `Time` object."""
from astropy.time.formats import TimeNumeric, day_frac
class TimeBKJD(TimeNumeric):
"""
Barycentric Kepler Julian Date time format.
This represents the number of days since January 1, 2009 12:00:00 UTC.
BKJD is the format in which times are recorded in Kepler data products.
See Section 2.3.2 in the Kepler Archive Manual for details.
"""
name = "bkjd"
BKJDREF = 2454833 # Barycentric Kepler Julian Date offset
def set_jds(self, val1, val2):
self._check_scale(self._scale) # Validate scale.
jd1, jd2 = day_frac(val1, val2)
jd1 += self.BKJDREF
self.jd1, self.jd2 = day_frac(jd1, jd2)
def to_value(self, **kwargs):
jd1 = self.jd1 - self.BKJDREF
jd2 = self.jd2
return super().to_value(jd1=jd1, jd2=jd2, **kwargs)
value = property(to_value)
class TimeBTJD(TimeNumeric):
"""
Barycentric TESS Julian Date time format.
This represents the number of days since JD 2457000.0.
BTJD is the format in which times are recorded in TESS data products.
"""
name = "btjd"
BTJDREF = 2457000 # Barycentric TESS Julian Date offset
def set_jds(self, val1, val2):
self._check_scale(self._scale) # Validate scale.
jd1, jd2 = day_frac(val1, val2)
jd1 += self.BTJDREF
self.jd1, self.jd2 = day_frac(jd1, jd2)
def to_value(self, **kwargs):
jd1 = self.jd1 - self.BTJDREF
jd2 = self.jd2
return super().to_value(jd1=jd1, jd2=jd2, **kwargs)
value = property(to_value)