Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress warnings about NaNs in input data from TweakRegStep #8308

Merged

Conversation

jdavies-st
Copy link
Collaborator

@jdavies-st jdavies-st commented Feb 26, 2024

Currently TweakRegStep logs lots of warnings like the following:

2024-02-26 14:09:45,740 - stpipe.tweakreg - WARNING - /Users/jdavies/miniconda3/envs/jwst-dev/lib/python3.11/site-packages/photutils/background/background_2d.py:273: AstropyUserWarning: Input data contains invalid values (NaNs or infs), which were automatically masked.
2024-02-26 14:09:45,740 - stpipe.tweakreg - WARNING -   warnings.warn('Input data contains invalid values (NaNs or '
2024-02-26 14:09:45,740 - stpipe.tweakreg - WARNING - 
2024-02-26 14:09:46,597 - stpipe.tweakreg - INFO - Detected 106 sources in jw01345002001_14201_00002_nrcalong_cal.fits.
2024-02-26 14:09:46,608 - stpipe.tweakreg - WARNING - /Users/jdavies/miniconda3/envs/jwst-dev/lib/python3.11/site-packages/photutils/background/background_2d.py:273: AstropyUserWarning: Input data contains invalid values (NaNs or infs), which were automatically masked.
2024-02-26 14:09:46,608 - stpipe.tweakreg - WARNING -   warnings.warn('Input data contains invalid values (NaNs or '
2024-02-26 14:09:46,608 - stpipe.tweakreg - WARNING - 
2024-02-26 14:09:47,422 - stpipe.tweakreg - INFO - Detected 115 sources in jw01345002001_14201_00003_nrcalong_cal.fits.
2024-02-26 14:09:47,433 - stpipe.tweakreg - WARNING - /Users/jdavies/miniconda3/envs/jwst-dev/lib/python3.11/site-packages/photutils/background/background_2d.py:273: AstropyUserWarning: Input data contains invalid values (NaNs or infs), which were automatically masked.
2024-02-26 14:09:47,433 - stpipe.tweakreg - WARNING -   warnings.warn('Input data contains invalid values (NaNs or '
2024-02-26 14:09:47,433 - stpipe.tweakreg - WARNING - 
2024-02-26 14:09:48,253 - stpipe.tweakreg - INFO - Detected 95 sources in jw01345002001_14201_00001_nrcalong_cal.fits.
2024-02-26 14:09:48,265 - stpipe.tweakreg - WARNING - /Users/jdavies/miniconda3/envs/jwst-dev/lib/python3.11/site-packages/photutils/background/background_2d.py:273: AstropyUserWarning: Input data contains invalid values (NaNs or infs), which were automatically masked.
2024-02-26 14:09:48,266 - stpipe.tweakreg - WARNING -   warnings.warn('Input data contains invalid values (NaNs or '
2024-02-26 14:09:48,266 - stpipe.tweakreg - WARNING - 
2024-02-26 14:09:49,092 - stpipe.tweakreg - INFO - Detected 100 sources in jw01345002001_14201_00001_nrcblong_cal.fits.
2024-02-26 14:09:49,950 - stpipe.tweakreg - WARNING - /Users/jdavies/miniconda3/envs/jwst-dev/lib/python3.11/site-packages/photutils/background/background_2d.py:273: AstropyUserWarning: Input data contains invalid values (NaNs or infs), which were automatically masked.
2024-02-26 14:09:49,950 - stpipe.tweakreg - WARNING -   warnings.warn('Input data contains invalid values (NaNs or '
2024-02-26 14:09:49,950 - stpipe.tweakreg - WARNING - 
2024-02-26 14:09:50,762 - stpipe.tweakreg - INFO - Detected 94 sources in jw01345002001_14201_00002_nrcblong_cal.fits.
2024-02-26 14:09:50,775 - stpipe.tweakreg - WARNING - /Users/jdavies/miniconda3/envs/jwst-dev/lib/python3.11/site-packages/photutils/background/background_2d.py:273: AstropyUserWarning: Input data contains invalid values (NaNs or infs), which were automatically masked.
2024-02-26 14:09:50,775 - stpipe.tweakreg - WARNING -   warnings.warn('Input data contains invalid values (NaNs or '
2024-02-26 14:09:50,775 - stpipe.tweakreg - WARNING - 
2024-02-26 14:09:51,584 - stpipe.tweakreg - INFO - Detected 98 sources in jw01345002001_14201_00003_nrcblong_cal.fits.

which is caused by passing _cal.fits data with NaNs to photutils.background.Background2D:

https://github.com/astropy/photutils/blob/d5e8bc9afebd758087ea47874aff0a1788e22587/photutils/background/background_2d.py#L287-L289

All JWST input data for this step has NaNs, so warning about them is not informative. This PR suppresses those warnings, so we now get:

2024-02-26 14:13:18,475 - stpipe.tweakreg - INFO - Detected 106 sources in jw01345002001_14201_00002_nrcalong_cal.fits.
2024-02-26 14:13:19,287 - stpipe.tweakreg - INFO - Detected 115 sources in jw01345002001_14201_00003_nrcalong_cal.fits.
2024-02-26 14:13:20,097 - stpipe.tweakreg - INFO - Detected 95 sources in jw01345002001_14201_00001_nrcalong_cal.fits.
2024-02-26 14:13:20,903 - stpipe.tweakreg - INFO - Detected 100 sources in jw01345002001_14201_00001_nrcblong_cal.fits.
2024-02-26 14:13:22,522 - stpipe.tweakreg - INFO - Detected 94 sources in jw01345002001_14201_00002_nrcblong_cal.fits.
2024-02-26 14:13:23,345 - stpipe.tweakreg - INFO - Detected 98 sources in jw01345002001_14201_00003_nrcblong_cal.fits.

Possible upstream fix for this in astropy/photutils#1712

Checklist for maintainers

  • added entry in CHANGES.rst within the relevant release section
  • updated or added relevant tests
  • updated relevant documentation
  • added relevant milestone
  • added relevant label(s)
  • ran regression tests, post a link to the Jenkins job below.
    How to run regression tests on a PR
  • Make sure the JIRA ticket is resolved properly

@jdavies-st jdavies-st requested a review from a team as a code owner February 26, 2024 13:31
@jdavies-st jdavies-st force-pushed the tweakreg-silence-photutils-warnings branch from 46dc688 to d102466 Compare February 26, 2024 13:33
Copy link

codecov bot commented Feb 26, 2024

Codecov Report

Attention: Patch coverage is 62.50000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 75.21%. Comparing base (4cc0ac1) to head (d879a7f).
Report is 2 commits behind head on master.

❗ Current head d879a7f differs from pull request most recent head bb89734. Consider uploading reports for the commit bb89734 to get more accurate results

Files Patch % Lines
jwst/source_catalog/detection.py 62.50% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8308      +/-   ##
==========================================
+ Coverage   75.15%   75.21%   +0.05%     
==========================================
  Files         470      474       +4     
  Lines       38604    38812     +208     
==========================================
+ Hits        29014    29191     +177     
- Misses       9590     9621      +31     
Flag Coverage Δ *Carryforward flag
nightly 77.36% <ø> (-0.03%) ⬇️ Carriedforward from 4cc0ac1

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@larrybradley larrybradley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @jdavies-st.

@jdavies-st
Copy link
Collaborator Author

@larrybradley PEP8 cleanup on aisle 7 is done.

@hbushouse hbushouse added this to the Build 10.2 milestone Feb 27, 2024
@hbushouse
Copy link
Collaborator

@jdavies-st jdavies-st force-pushed the tweakreg-silence-photutils-warnings branch from b80f5e9 to bb89734 Compare February 28, 2024 15:22
@hbushouse
Copy link
Collaborator

Regression test run started at https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/1236

Regression test run is clean, as expected.

@hbushouse hbushouse merged commit f5f4826 into spacetelescope:master Feb 28, 2024
25 checks passed
@jdavies-st jdavies-st deleted the tweakreg-silence-photutils-warnings branch February 29, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants