spacetelescope / jwst

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

outlier detection fails due to missing `array_shape` when run outside pipeline #8640

Closed stscijgbot-jp closed 2 months ago

stscijgbot-jp commented 2 months ago

Issue JP-3687 was created on JIRA by Brett Graham:

Running outlier detection outside of a pipeline with in_memory=False (the default) fails with:

 


    raise ValueError("WCS must have array_shape attribute set.")
ValueError: WCS must have array_shape attribute set. ```
This can be seen by running `strun outlier_detection fail_short_image3_asn.json` with the association (and data) for the `run_image3_closedfile` regtest

 

<https://bytesalad.stsci.edu/ui/repos/tree/General/jwst-pipeline/dev/nircam/image/fail_short_image3_asn.json>

I expect others will similarly fail as the initial failure was found running non-regtest data shared with us from a user related to a different ticket.

Running the same command and association with:

<https://github.com/spacetelescope/jwst/commit/831124ef9e768abaca412827272bc2e6ce6f60af>

(the commit just prior to <https://github.com/spacetelescope/jwst/pull/8553)> does not fail.

The issue appears to be that the resample usage in outlier detection adds an `array_shape` to the input wcses only when the input is a ModelContainer of open models (as occurs during the pipeline run) whereas when just outlier detection is called the input to resample is a ModelContainer of filenames and the input model wcses are not modifed.

Some possible solutions are:
 * modify `compute_image_pixel_area` to handle the case of a missing array shape. It's unclear to me why both the array shape and bounding box are considered (and if there are conditions when these might differ)
 * modify outlier detection to add an array_shape to the input wcs prior to the call to `compute_image_pixel_area`

 
stscijgbot-jp commented 2 months ago

Comment by Melanie Clarke on JIRA:

Fixed by #8645

stscijgbot-jp commented 2 weeks ago

Comment by David Law on JIRA:

Looks good to me on a MIRI test case, closing.