GalSim-developers/GalSim — pull request #24 by barnabytprowe (2012-03-14 02:04:36+00:00)
Title: #13

I would like to merge this code into the "master" branch:

https://github.com/GalSim-developers/GalSim/compare/master...%2313

This is a fairly concise optical module, containing functions (not yet embedded or referenced by classes) that will generate numpy arrays. These will contain images of the PSF and MTF (modulation transfer function, the OTF and PTF are also available) generated according to simple low-order aberration theory: http://en.wikipedia.org/wiki/Optical_aberration#Zernike_model_of_aberrations

In Python, from the GalSim base directory (which I guess if added to the $PYTHONPATH environment variable will all this to work from from everywhere), you simply load the module via

>>> import galsim.optics

To get an example aberrated PSF image, you can type something like
>>> psf = galsim.optics.psf(shape=(512, 512), defocus=0.25, astig1=0.04, astig2=-0.12, coma1=0.08, spher=0.1, kmax=0.2 * 3.14159)
>>> import pyfits
>>> pyfits.writeto('psf.fits', psf)

You will see the somewhat aberrated PSF. The convention for setting the size (via the kmax of the MTF) is described in the function docstrings.

Simple, not-exhaustive unit tests accompany the module in the tests/ directory. These can be run (and should pass, do let me know if not) by changing to the tests directory and simply typing:

$ nosetests

This is an early version of the optics module, and is not complete, but I would welcome comments from all, particularly from all Pythonistas (Joe, Jim, Peter etc. and any I've missed) and those who have put significant time elsewhere into the code so far (e.g. Mike, Rachel). The interface is rather simple, and we may want to eventually cope with inputs in a slightly less abstracted form, but it is fairly general. Currently no zero padding is done, in real or k-space, and this may sometimes be necessary to avoid periodic overlapping (the real space equivalent of aliasing) in heavily aberrated PSFs. The documentation is yet to be DOxygen-ized, but that is on my to-do list, rest assured.

If review comments could be made on this code before the end of this week, I will then merge it unless there are strong objections (possible) / conflicts with other code (unlikely at this stage). Please make comments on the most recent commit, or at an earlier relevant stage with a link at the current most recent commit.