GalSim-developers/GalSim — pull request #156 by gbernstein (2012-05-18 18:54:24+00:00)
Title: #44 photons

Photon shooting is now fully functional. I can think of some optimizations and code cleanups to do but I think it's better to pull it into the master and let you all find the problems first. There is a lot of new stuff, although at user level you only need to know about `SBProfile::drawShoot()` and everything else should be hidden. See the docstring for that method for more details on photon shooting.

I had to alter these other parts of the code to get this working:
* in Int.h, had to change some function arguments to references, @mjarvis said this is ok.
* in fits.py, I changed the way the FITS coordinate keywords CRPIX etc were being calculated so they reflect what the SBProfile code is truly assuming about the coordinate system. @TallJimbo may wish to check.
* The Python wrappers for SBProfile classes had to change a bit. @TallJimbo had written me an initial version, which I hacked at (with Mike's help) as the interface evolved. It works, but I'm not sure it's optimal and may be wrapping routines and classes that do not need Python access.

You can give this a whirl with the simple example programs SBDrawShoot.py and ShootInterpolated.py which will draw analytic and pixellated images, respectively, using photon shooting. For instance

examples/ShootInterpolated.py delta.fits test.fits 0.1 128 100000

will take in input image delta.fits (which I have produced as having a single nonzero pixel in the center) and draw test.fits as a magnified version of the interpolation kernel (currently Quintic in the code) with 1e5 photons.

All the SBProfile options have working photon shooting implementations except: SBDeconvolve (which is impossible), the Sinc interpolant (which is crazy), and SBLaguerre (which is at least difficult, maybe impossible).

There may be some bugs with photon-shooting setup information being lost when SBProfiles are copied or assigned; I have looked at all of the cases yet. But if we are going to review the SBP code soon to make them immutable, these will turn up. Meanwhile: for the classes that do the shooting numerically instead of analytically, there is setup time, so it's best not to make a new instance for every time you draw. These are the Cubic, Quintic, & Lanczos interpolant, and the SBAiry. (SBSersic caches the setups).