spacetelescope / jwst

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

absolute derivitive calculation in outlier detection has edge effects #8636

Open stscijgbot-jp opened 2 months ago

stscijgbot-jp commented 2 months ago

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

The abs_deriv function used in outlier detection assumes 0 values for off-edge pixels which leads to edge effects.

https://github.com/spacetelescope/jwst/blob/033b81756c2cc04c0a38930d1c88b3c931586bd7/jwst/outlier_detection/outlier_detection.py#L517

For example providing the following as input:

 

arr = np.arange(25).reshape((5, 5))

I would expect that the output should be 5 everywhere in the result (since for example the absolute difference between for example arr[4, 4] and arr[3, 4] is 5

 

 


[ 0  1  2  3  4]
[ 5  6  7  8  9]
[10 11 12 13 14]
[15 16 17 18 19]
[20 21 22 23 24] ```
However the result is different as it is assumed that off-edge pixels are 0.

 
```java
[ 5  5  5  5  5]
[ 5  5  5  5  9]
[10  5  5  5 14]
[15  5  5  5 19]
[20 21 22 23 24]  ```
This likely leads to edge pixels being erroneously flagged as outliers.

 

 
stscijgbot-jp commented 2 months ago

Comment by Brett Graham on JIRA:

A modified abs_deriv that does not have the edge effects (returns all 5s for the above example) is at #8635

stscijgbot-jp commented 2 months ago

Comment by Brett Graham on JIRA:

Here is a regression test run with the above linked fixed abs_deriv: https://plwishmaster.stsci.edu:8081/blue/organizations/jenkins/RT%2FJWST-Developers-Pull-Requests/detail/JWST-Developers-Pull-Requests/1595/tests

showing 62 test failures. A more thorough investigation of these differences will be needed but many have different OUTLIER dq bits as expected.

braingram commented 1 month ago

xref: https://github.com/spacetelescope/jwst/issues/8402