-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobs-list.py
executable file
·41 lines (32 loc) · 976 Bytes
/
obs-list.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
#!/usr/bin/env python3
import datetime
import sys
import astropy.units as u
from astroquery.jplhorizons import Horizons
from astropy.time import Time
# Input from command-line
obj = sys.argv[1]
lon = float(sys.argv[2])
lat = float(sys.argv[3])
elev = float(sys.argv[4])
# Observer's location
observer_loc = {
'lon': lon * u.deg,
'lat': lat * u.deg,
'elevation': elev * u.km
}
# Setup the time range and epochs
start = datetime.datetime.now()
step_delta = datetime.timedelta(seconds=60)
num_steps = 10
epochs = [Time(start + i * step_delta).jd for i in range(num_steps)]
# Use Horizons to query the object at the specified epochs
obj = Horizons(id=obj, location=observer_loc, epochs=epochs)
# Query for RA/Dec values
ephs = obj.ephemerides()
# Print RA/Dec for each epoch
for epoch_data in ephs:
ra = epoch_data['RA']
dec = epoch_data['DEC']
time_str = epoch_data['datetime_str']
print(f"Epoch: {time_str} RA: {ra:.6f}° Dec: {dec:.6f}°")