Tuesday, August 26, 2008

Telescope Simulator

I created a telescope simulator! WOOOT

WTF (Why The Heck) would I do such a thing? I don't know. But I did it. Now bow before me. Bwahahahh.....

Ok, silliness aside, here's the basic idea. Telescopes (and cameras, and imaging systems of any sort) act as spatial filters. The aperture's diameter, its shape, and the nature of any obstructions fundamentally limit the sharpness of the image that can be focused onto the image sensor. This phenomenon is known as the diffraction limit.

I created a software simulation of this effect, using Python and the following Python libraries: Matplotlib(PyLab), SciPy and NumPy. I could have done this all in MatLab, but I wanted to give Python a shot, for fun. I made the "Fourier Assumption", ie, that the 2D Fourier Transform of the aperture function is the point-spreading-function in the focal plane (which is a good assumption for imaging systems with high F-numbers), and then solved the Fourier Transform for a circular aperture with a circular central obstruction. I used wxMaxima to crunch the 2D integral for me, which was a good thing, since the solution involved Bessel functions.

My telescope simulator can simulate an imaging system with the following customizable parameters:
  1. Aperture diameter (circular)
  2. Aperture obstruction diameter (circular, centered)
  3. Light wavelength range (optical filter bandwidth)
  4. Focal length
  5. Image sensor pixel X and Y dimensions
The following images simulate a known image sensor with 4.64um (square) pixels. The aperture diameter is ~32", with a ~8" obstruction. The focal length is 342", and the imaging wavelength is 500nm (green). To simulate a wider bandwidth, I would just run multiple simulations, stepped over a bandwidth range and average the images together, but I didn't do that this time.

I begin with a very large image of Mars, probably taken by the Hubble, or an imaging satellite nearer to Mars. I then select out the green channel (since it is the highest-quality channel) and re-sample it (using perfect "Sinc" re-sampling), to simulate it being sampled by my simulated image sensor, at the simulated focal length, and with Mars at its closest to Earth. This is what I call the "perfect" image. It is the upper bound for what the telescope could ever hope to achieve. I then compute the point-spreading function of the aperture, and convolve this with the "perfect" image, which has the effect of smearing it. This simulates the effect of a real-world, finite, imperfect aperture. It shows, quite clearly, the diffraction limit's effect on image quality.

Original Image of Mars
(simulation only uses the green channel)

"Perfect" Image
(as if sampled by a telescope with an infinite aperture)

Simulated Image
(smeared by the effects of a non-infinite aperture)

You can click on the images for the full-res versions, although, the gray-scale images may not be any bigger than displayed here. There aren't very many pixels in the simulated image sensor, and using more pixels doesn't help! That's why its called the diffraction limit. It fundamentally limits an imaging system's resolving power, and partially explains why the ongoing consumer-digital-camera "mega-pixel race" is a gigantic in-your-face scam. Image noise is the other side of the issue.

I will upload my Python code to my Junk Shed sometime in the near future, once I clean it up a bit, to make it fit for public consumption.

2 comments:

ExtremMicrobia said...

Pythons bite. First they squeeze and then they bite.
Well that's a cool simulator. You should get some pictures of Europa :D I bet those would be cool to play with.

Unknown said...

did you ever finish that simulator? would be interested in looking at it or cleaning it up for you