Skip to content

Commit 3d6b456

Browse files
Merge pull request #54 from CTetford/develop
AutoPA Updates
2 parents c1cc85b + 1098ac8 commit 3d6b456

File tree

2 files changed

+61
-3
lines changed

2 files changed

+61
-3
lines changed

Software/Addons/AutoPA/polaralign.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,14 @@ def polarcalc(mylat, mylong, myelev, time, p1RA, p1DEC, p2RA, p2DEC, p3RA, p3DEC
8989
p3RA = sys.argv[9]
9090
p3DEC = sys.argv[10]
9191

92-
serialport = '/dev/ttyACM0'
92+
#Serial port address for Arduino, typically /dev/ttyACM0 in Astroberry, possibly /dev/ttyACM1
93+
serialport = sys.argv[11]
9394

9495
result = polarcalc(mylat, mylong, myelev, time, p1RA, p1DEC, p2RA, p2DEC, p3RA, p3DEC)
9596

96-
#Verify error correction can be handled by AutoPA hardware (assuming it is in home/centered position)
97+
#Verify error correction values can be handled by AutoPA hardware (assuming it is in home/centered position)
9798
moveAz = "N"
98-
if abs(result[0]) > 192:
99+
if abs(result[0]) > 120:
99100
moveAz = input("Azimuth error may be out of bounds of hardware capabilities if not in home position. Continue? (Y/N): ")
100101
else:
101102
moveAz = "Y"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env python3
2+
import math
3+
from astropy.coordinates import SkyCoord, EarthLocation, AltAz, Angle
4+
from astropy import units as u
5+
from astropy.time import Time
6+
from astropy.utils import iers
7+
import sys, subprocess
8+
9+
def polarcalibrate(mylat, mylong, myelev):
10+
#iers.conf.auto_download = False
11+
#iers.conf.auto_max_age = None
12+
13+
#Create location object based on lat/long/elev
14+
observing_location = EarthLocation(lat=mylat*u.deg, lon=mylong*u.deg, height=177*u.m)
15+
16+
p1RA = input("Enter first RA value in 00h00m00.0s format: ")
17+
p1DEC = input("Enter first DEC value in 00d00m00.0s format: ")
18+
p1Time = Time(input("Enter first Time value in YYYY-MM-DD HH:MM:SS format: "))
19+
p2RA = input("Enter second RA value in 00h00m00.0s format: ")
20+
p2DEC = input("Enter second DEC value in 00d00m00.0s format: ")
21+
p2Time = Time(input("Enter second Time value in YYYY-MM-DD HH:MM:SS format: "))
22+
23+
p1 = SkyCoord(p1RA, p1DEC)
24+
p2 = SkyCoord(p2RA, p2DEC)
25+
26+
p1AzAlt = p1.transform_to(AltAz(obstime=p1Time,location=observing_location))
27+
p2AzAlt = p2.transform_to(AltAz(obstime=p2Time,location=observing_location))
28+
print(f"First capture Az./Alt.: {p1AzAlt.az.to_string(u.hour, precision=2)}/{p1AzAlt.alt.to_string(u.deg, precision=2)}.")
29+
print(f"Second capture Az./Alt.: {p2AzAlt.az.to_string(u.hour, precision=2)}/{p2AzAlt.alt.to_string(u.deg, precision=2)}.")
30+
31+
if p1AzAlt.az.deg > 180:
32+
p1Az = (360-p1AzAlt.az.deg)*60
33+
else:
34+
p1Az = p1AzAlt.az.deg*60
35+
if p2AzAlt.az.deg > 180:
36+
p2Az = (360-p2AzAlt.az.deg)*60
37+
else:
38+
p2Az = p2AzAlt.az.deg*60
39+
40+
deltaAz = abs(p1Az - p2Az)
41+
deltaAlt = abs(p1AzAlt.alt.arcmin - p2AzAlt.alt.arcmin)
42+
43+
print(f"Azimuth delta is: {deltaAz:.4f} arcminutes.")
44+
print(f"Altitude delta is: {deltaAlt:.4f} arcminutes.")
45+
46+
return
47+
48+
#Latitude in degrees
49+
mylat = float(sys.argv[1])
50+
51+
#Longitude in degrees
52+
mylong = float(sys.argv[2])
53+
54+
#Elevation in meters
55+
myelev = sys.argv[3]
56+
57+
polarcalibrate(mylat, mylong, myelev)

0 commit comments

Comments
 (0)