mperrin / webbpsf

James Webb Space Telescope PSF simulation tool - NOTE THIS VERSION OF REPO IS SUPERCEDED BY spacetelescope/webbpsf
BSD 3-Clause "New" or "Revised" License
16 stars 15 forks source link

Bug in NIRCam coronagraph round mask: truncation at wrong value for zero of Bessel function #206

Closed mperrin closed 6 years ago

mperrin commented 6 years ago

Just noticed this today; we've been mis-calculating the transmission of the round masks by about half a percent. Not sure how long it has been an issue, but potentially a long time.

Issue: The NIRCam coronagraph occulters only contain the central peak and first side lobe, and are truncated after that. The implementation for the bar occulters appears to be correct, but for the round masks it's truncating it not at the second zero of the function but at a nonzero value. As a result the transmission of the mask far away from the occulter is not 1, as it should be.

See as follows. In the left-hand plot the background is slightly off-white, and in the right panel we see the transmission flatlines at around 0.995. mask335r_example

[edit: right hand plot in above figure is mislabeled. Should say 335R instead of 210R]

On the other hand, the LWB mask looks fine:

masklwb_example

Root cause and Fix: The problem is that I was truncating at r=2 pi, but that's not the correct zero for the Bessel function J1. The correct value to truncate at is 7.1559. Switching to this in webbpsf/optics.py:NIRCam_BandLimitedCoron.get_transmission() does appear to resolve this issue. I'll check in a fix for that shortly, but wanted to document this issue here.

I haven't checked what impact this had on the contrasts. I'm hoping not that much because it acts mostly like just an 0.5% reduction in throughput uniformly.

mperrin commented 6 years ago

@JarronL, FYI, see this issue I just found in the NIRCam coronagraph occulter model for the round masks. Probably a 0.5% throughput error that I hadn't seen until now.

I'm a little dismayed to discover there was an issue here I/we hadn't caught before. Would you be willing to help me audit and cross check the rest of the mask geometry a bit? Now I'm paranoid and want to make extra sure nothing else is off...

mperrin commented 6 years ago

After updating the code to truncate at the correct value for the second zero of the first Bessel function of the first kind (i.e. scipy.special.jn_zeros(1,2)[1] instead of 2*np.pi), the occulter transmission now looks like it should. The transmission levels out at precisely 1.0 for all positions far from the occulting mask and ND spots.

mask335r_example_fixed

mperrin commented 6 years ago

I double checked the implementations in WebbPSF against the equations given in Krist et al. 2007 Proc SPIE. Everything else looks consistent as far as I can tell.

JarronL commented 6 years ago

I actually had noticed the lower throughput a while ago, but thought it was intentional or a consequence of the Bessel function being used. At the time, I did a quick test where I forced the transmission to be 1.0 past 2*pi and saw negligible impact on the contrast, so just let it go.