Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python script for controlling ASCOM CCD camera?

Tags:

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?

like image 744
nerdfever.com Avatar asked Sep 11 '17 19:09

nerdfever.com


1 Answers

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
like image 101
saranova Avatar answered Sep 30 '22 14:09

saranova