I want to control a CCD astronomical camera in Python using the ASCOM driver, but haven't found an example script to show how it's done.
I'd like to see how basic control of the camera is done - set exposure length, start exposure, download image data.
Can someone post an example Python script I can use as a starting point?
import win32com.client
from astropy.io import fits
# if you don't know what your driver is called, use the ASCOM Chooser
#x = win32com.client.Dispatch("ASCOM.Utilities.Chooser")
#x.DeviceType = 'Camera'
#driver = x.Choose(None)
# otherwise, just use it
driver = "ASCOM.AtikCameras.Camera"
camera = win32com.client.Dispatch(driver)
camera.connected = True
camera.CoolerOn = True
openshutter = True # False will take a dark frame
exptime = 1
camera.StartExposure(exptime,openshutter)
image = camera.ImageArray
hdu = fits.PrimaryHDU(image)
hdu.writeto('test.fits')
# see more camera methods/properties here:
# https://ascom-standards.org/Help/Developer/html/T_ASCOM_DriverAccess_Camera.htm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With