Python Scripting in SharpCap for Jupiter, Saturn, and Mars

Mars captured using a Python script in SharpCap

Mars captured with Python in SharpCap

SharpCap allows users to add Python scripts to setup and control captures and perform other functions.  I recently wrote a Python script to capture Jupiter, Saturn, and Mars.  Specifically for Mars, it prompts the user to manually select an IR filter, captures nine sequences of 120 seconds each, prompts the user to manually select a L filter, and captures another three sequences of 120 second.  This script will be discussed in am upcoming video of my methods for capturing Jupiter, Saturn, and Mars using the ZWO ASI462MC.  Here is the script:

# SharpCap script to capture Jupiter, Saturn, and Mars with the ASI462
# Values tested with the ASI462MC, Astronomik IR807 and Optolong L-Pro filters

def captureASI462( planet_name, IR_seq, OSC_seq, seq_time ) :
import clr, time
from System import TimeSpan, Console

clr.AddReference("System.Windows.Forms")
import System.Windows.Forms as WinForms

clr.AddReference("SharpCap")
from SharpCap.UI import CaptureLimitType

# Make sure we have a camera
if not SharpCap.IsCameraSelected :
Console.Beep()
WinForms.MessageBox.Show( "Ensure the camera is connected and try again", "Error", WinForms.MessageBoxButtons(0) )
return

# Last minute check for the IR filter
Console.Beep()
if WinForms.MessageBox.Show("Ensure InfraRed filter is installed", "IR Capture", WinForms.MessageBoxButtons(1) ) != WinForms.DialogResult.OK :
return

# Retain Gain and Color Balance Settings
CameraGain = SharpCap.SelectedCamera.Controls.Gain.Value
WhiteBalB = SharpCap.SelectedCamera.Controls[16].Value
WhiteBalR = SharpCap.SelectedCamera.Controls[17].Value

# Set Color Balance to gray and set Target Name
SharpCap.SelectedCamera.Controls[16].Value = 50 # White Bal B: Set WB to gray for IR
SharpCap.SelectedCamera.Controls[17].Value = 50 # White Bal R: Set WB to gray for IR
SharpCap.TargetName = planet_name + "_IR"

for i in range( IR_seq ) : # Capture sequences of IR
SharpCap.SelectedCamera.CaptureConfig.CaptureLimitType = CaptureLimitType.TimeLimited
SharpCap.SelectedCamera.CaptureConfig.CaptureLimitTime = TimeSpan.FromSeconds( seq_time )

SharpCap.SelectedCamera.PrepareToCapture()
SharpCap.SelectedCamera.RunCapture()
while SharpCap.SelectedCamera.Capturing: # Wait for capture to complete
time.sleep( 0.1 )
time.sleep( 1 ) # Pause between captures

time.sleep( 1 ) # Pause between sequences

# Prompt user to change filter
Console.Beep()
if WinForms.MessageBox.Show("Ensure Luminence filter is installed", "OSC Capture", WinForms.MessageBoxButtons(1) ) != WinForms.DialogResult.OK :
return

# Set Color Balance for OSC, decrease gain by one stop, and change Target Name
SharpCap.SelectedCamera.Controls.Gain.Value = CameraGain - 60 # Adjust gain minus one stop (gain of 60 = 6dB)
SharpCap.SelectedCamera.Controls[16].Value = 64 # White Bal B: Set WB to color balance for OSC
SharpCap.SelectedCamera.Controls[17].Value = 64 # White Bal R: Set WB to color balance for OSC
SharpCap.TargetName = planet_name + "_OSC"

for i in range( OSC_seq ) : # Capure sequences of One Shot Color
SharpCap.SelectedCamera.CaptureConfig.CaptureLimitType = CaptureLimitType.TimeLimited
SharpCap.SelectedCamera.CaptureConfig.CaptureLimitTime = TimeSpan.FromSeconds( seq_time )

SharpCap.SelectedCamera.PrepareToCapture()
SharpCap.SelectedCamera.RunCapture()
while SharpCap.SelectedCamera.Capturing: # Wait for capture to complete
time.sleep( 0.1 )
time.sleep( 1 ) # Pause between captures

time.sleep( 1 ) # Pause between sequences

# Restore Gain and White Balance
SharpCap.SelectedCamera.Controls[16].Value = WhiteBalB
SharpCap.SelectedCamera.Controls[17].Value = WhiteBalR
SharpCap.SelectedCamera.Controls.Gain.Value = CameraGain

Console.Beep()
Console.Beep()

#captureASI462( "Jupiter", 9, 3, 30 )
#captureASI462( "Saturn", 9, 3, 90 )
#captureASI462( "Mars", 9, 3, 120 ) # Good seeing for Mars
#captureASI462( "Mars", 5, 1, 120 ) # Normal or bad seeing for Mars

To use this, Open SharpCap, select Show Console from the Scripting menu.  Now copy the Python script above, and paste it into the editing window.  Save it as JSM_462.py.  Now you can run it by selecting Run Script from the Scripting menu, and opening the JSM_462.py file.  With minor modifications, this script is used to capture Jupiter, Saturn, and Mars.  As I said, this will be further discussed in an upcoming video.  Stay tuned for more!

SHARE IT:

Comments are closed.