In my observatory I use:
* 3 different home positions according to the mounted OTA
* 2 different FLAT positions for natural and illuminated panel flats
I had the need of being able to tell my mount to GOTO all this diferrent AltAz coordinates, so I scripted it.
Any improvement appreciated
Code: Select all
import time
clr.AddReference("SharpCap.ImageProcessing")
clr.AddReference("SharpCap")
clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')
from SharpCap.ImageProcessing import SkyCoordConverter
from datetime import datetime
from System.Windows.Forms import *
from System.Drawing import Point, Color, Font, FontStyle, Size, Image, Icon
#TELESCOPE COORDINATES
latitude = 40.459583
longitude = -3.799660
class MoveToAltAz(Form):
def __init__(self):
self.Text = "NTO GotoAltAz"
self.TopMost = True
self.Width = 246
self.Height = 240
self.BackColor = Color.FromName("Black")
self.ForeColor = Color.FromName("Orange")
self.actualRaDec = Label()
self.actualRaDec.Text = "RA=00:00:00DEC=00:00:00N"
self.actualRaDec.Location = Point(10, 10)
self.actualRaDec.Font = Font(self.actualRaDec.Font, FontStyle.Bold)
self.actualRaDec.ForeColor = Color.FromName("Green")
self.actualRaDec.AutoSize = True
self.actualRaDec.DoubleClick += self.refrescar_posicion
self.actualAltAz = Label()
self.actualAltAz.Text = "Alt=00:00:00Az=00:00:00"
self.actualAltAz.Location = Point(10, 40)
self.actualAltAz.Font = Font(self.actualAltAz.Font, FontStyle.Bold)
self.actualAltAz.ForeColor = Color.FromName("Green")
self.actualAltAz.AutoSize = True
self.actualAltAz.DoubleClick += self.refrescar_posicion
self.labelTARGET = Label()
self.labelTARGET.Text = "Target"
self.labelTARGET.Location = Point(10, 70)
self.labelTARGET.AutoSize = True
self.TARGET = ComboBox()
self.TARGET.Items.Add("HOME CN")
self.TARGET.Items.Add("HOME C11")
self.TARGET.Items.Add("HOME REF")
self.TARGET.Items.Add("FLAT NAT")
self.TARGET.Items.Add("FLAT SCREEN")
self.TARGET.Location = Point(56, 70)
self.TARGET.Width = 164
self.TARGET.SelectedIndexChanged += self.cambiar_combo
self.labelALT = Label()
self.labelALT.Text = "Altitude"
self.labelALT.Location = Point(10, 100)
self.labelALT.AutoSize = True
self.ALT = TextBox()
self.ALT.Text = "0.0000"
self.ALT.Location = Point(56, 100)
self.ALT.Width = 54
self.labelAZM = Label()
self.labelAZM.Text = "Azimuth"
self.labelAZM.Location = Point(120, 100)
self.labelAZM.AutoSize = True
self.AZM = TextBox()
self.AZM.Text = "230.0000"
self.AZM.Location = Point(166, 100)
self.AZM.Width = 54
self.labellabelRA = Label()
self.labellabelRA.Text = "RA"
self.labellabelRA.Location = Point(10, 130)
self.labellabelRA.AutoSize = True
self.labelRA = Label()
self.labelRA.Text = "0.0000"
self.labelRA.Location = Point(56, 130)
self.labelRA.AutoSize = True
self.labellabelDEC = Label()
self.labellabelDEC.Text = "DEC"
self.labellabelDEC.Location = Point(120, 130)
self.labellabelDEC.AutoSize = True
self.labelDEC = Label()
self.labelDEC.Text = "0.0000"
self.labelDEC.Location = Point(166, 130)
self.labelDEC.AutoSize = True
self.CALC = Button()
self.CALC.Text = 'Calculate'
self.CALC.Width = 100
self.CALC.Height = 30
self.CALC.Location = Point(10, 160)
self.CALC.Font = Font(self.CALC.Font, FontStyle.Bold)
self.CALC.Click += self.calculate_RaDec
self.GOTO = Button()
self.GOTO.Text = 'GOTO'
self.GOTO.Width = 100
self.GOTO.Height = 30
self.GOTO.Location = Point(120, 160)
self.GOTO.Font = Font(self.GOTO.Font, FontStyle.Bold)
self.GOTO.Click += self.goto_RaDec
self.Controls.Add(self.actualRaDec)
self.Controls.Add(self.actualAltAz)
self.Controls.Add(self.labelTARGET)
self.Controls.Add(self.TARGET)
self.Controls.Add(self.labelALT)
self.Controls.Add(self.ALT)
self.Controls.Add(self.labelAZM)
self.Controls.Add(self.AZM)
self.Controls.Add(self.labellabelRA)
self.Controls.Add(self.labelRA)
self.Controls.Add(self.labellabelDEC)
self.Controls.Add(self.labelDEC)
self.Controls.Add(self.CALC)
self.Controls.Add(self.GOTO)
SharpCap.Mounts.SelectedMount.Connected = True
self.refrescar_posicion()
def OnFormClosing(self, e, *args):
e.Cancel = True
form.Hide()
def refrescar_posicion(self, *args):
ahora = datetime.now()
scc = SkyCoordConverter(latitude,longitude)
coordAltAz = scc.DoCoordTransform(0,0,0)
coordAltAz.Altitude = SharpCap.Mounts.SelectedMount.Altitude
coordAltAz.Azimuth = SharpCap.Mounts.SelectedMount.Azimuth
self.actualAltAz.Text = coordAltAz.ToString()
coordRaDec = scc.ConvertAltAzToRADec(coordAltAz,ahora)
self.actualRaDec.Text = coordRaDec.ToString()
def cambiar_combo(self, *args):
if self.TARGET.SelectedIndex is 0:
self.ALT.Text = "0.0000"
self.AZM.Text = "230.0000"
if self.TARGET.SelectedIndex is 1:
self.ALT.Text = "0.0000"
self.AZM.Text = "180.0000"
if self.TARGET.SelectedIndex is 2:
self.ALT.Text = "0.0000"
self.AZM.Text = "230.0000"
if self.TARGET.SelectedIndex is 3:
self.ALT.Text = "90.0000"
self.AZM.Text = "90.0000"
if self.TARGET.SelectedIndex is 4:
self.ALT.Text = "10.0000"
self.AZM.Text = "200.0000"
def calculate_RaDec(self, *args):
altitude = float(self.ALT.Text)
if altitude is None: return
azimuth = float(self.AZM.Text)
if azimuth is None: return
ahora = datetime.now()
scc = SkyCoordConverter(latitude,longitude)
coordAltAz = scc.DoCoordTransform(0,0,0)
coordAltAz.Altitude = altitude
coordAltAz.Azimuth = azimuth
coordRaDec = scc.ConvertAltAzToRADec(coordAltAz,ahora)
self.labelRA.Text = "{:.4f}".format(coordRaDec.RightAscension)
self.labelDEC.Text = "{:.4f}".format(coordRaDec.Declination)
def goto_RaDec(self, *args):
if self.GOTO.Text is 'STOP':
SharpCap.Mounts.SelectedMount.Stop()
else:
altitude = float(self.ALT.Text)
if altitude is None: return
azimuth = float(self.AZM.Text)
if azimuth is None: return
rightascension = float(self.labelRA.Text)
if rightascension is None: return
declination = float(self.labelDEC.Text)
if declination is None: return
self.actualRaDec.ForeColor = Color.FromName("Red")
self.actualAltAz.ForeColor = Color.FromName("Red")
self.GOTO.Text = 'STOP'
self.GOTO.ForeColor = Color.FromName("Red")
PAUSE = 1
SharpCap.Mounts.SelectedMount.SlewTo(rightascension, declination)
# while SharpCap.Mounts.SelectedMount.Altitude > (altitude + 2) or SharpCap.Mounts.SelectedMount.Altitude < (altitude - 2):
# while SharpCap.Mounts.SelectedMount.Azimuth > (azimuth + 2) or SharpCap.Mounts.SelectedMount.Azimuth < (azimuth - 2):
scc = SkyCoordConverter(latitude,longitude)
coordAltAz = scc.DoCoordTransform(0,0,0)
while SharpCap.Mounts.SelectedMount.Slewing:
ahora = datetime.now()
coordAltAz.Altitude = SharpCap.Mounts.SelectedMount.Altitude
coordAltAz.Azimuth = SharpCap.Mounts.SelectedMount.Azimuth
self.actualAltAz.Text = coordAltAz.ToString()
coordRaDec = scc.ConvertAltAzToRADec(coordAltAz,ahora)
self.actualRaDec.Text = coordRaDec.ToString()
Application.DoEvents()
time.sleep(PAUSE)
self.actualRaDec.ForeColor = Color.FromName("Green")
self.actualAltAz.ForeColor = Color.FromName("Green")
self.GOTO.Text = 'GOTO'
self.GOTO.ForeColor = Color.FromName("Orange")
self.refrescar_posicion()
form = MoveToAltAz()
form.Icon = Icon("C:\Program Files (x86)\SharpCap 3.2\Icons\AltAz_icon.ico")
def show_script():
form.Show()
SharpCap.AddCustomButton("GOTO AltAz", Image.FromFile("C:\Program Files (x86)\SharpCap 3.2\Icons\AltAz_icon.ico"), None, show_script)
http://nto.org.es/SHARED_GLOBAL/DialogAltAz.JPG