Skip to content

Commit 299b582

Browse files
committed
#88: added jd2hjd script to compare VStar against an even more accurate implementation
1 parent 0accc00 commit 299b582

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

script/jd2hjd.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from astropy.time import Time
2+
from astropy.coordinates import SkyCoord, EarthLocation
3+
import astropy.units as u
4+
5+
import sys
6+
7+
8+
def jd2hjd(jd: float, ra: float, dec: float) -> float:
9+
# 1. Define input time, location (, and target
10+
jd_time = Time(jd, format='jd', scale='utc')
11+
# Klemzig (how much difference does location make for our purposes?)
12+
location = EarthLocation(lat=34.88*u.deg, lon=138.64*u.deg, height=60*u.m)
13+
target = SkyCoord(ra=ra*u.deg, dec=dec*u.deg)
14+
15+
# 2. Calculate light travel time to heliocenter (or barycenter)
16+
ltt_hjd = jd_time.light_travel_time(target, 'heliocentric', location=location)
17+
18+
# 3. Apply correction
19+
hjd_time = jd_time + ltt_hjd
20+
21+
return hjd_time
22+
23+
24+
if __name__ == "__main__":
25+
if len(sys.argv) == 4:
26+
jd = float(sys.argv[1])
27+
ra = float(sys.argv[2])
28+
dec = float(sys.argv[3])
29+
hjd = jd2hjd(jd, ra, dec)
30+
print(f"{jd} => {hjd}")

0 commit comments

Comments
 (0)