Skip to content

Conversation

@emolter
Copy link
Collaborator

@emolter emolter commented May 14, 2025

Resolves JP-3943

Closes #9295

This PR improves the compatibility between the tweakreg and source_catalog steps as follows:

  • Make tweakreg and source_catalog call the same underlying code for source finding
  • Add the same step-level parameters for controlling the source finding algorithm to source_catalog as already existed for tweakreg
  • Keep the same defaults in both steps
  • Continue to generate the segmentation map in source_catalog when segmentation is the starfinder (as is the default)
  • Make a small change in the way backgrounds are handled in source_catalog, bringing it in line with what already happens in tweakreg on main: Prior to this PR, in source_catalog, the computed background was subtracted from the data before source finding. As of this PR, the computed background is instead added to the source finding threshold. Both options are viable and the differences in the source catalogs are small.
  • Make a small improvement in the way thresholding is handled by the segmentation algorithm in tweakreg, bringing it in line with what already happens in source_catalog on main and what is in the SourceFinder documentation: Prior to this PR, in tweakreg, the threshold passed into SourceFinder was single-valued. As of this PR, the threshold is an image representing a per-pixel RMS threshold based on the background.

The two latter changes cause some small changes in the expected source catalogs from both steps.

Tasks

  • If you have a specific reviewer in mind, tag them.
  • add a build milestone, i.e. Build 12.0 (use the latest build if not sure)
  • Does this PR change user-facing code / API? (if not, label with no-changelog-entry-needed)
    • write news fragment(s) in changes/: echo "changed something" > changes/<PR#>.<changetype>.rst (see changelog readme for instructions)
    • update or add relevant tests
    • update relevant docstrings and / or docs/ page
    • start a regression test and include a link to the running job (click here for instructions)
      • Do truth files need to be updated ("okified")?
        • after the reviewer has approved these changes, run okify_regtests to update the truth files
  • if a JIRA ticket exists, make sure it is resolved properly

@codecov
Copy link

codecov bot commented May 14, 2025

Codecov Report

❌ Patch coverage is 98.42520% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.15%. Comparing base (75711d1) to head (2c386b8).
⚠️ Report is 398 commits behind head on main.

Files with missing lines Patch % Lines
jwst/source_catalog/source_catalog.py 97.67% 1 Missing ⚠️
jwst/tweakreg/tweakreg_catalog.py 98.43% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9462      +/-   ##
==========================================
+ Coverage   79.13%   79.15%   +0.01%     
==========================================
  Files         368      367       -1     
  Lines       37222    37200      -22     
==========================================
- Hits        29457    29444      -13     
+ Misses       7765     7756       -9     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@emolter emolter added this to the Build 12.0 milestone May 27, 2025
@emolter
Copy link
Collaborator Author

emolter commented May 27, 2025

Initial round of regtests here https://github.com/spacetelescope/RegressionTests/actions/runs/15003189900 prior to adding all the new parameters to source catalog.
These show the following differences:

  • segm maps are not being generated at all, while we figure out what to do about them moving forward
  • test_tweakreg_catalog_starfinder_alternatives[segmentation]: jwst.regtest.test_niriss_sourcefind is failing because of the bugfix to JP-4004
  • The other three tests, ending in _catalog, have small numerical differences. This is due to a small change in the way backgrounds are handled: prior to this PR, in source_catalog, the computed background is subtracted from the data before source finding. As of this PR, the computed background is instead added to the source finding threshold (which was the original behavior in tweakreg). Both options are viable and the differences in the source catalogs are small.

The differences are expected to be the same after the next commits, which add a bunch of options but should not change the defaults.

@melanieclarke melanieclarke removed this from the Build 12.0 milestone Jun 10, 2025
@emolter emolter added this to the Build 12.1 milestone Jul 10, 2025
@emolter
Copy link
Collaborator Author

emolter commented Jul 11, 2025

starting some new regtests https://github.com/spacetelescope/RegressionTests/actions/runs/16225055520

most recent rerun is after d63b233

The small differences in catalogs are expected due to the last two changes in the bulleted list in the top-level description.

@emolter emolter changed the title WIP: JP-3943: Give source_catalog step same flexibility as tweakreg JP-3943: Give source_catalog step same flexibility as tweakreg Jul 11, 2025
@emolter emolter marked this pull request as ready for review July 11, 2025 22:13
@emolter emolter requested review from a team as code owners July 11, 2025 22:13
@emolter emolter requested a review from tapastro July 11, 2025 22:14
finder_args = list(inspect.signature(IRAFStarFinder).parameters)
finder_dict = {k: kwargs.pop(k) for k in dict(kwargs) if k in finder_args}

# oldestdeps still encounters bug with roundlo=0.0
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

how do people feel about just bumping the minimum photutils version to 2.1 instead?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay by me. I have another PR that will likely need photutils >= 2.0 anyway.

model.meta.bunit_err = unit.name

@staticmethod
def convert_from_jy(model):
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe better to state in the method name what you are converting to rather than from, e.g.
def convert_to_megajansky_per_steradian()
it's a bit long but I think clearer

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

how does 5937225 look?

@tapastro tapastro merged commit 63ad9a0 into spacetelescope:main Jul 17, 2025
28 checks passed
@emolter
Copy link
Collaborator Author

emolter commented Jul 17, 2025

clean regtest run for okify. the last one was a re-run, which we still can't okify from
https://github.com/spacetelescope/RegressionTests/actions/runs/16350337396

ok, trying again because of this sonar scan URL issue
https://github.com/spacetelescope/RegressionTests/actions/runs/16350562339

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.

Homogenize usage and capability of source_catalog step and tweakreg source catalog

4 participants