GalSim-developers/GalSim — pull request #206 by rmjarvis (2012-06-27 13:19:27+00:00)
Title: #175 Updates to demo scripts plus new one for photon shooting

I've updated the existing demo scripts with some of our recent code changes. Specifically:

- Multiple ways of specifying shear
- Added obscuration to the OpticalPSF usage
- Switch usage of Moffat truncation to physical units
- Added AtmosphericPSF (Kolmogorov spectrum)
- Use new applyDilation function
- Use new drawShoot method for drawing using photon shooting.

The last item is the biggest addition. There is a new script 4 in MultiObjectDemo.py. It creates pairs of images, the left side drawn using FFTs, and the right side drawn using photon shooting. It uses 5 different PSFs:
- Gaussian
- Moffat
- DoubleGaussian
- Gaussian * OpticalPSF
- AtmosphericPSF * Airy
And 5 different galaxies:
- Gaussian
- Exponential
- DeVaucouleurs
- n=2.5 Sersic
- Bulge + Disk (Sersic 3.2 / 1.5 respectively)
Each pairing (5x5) is done with 4 random values of:
- flux
- galaxy half-light radius
- galaxy ellipticity
- position angle
So 100 images total, written to a fits data cube.

There were a number of bugs found along the way in writing this, and some new functionality written to facilitate this. (Especially the ability of drawShoot to now automatically figure out how many photons to shoot given a sky level.) Some of these were migrated to branch #163, which was recently merged. But some are still to be code reviewed on this branch. So here is a list of the code changes worth checking out:

- Moved DoubleGaussian from atmosphere.py to base.py. It was the only profile that wasn't directly in the galsim namespace, so now it is `galsim.DoubleGaussian` rather than `galsim.atmosphere.DoubleGaussian`. This seems cleaner to me.
- The new applyDilation function, along with applyMagnification and the corresponding create versions were done as part of this branch. They were a small enough addition that I didn't bother having them on their own branch. So this pull request includes issue #191.
- Added gain option to draw and drawShoot. It turns out this makes it easier for drawShoot to handle the different normalizations while still having the flux be accurate for determining how many photons to shoot.
- Fixed some bugs in the initial implementation of the automatic determination of the number of photons.
- Added dx option to draw. For now specifying it is equivalent to doing `image.setScale(dx)` before calling drawShoot, but it makes the signatures for draw and drawShoot in python more parallel, and eventually it will be used as part of the option to automatically create an image as draw currently does.
- Added an option to AtmosphericPSF to specify fwhm rather than lam_over_r0. (As usually exactly one size must be specified).
- Fixed a bug in AtmosphericPSF when an interpolant is specified.
- Use an AiryInfo class to store information common to all Airy objects for a particular obscuration value, similar to SersicInfo for its n value. The assumption is that the user may create different Airy objects for different purposes, but won't vary the obscuration very often. We will want to think about what to do when this isn't the case (for Sersic n too!). Currently there is a hardwired maximum of 100, just like for Sersic, but we may want to either get rid of that limit (and warn the user when it starts storing a lot) or automatically clear out the storage when it gets too large.
- A few other minor optimizations for Airy that had been deferred until there were better unit tests for Airy, which there are now.
- Removed the wrappings for plainDraw, fourierDraw, etc. These are really implementation details and shouldn't be made public. I'd actually like them to be made private methods in C++, but I didn't make that change. But at least we shouldn't be exposing them to the python layer.