Closed rmjarvis closed 5 years ago
Here is a comparison of the photon shooting (left) and fft (right) for 1.e7 photons.
Not identical, but close enough I think for the purpose of having interesting wings interfering with the objects we really care about.
Here's a comparison for a star with 2.1e8 photons (magnorm=12.5 for this star):
The image on the left has the fft_switch enabled with fft_sb_thresh=2e5
, and the image on the right has it disabled using fft_sb_thresh=None
. Here are profile plots of a vertical slice through the center of each image:
cProfile outputs attached:
fft_switch_off.prof.txt
fft_switch_on.prof.txt
Based on the profile info, using the fft rendering saves about ~100s, so for a magnorm=10 object (10x more photons), this is about ~1000s savings.
Since we are doing a real FFT I'm a bit confused by the profile difference. Is this the difference between sampling over infinite time and 30 seconds?
Great! Thanks Jim!
I'm a bit confused by the profile difference.
Partly, it's that the profiles aren't actually identical. A VonKarman profile would be closer to what you get from real phase screens, but it was showing weird artifacts in the FFT rendering that I couldn't figure out. So Josh and I decided that, for this purpose, switching to Kolmogorov (which doesn't show any artifacts) was probably fine.
And additionally, this is down in the regime where both photon shooting and ffts are making approximations. They make different approximations of course, and it's not actually clear which one of them is more accurate there. If I had to guess, I'd say the FFT is probably more accurate, since this is in the part of the profile that comes from the Airy wings, which the SecondKick is supposed to emulate for photon shooting. But there are a lot of fiddly bits in that second kick approximation, which may not be completely capturing this bit perfectly. Also, the FFT shape looks more natural to me, while the photon shooting looks to have a slightly abrupt drop off where they start to diverge.
Thanks Mike. I was remembering the FFT vs ray-tracing studies that Josh did when he was tuning the critical cutoff, and I thought I remembered better agreement but I didn't appreciate it was actually a different function. I wonder why wasn't Josh seeing the artifacts then?
Unless there are objections, I will merge this at 2pm PT today.
This PR implements ImSim issue 157 to transition to using FFT rendering when the object is very bright.
It's not really efficient to do this with the full atmospheric screen PSF, but if the object is saturated, we don't really care about the central turbulent part being right. Rather, we mostly just care that the wings are more or less correct. So this implements transitioning to a Kolmogorov convolved with an OpticalPSF taking all the relevant parameters from the currently active PhaseScreenPSF. So it matches the regular PSF as much as possible.
The FFT rendering time maxes out at around 1 second (on my laptop) for any flux, and the transition seems to be around 1e6 photons. Since 1e6 photons is not typically saturated, I set it up to keep using the regular photon shooting rendering until the object would be saturated and switch over at that point.
The recommended way to use this is to set fft_sb_thresh to the saturation value, 1.e5, or possibly a bit higher to be conservative. The default value is None, which means don't ever switch.
As usual, I didn't try to run this, since I don't have an easy way to do so. But I did run some tests of the salient bits of code on my laptop to try it out. So apologies in advance if there are any stupid coding errors here.