spacetelescope / jwst

Python library for science observations from the James Webb Space Telescope
https://jwst-pipeline.readthedocs.io/en/latest/
Other
546 stars 160 forks source link

NIRCam ERR measurements (from photutils) of same source are inconsistent depending on the pixel scale of the mosaic #8625

Open stscijgbot-jp opened 5 days ago

stscijgbot-jp commented 5 days ago

Issue JP-3680 was created on JIRA by Maria Pena-Guerrero:

A user reported via Help Desk ticket, that NIRCam ERR measurements of the same source are inconsistent depending on the pixel scale of the mosaic. This was confirmed by the NIRCam team and they suspect a bug in the resample step.

The notebook the user provided can be found in the Help desk ticket: https://stsci.service-now.com/nav_to.do?uri=%2Fincident.do%3Fsys_id%3D9b3c5903934b8e50619dfe4c5cba103f%26sysparm_domain%3Dnull%26sysparm_domain_scope%3Dnull%26sysparm_view%3DJWST%26sysparm_view_forced%3Dtrue

 

stscijgbot-jp commented 5 days ago

Comment by Bryan Hilbert on JIRA:

The values in the SCI extension of the mosaics were consistent across changing output pixel scale values. It is the values in the ERR array that vary with the output pixel scale.

stscijgbot-jp commented 5 days ago

Comment by David Law on JIRA:

Maria Pena-Guerrero : Just to confirm, this bug is present in the B11.0 (jwst 1.15.0) code, right?

stscijgbot-jp commented 5 days ago

Comment by Maria Pena-Guerrero on JIRA:

correct, present in B11.0

stscijgbot-jp commented 3 days ago

Comment by Bryan Hilbert on JIRA:

Anton Koekemoer has had a chance to take a more detailed look at this issue. He reports:

"I still confirm the 2x inconsistency in errors, I also confirm that our test from the other day reproduces the photutils approach -- but photutils may be part of the issue, here’s why:

So perhaps this is not a pipeline bug at all, but a photutils bug? Larry Bradley

stscijgbot-jp commented 3 days ago

Comment by Anton Koekemoer on JIRA:

To expand a bit on the above -- it all works fine, ie the pipeline ERR array and also the photutils measurements, when the mosaics are at the default pixel scale, so no issues there at all (ie this doesn't impact any of our default pipeline products).

But with a non-default pixel scale, the way in which the ERR array is defined (MJy/sr) means the interaction with photutils needs to be slightly adjusted to account for the relative change in pixel scale.

Attached here is the plot from the original helpdesk call (all public data), showing the 2x difference in the error values -- the photometry flux values are all consistent, just the error values are off by 2x, or by sqrt(relative pixel area)

!image-2024-07-05-11-53-01-534.png!

stscijgbot-jp commented 4 hours ago

Comment by Larry Bradley on JIRA:

The very first thing the JWSTSourceCatalog step does when creating the source catalog is to convert the data and error array from MJy/sr to Jy. All of the photutils photometry calculations are done from data/error arrays in flux (Jy) units, so it's not a photutils bug.

The unit conversion from MJy/sr to Jy is performed in the source catalog step using the model.meta.photometry.pixelarea_steradians value of the input image. -Does the resample step update this value for non-native pixel scales? That could be the source of the bug.- Edit: that's not the issue. The issue is the input error array (see comment above).

stscijgbot-jp commented 1 hour ago

Comment by Larry Bradley on JIRA:

I took a look at the images provided in the help desk ticket. The issue is definitely with the input data. The error arrays for 30 mas/pix and 60 mas/pix data are not equivalent. You can verify this by taking a single pixel in the 60 mas/pix image and comparing it with its corresponding 4 pixel (2x2 region) in the 30 mas/pix.

First convert the data and error arrays from surface brightness to flux density units (e.g., multiply by PIXAR_SR * 1e12 to convert to uJy).

Flux: Comparing the 60 mas/pix data value with the sum of the corresponding 4 pixels in 30 mas/pix data images agree.

Errors: The square root of the quadrature sum of the 4 pixels in the 30 mas/pix image is half the value of the same pixel in the 60mas/pix error image. They should give the same value. Therefore, one of the error arrays in the images provided by the user is wrong (scaled improperly).