Using Python for Telescope/CCD Camera Automation and Data Processing

After having gone on my first real astronomy data run at the Pinto Valley Observatory, I saw quite a few things that could be done to improve the workflow for next time around. The two things that I am focusing on at the moment are:

  • Telescope and CCD camera integration for data acquisition
  • Data processing

The goal is to eventually be able to feed a list to a script, and go to sleep while it completes the data acquisition for the night.

Telescope and Camera Control

For the telescope and camera integration, I would like to write some code that can take a list of targets, integration times, and perhaps some other settings, and is able to figure out what order to aim at the targets and take data based on when it is closest to the zenith for the least amount of atmospheric noise. It was very cumbersome do take notes on the data set and target on one laptop, control the telescope from a second laptop, and take the data and control the camera from a third laptop. All of this could be simplified with some scripting that uses the provided lists of targets, moves the telescope (with ASCOM, INDI, SiTech, etc.), corrects for tracking errors and centers the target, and then starts the data acquisition and stores it away somewhere.

The main problem with all of this seems to be the complete lack of standardization in the telescope and camera world. Most every one operates with it’s own set of standards, which defeats the purpose. The camera we were using on PVO run was an Andor Luca-S which requires the proprietary SDK in order to control it. SBIG and a few others are able to be controlled using free and available libraries and software. On the telescope side, ASCOM was a well intentioned idea, but it’s limited to Windows based machines, which I do not have. I use Ubuntu linux, so I’m looking for alternatives that can work on any platform. INDI can do this, but it has limited device support. Fortunately, it works with the Celestron NexStar 6 that I have to play with.

So, in short, there seem to be three pieces to getting somewhere with this:

  • Figuring out how to handle the target list. Do I need to have a catalog, or am I going to rely on the user to provide RA/Dec for the targets?
  • Telescope control and tracking adjustment. Dan Gray wrote a simple spiral search script for the SiTech controller at PVO which worked well. It required manual intervention to hit “stop” once the target was in the FOV, but that could be automated easily if the camera is integrated by looking at the overall delta brightness of the images and once it changes by a certain threshold, you know that the target is in the FOV. Then you could center using this mechanism by moving in the x direction slowly until the delta changes, backup to get it in the FOV again, then move in the negative x direction until the delta drops again. Divide that by two and that target is centered for the x direction, then rinse and repeat to center in the y.
  • The camera automation seems easy enough with the Andor SDK, but, it’s proprietary which means that if I wanted to work with a different kind of camera, it would take more code. There probably isn’t a way around this other than writing functions to deal with detecting supported camera types and having code that can deal with it.

Data Processing

I’ve already started writing a bit of Python code for the data processing side of things. For the PVO run, we took data and recorded it in the proprietary Andor format called SIF. It is an undocumented format and there is nothing in the SDK for messing with these files, so you are stuck using their SOLIS software to convert it to different formats. I’m never taking data like that again. :) The Andor camera supports the FITS file format, which is used by NASA and lots of astronomy folks out there, and has quite a bit of support, including with the python module called PyFITS. I’ve been messing with that a bit today. Since all of our data from PVO is in SIF, we have to manually convert it to FITS using SOLIS before we can manipulate it by any other means. This is a tedious process which can be avoided in the future by recording data directly into the FITS format.

FITS files can be multidimentional “cubes” of data, so that our entire 2000 image set of a single target is in a single, convenient file. This is very easy to manipulate and run analysis on, and requires no extra conversion. This is what we will use for future runs.

Dr. Genet and I also use an wonderful piece of software called REDUC which is written by Florent Losse to compile our data and do various things like lucky imaging or speckle interferometry. The only issue is that REDUC only supports single dimensional FITS files, so we have to break up the FITS file from SOLIS into individual FITS files for a set of data. I’ve already been talking via email with Florent to get support in his software for data cubes, since this is widely used and accepted as a standard format for astronomical data. In the meantime, I’ve written a script that can slice up a multidimensional FITS into individual FITS files, and it also writes out a log file (in CVS format for Excel or LibreOffice, at the moment) with contains the header information for each data set, such as the exposure time, EM gain, number of photos, temperature of the camera, etc. If Florent can get the data cube support build in, I won’t need to slice up the FITS files anymore and no data conversions will need to take place which is ideal. I will still want to be able to write out a log file, since this comes in really handy once you’ve got a few nights worth of data.

The other piece which I just started playing with is actually analyzing the data. Python has some neat tools, such as the very powerful matplotlib, which might help in doing this and I’ve only begun to scratch the surface, doing some simple histograms, heat maps, and contours for some of the data that I have. This is a tantalizing possibility and I’m going to be very curious to see what I can come up with.

So there are plenty of pieces to these puzzles, and I’m going to attempt to figure something out. The data processing seems like the easiest part to tackle for the moment, and I will brainstorm on the other pieces as I go along. I’ll be sure to post something once I figure out anything substantial, since there seems to be bits and pieces all over the web, but no one with solid solutions. It looks like some of the big observatories have it figured out, but they have a lot of resources, and completely custom written software for their specific equipment. I would like to come up with something that helps out us amateurs so that we can make our own contributions to science without all of the headache.



Roweville or Bust!

I’m headed out to the Mojave Desert with Dr. Russ Genet to use the 20-inch PlaneWave CDK telescope at Pinto Valley Observatory at Roweville, owned and run by David Rowe, and I believe Dan Gray (from Sidereal Technology) is also joining us. We have a list of many different targets for gathering data, with our primary goal being speckle interferometry. We are also going to attempt to record data from a lunar occultation of a double star. I can’t wait to leave, this will be an exciting trip! Hopefully the weather cooperates…

Happy Birthday, Carl Sagan!

Carl Sagan (1934 – 1996)

Today is the 78th trip around the sun since Carl Sagan was brought into this world. He inspired  everyone to think deeply about our cosmic ocean and the vast universe of hidden treasures that await us. He devoted his life to the pursuit of knowledge and critical thought, letting the facts lead the way, and was still able to explain it with a sense of calm thoughtfulness that made everyone stop and realize the inherent beauty of nature, science, and human thought.

Even today, Carl’s scientific efforts are bearing fruit. Just within the last couple of months, the Voyager 1 spacecraft is still providing us with groundbreaking scientific data, over 35 years after it’s launch. It is the furthest man-made object in space, currently exiting the solar system, and quite literally on its way to the stars. Because of Carl, we took the “Pale Blue Dot” photo which provided for the first time a unique perspective on just how vast the cosmos was, and how tiny of a planet we live on.

“All of human history has happened on that tiny pixel, which is our only home.” -Carl Sagan, speech at Cornell University, October 13, 1994. Earth is the tiny dot circled in blue.

Perhaps the most well known legacy of Carl is his Cosmos: A Personal Voyage, the 13 part series for PBS, which is still to this day the most watched PBS series in the world. Carl’s was of stating very complex and mind boggling ideas in simple, clear ways that anyone could understand, while still providing deep insight into the nature of the cosmos was at the heart of why this series was so special. He presented the largest pillars of knowledge that humans have uncovered with a poetic candor that mesmerized those who were watching.

I know that Carl played a large part in pushing me down the path that I have gone, and has left in his wake a new generation of role models to make the case for scientific though and reason, rationality, and human dignity. I hope that we can live up to the high water mark that he set. For now, he is back where he came from, someday, forming a new pile of star stuff.



Farewell, Comet 168P/Hergenrother!

This image shows the distinct nuclei splitting off from the comet. Credit: NASA/JPL-Caltech/NOAO/Gemini

If you want to catch a glimpse of the Comet 168P/Hergenrother, you’d better do it quickly. The comet has broken into at least four distinct pieces, according to NASA. This was discovered after it made it’s 7-year periodic appearance and had a sudden brightening from the expected 15th or so magnitude all the way up to a 9th magnitude. Over the last couple of months, it has brightened and dimmed a couple of times, probably due to this fracturing process. It’s perihelion (closest approach to the sun) was on October 1st, and may have also contributed to this break down and brightening process.

I made my second attempt to try and spot this dim comet tonight and was met with success! It was exciting to see something that I knew I would only get to see once. For my first attempt (last night), I had tried to catch it in my 10″ Dobsonian from my front porch, but with the “small city” amount of light pollution to deal with, it made this impossible. I may have caught the ghost of a smudge of it, but I will never be sure.

Tonight, I decided to trek out to an area with very dark skies, to make my chances as good as possible to see this lonely, dying comet, since I knew that I probably wouldn’t get another opportunity. I had almost immediate success. It was easy to spot, using the star finder map from Comet Chasers, in addition to making sure I knew the star hops pretty well in Stellarium before I had gone out for the night.

It was definitely a faint comet to spot, but it was decently visible. I used my 25mm eyepiece, anything with higher magnification made it too dim. This provided a nice, full view of the comet. I was able to see the nebulous coma stretching out, and the nucleus of the comet. With my eyes and telescope, however, I was not able to resolve pieces or separate nuclei, only a single one at the front. Averted vision worked well to enhance the coma. I waited around a half an hour after my first look for the sky to darken a bit more, and around 8:00pm seemed to be a good time.

It’s always exciting to witness events like this, since usually things take eons to unfold in the cosmos. When we can see something happening within our own lifetime, let alone within a few months or weeks, it’s always a unique memory.

My condolences to Carl Hergenrother (who blogs over at The Transient Sky) for losing a friend. :) While I’m sure it was thrilling to discover it 14 years ago, I’m sure it’s equally exciting for it to be getting some attention again. This was only my second comet to view in a telescope, and my first to find on my own, so it was an interesting learning experience that happened to turn into a bit of excitement.

If you have a decent telescope and some fairly dark skies, grab a finder map and give this one a shot. You won’t get another chance.

The comet is currently just above the constellation Pegasus. A zoomed view of the square portion is in the next image.

A zoomed view of the previous image. The star hop was easy for me by making a triangle from the top two stars of Pegasus to the top star in this image, and then walking down to where the comet was, somewhere within the circle on the map.