GalSim-developers/GalSim — pull request #473 by rmjarvis (2013-10-12 05:00:31+00:00)
Title: #470 Fix bugs in fourier space rendering of truncated Sersic profiles

This is a small PR to address a couple of bugs that affected the fourier space rendering of truncated Sersic profiles. There were two bugs.

1. The coefficients for the small-k approximation was missing a factor of flux_fraction, which is 1 normally, but < 1 for truncated Sersics. This meant that at the transition between the small-k and regular table look up regions, there was a sharp cliff in k-space, which led to ringing in real space.
2. The large-k approximation we use is essentially never a good approximation for severely truncated Sersics. There was a bug where if we don't ever find a good ksq_max at which to start using the asymptotic expansion, then ksq_max is left as uninitialized memory. This often meant that it was zero, which meant that f(k=0) tended to come out as -inf. This in turn led to nan's in the final drawn image. Now ksq_max is set to the last value in the lookup table if we don't find anything sooner.

I left in a test script -- really a test config file -- if you want to run it and see the resulting images. We don't need to keep it for the merge, but I left it in for now in case anyone wants to try it when reviewing the PR.

There is also a new unit test that checks if a severely truncated sersic convolved with an effective delta function agrees with the real-space drawing.