spacetelescope / jwql

The James Webb Space Telescope Quicklook Application
BSD 3-Clause "New" or "Revised" License
64 stars 44 forks source link

WATA preview images: improve scaling #1604

Open stscijgbot-jwql opened 3 months ago

stscijgbot-jwql commented 3 months ago

Issue JWQL-244 was created on JIRA by Bryan Hilbert:

Sometimes with WATA data, the default scaling isn't very good. A couple of very low and/or very high signal pixels seem to be throwing off the scaling.

Example: https://jwql.stsci.edu/NIRSpec/jw02784001001_02101_00001_nrs1/

Maybe we need to filter these pixels, or switch to a 99% scaling or something. (Although 99% of a 32x32 box means excluding only 9 pixels.

stscijgbot-jwql commented 3 months ago

Comment by Bryan Hilbert on JIRA:

I've been trying different options using the example file above. So far the two best results are from astropy ZScaleInterval when using a very low contrast (~0.01), and using astropy's MinMaxInterval. Those two results look very similar. I think the underlying problem is that the number of pixels with very low signal is larger than the number of pixels with very high signal. So doing a percentile clipping removes the pixels in the peak of the source, as well as some fraction of the low pixels. What's left is the wings of the PSF as well as the surrounding background pixels, all of which have fairly similar signal levels. That means the resulting image doesn't highlight the source very well. The background level is brought up into the upper range of the colorbar.

stscijgbot-jwql commented 3 months ago

Comment by Bryan Hilbert on JIRA:

ZScaleInterval with a contrast of 0.5, and a linear scaling seems best. This matches what Explore Image defaults to.

stscijgbot-jwql commented 3 months ago

Comment by Bryan Hilbert on JIRA:

Looks like Explore Image uses ZScaling with a contrast of 0.25

stscijgbot-jwql commented 3 months ago

Comment by Bryan Hilbert on JIRA:

For a future PR: Here is how the data are scaled in Explore Image: https://github.com/spacetelescope/jwql/blob/c4c37f567d604bb266fbf30c86d8db2e0c940324/jwql/utils/interactive_preview_image.py#L678 Then, in place of matplotlib.colors.LogNorm(), use matplotlib.colors.Normalize() You shouldn't need to shift the data to make it all positive, either. Although for some reason, in my testing just now, using the unshifted data gave a different-looking image than when it was shifted. Probably just a mistake on my part.

Emily Wislowski, let me know if the NIRSpec team would rather switch to a preview image that matches the image in the default Explore Image, such as: https://jwql.stsci.edu/NIRSpec/jw01118001001_02101_00001-seg001_nrs1_rate/explore_image/ https://jwql.stsci.edu/NIRSpec/jw02784001001_02101_00001_nrs1_rate/explore_image/ https://jwql.stsci.edu/NIRSpec/jw01647001001_02101_00001-seg001_nrs1_rate/explore_image/

In these cases, the background is much better separated from the PSF. However, the scaling is such that you can't see what's going on inside the PSF, because it's all above the top of the pixel range.