5

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?

nerdfever.com
  • 1,652
  • 1
  • 20
  • 41
  • Probably this link will help you https://www.lowmagnitude.com/2012/12/using-python-for-telescope-ccd-camera-automation-and-data-processing/ – Akash Sep 11 '17 at 19:22
  • http://www.rkblog.rk.edu.pl/w/p/ascom-end-user-application-developers/ or http://wt5l.blogspot.com.br/2011/05/automated-astrophotography-with-python.html – Dadep Sep 11 '17 at 19:24
  • Thanks, but I knew about those (Google is my friend, too). None of them show code for talking to a camera. – nerdfever.com Sep 11 '17 at 21:02
  • 2
    @nerdfever.com can you explain why those links do not contain complete information. What specifically do you mean by 'talking' to a camera. I would consider the examples there to meet that criteria. For example `tel = win32com.client.Dispatch("Celestron.Telescope");tel.SlewToCoordinates(12.34, 86.7)` certainly 'talks' to the camera... Unfortunately these kinds of things being poorly documented is quite common. Have you looked at the `PlatformDeveloperHelp.chm` file? – sytech Nov 14 '17 at 03:29
  • @sytech Cameras don't slew (platforms slew). Cameras expose for a period of time, then transfer captured image data. How does one discover the name of the camera? ("Celestron.Telescope" had to be discovered somehow.) For the bounty, I'd like to see 10 to 50 lines of Python that discover the camera(s), pick one and address/open it, set exposure time, take an image, and transfer the data to the PC (in any format). And advice re any necessary packages to be installed. – nerdfever.com Nov 14 '17 at 15:55
  • 2
    @nerdfever.com You'll probably be hard-pressed to find such a Python reference because it's a .NET program. I would recommend downloading the [.NET client toolkit](http://ascom-standards.org/Downloads/DevSamples.htm) and read the C# sample code which demonstrates such uses for the underlying namespaces. You'll have to adapt the .NET code for use with win32com from Python or use IronPython to use the .NET code directly such as shown in the previously linked examples. You may want to research the general topic of using win32com in this manner or using IronPython to interface with .NET code. – sytech Nov 14 '17 at 17:38
  • http://www.rkblog.rk.edu.pl/w/p/ascom-end-user-application-developers/ – Benjamin RD Nov 20 '17 at 17:42
  • Hope this is helpful: http://www.rkblog.rk.edu.pl/w/p/ascom-end-user-application-developers/ – EraserheadIRL Apr 11 '18 at 15:14

1 Answers1

4
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
saranova
  • 86
  • 4