spacetelescope / jwst

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

extract_1d SOSS ATOCA failures on saturated data #8540

Closed stscijgbot-jp closed 1 week ago

stscijgbot-jp commented 4 months ago

Issue JP-3650 was created on JIRA by Ned Molter:

Error message  ValueError: Some pixels do not follow the expected dispersion axis! is seen when attempting run the ATOCA algorithm on saturated, highly flagged, or other bad data.  Initial analysis suggests that for these datasets, the soss_solver finds unreasonable solutions for the (rotation, xshift, yshift) transform that attempts to align the expected positions of the spectral trace with the real position.  For "good" data, the rotation angle should be much smaller than one degree (of order 1e-3 degrees), but for e.g. the OTB mock data this rotation angle was found to be 3 degrees. 

 

The transform is applied to the wavelength map using an FFT method.  The wavelength map is padded by 20 pixels in all directions (by default) to mitigate any artifacts caused by the edge of the detector during the transform.  However, for such a large rotation angle, artifacts of the FFT end up in the corners of the frame, and are never masked properly; see attached image.  These artifacts have incorrect wavelength values, and this is caught when the code checks that the wavelength values are strictly ascending/descending, leading to the error.

 

This failure mode has occurred on a dataset where Orders 1 and 2 were purposely saturated to attempt to retrieve a spectrum from Order 3.  At present, the pipeline does not support extraction of Order 3.  It has also occurred on some OTB data that display nothing resembling a true spectral trace.  It appears that this failure mode should not occur for good data in orders 1 and 2, because there would be no situation in which the actual rotation angle of the detector was different from expected by such a large amount, far outside the pointing tolerance.

stscijgbot-jp commented 4 months ago

Comment by Ned Molter on JIRA:

It remains an open question what exactly to do about this.  Here's my two cents:

stscijgbot-jp commented 3 months ago

Comment by Nestor Espinoza on JIRA:

We discussed this during today's SOSS tag-up meeting (see June 10th meeting notes here: https://innerspace.stsci.edu/display/JWST/NIRISS+SOSS+Team).

The dataset on which this is failing (PID 3279)  is one in which Orders 1 and 2 were saturated (on purpose); we believe this indeed showcases the limiting case of ATOCA/the pipeline, in which if you have most of your pixels saturated, ATOCA will fail. In cases like this, the user will have to handle extraction on their own — which was, in fact, the intent of the proposal ([https://www.stsci.edu/jwst/science-execution/program-information?id=3279).]

RE: the error message being better/better diagnose the issue, it's complex this being a limiting case (we do know the same message appears on other instances of ATOCA). We suggest, however, to defer work on better error messages and/or diagnose ATOCA failures better for future work, given we are working in fact on implementing some updates to ATOCA at the moment. 

stscijgbot-jp commented 3 months ago

Comment by Ned Molter on JIRA:

Setting this ticket to "On Hold" based on what I'm understanding from your comment Nestor Espinoza.  If everyone is content that no changes are going to be needed until the ATOCA updates are ready to integrate into the pipeline, should we go ahead and withdraw this ticket?

stscijgbot-jp commented 1 month ago

Comment by Rachel Plesha on JIRA:

Joseph Filippazzo / Aarynn Carter will Nestor's comment below be addressed with the changes being implemented in JP-3588? If so, this ticket may be fixed with the upcoming build 11.1 changes.

stscijgbot-jp commented 1 month ago

Comment by Joseph Filippazzo on JIRA:

I think the answer is yes, it SHOULD get fixed by JP-3588. The changes will completely remove the transformation determined via a trace fitting routine (which errors for saturated traces) in favor of a new method that predicts the trace locations derived from observational data as a function of pupil wheel position.

stscijgbot-jp commented 1 month ago

Comment by Aarynn Carter on JIRA:

I agree with Joe, it should be resolved - we'll have to test it to be sure. 

stscijgbot-jp commented 1 week ago

Comment by Ned Molter on JIRA:

Marking this Ready for Testing because it should be fixed by the PASTASOSS PR here #8763