-
Notifications
You must be signed in to change notification settings - Fork 169
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
JP-1649: Add option for user-defined sky levels in skymatch #9053
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9053 +/- ##
==========================================
+ Coverage 76.92% 76.93% +0.01%
==========================================
Files 498 498
Lines 45810 45831 +21
==========================================
+ Hits 35240 35261 +21
Misses 10570 10570
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. |
jwst/skymatch/skymatch.py
Outdated
@@ -25,7 +25,7 @@ | |||
log.setLevel(logging.DEBUG) | |||
|
|||
|
|||
def match(images, skymethod='global+match', match_down=True, subtract=False): | |||
def skymatch(images, skymethod='global+match', match_down=True, subtract=False, skylist=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slightly beyond the PR scope, but I went ahead and changed the name of this function because it violates https://docs.astral.sh/ruff/rules/builtin-variable-shadowing/
Happy to revert if desired, though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is match
a reserved/built-in word?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess so, as of 3.10: https://docs.python.org/3/reference/compound_stmts.html#the-match-statement
``skymethod`` parameter to "user". Note that the skylist will be applied on a | ||
per-image basis irrespective of the groups defined in the association, and the | ||
order of the list must match the order of the input images. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious whether this is the desired behavior for asn groups @drlaw1558 @goudfroo
initial round of regression tests started here: https://github.com/spacetelescope/RegressionTests/actions/runs/12656574738 edit: all passing |
cal_model.meta.background.method = "user" # optional
cal_model.meta.background.level = custom_sky_value
cal_model.meta.background.subtracted = False Then save the model and disable sky subtraction step. Actually, you could add |
Thanks for the suggestions Mihai. There's a relevant discussion on the JIRA ticket: https://jira.stsci.edu/browse/JP-1649 This PR follows David Law's suggestion at the bottom: add a "user" option and a parameter encoding a list of sky levels. Let's call that suggestion (0). I think ultimately any of 0, 1, or 2 would work, but they should be documented, including (especially?) if (2) ends up being our suggested workflow. Wondering if @tapastro and @melanieclarke have opinions on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, since it's just a list of floating point values, it's most easily and directly provided via a parameter, as implemented here. Option 0 sounds like the most user friendly to me.
There are several problems with this approach:
|
Jumping in to clarify quickly; the aim of this change is to make it simpler for users to handle the case where backgrounds are complex and hard to match. Specifying particular regions for matching seems like a rabbit hole I'd be reluctant to explore, as it could become arbitrarily complicated. Rather, the intent is for users to measure offset values in whatever complex manner they want outside the pipeline, and for us to then give a simple way within the pipeline of applying those values (rather than hacking cal files). Might a two-element list of [filename, value] deal with the ordering issue? |
Melanie and I discussed this more at our stand-up today. I think we agree with Mihai that it might be good to avoid touching the |
Yes, it might. That is exactly how it works in the |
Here is the alternative that I would propose: https://github.com/spacetelescope/jwst/compare/main...mcara:jwst:add-custom-sky?expand=1 |
I think the concern is, no, it would not be just as easy. It would require a user to understand the structure of an association file. While I agree that it isn't particularly complicated to change, the expectation is usually that the asn files will "just work". With regards to adding 1-2 new keywords to the asn, it could be just as easily argued that there's no harm adding 1-2 new input parameters to skymatch. Plus, step parameters are typically easier for a user to find in the documentation. |
Actually, for |
With the most recent commits I have moved handling for the "user" option out of The new code does exactly what Mihai suggests - it just updates the relevant metadata values in the datamodels and then returns from the step. There is no need to create a SkyImage. With that refactor, it is not necessary to make the I think this is the simplest possible way to support the desired functionality. I think we could decide separately whether to also allow background levels to be defined in the association as is done in Mihai's proposed alternative above. Please do let me know your thoughts everyone! |
Sounds reasonable to me! I'd be inclined to keep this simple and just have the one input method for the time being. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! Simple and clear.
I'll hold off on approving, to make sure we give the science stakeholders a chance to review, but I have only one small question/suggestion below.
Have regression tests been run?
regtests here, rerun just started |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, one more thing - the arguments documentation for skymatch needs to be updated.
Resolves JP-1649
Closes #5262
This PR adds the option to pass in user-defined sky levels to the skymatch step.
Tasks
Build 11.3
(use the latest build if not sure)no-changelog-entry-needed
)changes/
:echo "changed something" > changes/<PR#>.<changetype>.rst
(see below for change types)docs/
pageokify_regtests
to update the truth filesnews fragment change types...
changes/<PR#>.general.rst
: infrastructure or miscellaneous changechanges/<PR#>.docs.rst
changes/<PR#>.stpipe.rst
changes/<PR#>.datamodels.rst
changes/<PR#>.scripts.rst
changes/<PR#>.fits_generator.rst
changes/<PR#>.set_telescope_pointing.rst
changes/<PR#>.pipeline.rst
stage 1
changes/<PR#>.group_scale.rst
changes/<PR#>.dq_init.rst
changes/<PR#>.emicorr.rst
changes/<PR#>.saturation.rst
changes/<PR#>.ipc.rst
changes/<PR#>.firstframe.rst
changes/<PR#>.lastframe.rst
changes/<PR#>.reset.rst
changes/<PR#>.superbias.rst
changes/<PR#>.refpix.rst
changes/<PR#>.linearity.rst
changes/<PR#>.rscd.rst
changes/<PR#>.persistence.rst
changes/<PR#>.dark_current.rst
changes/<PR#>.charge_migration.rst
changes/<PR#>.jump.rst
changes/<PR#>.clean_flicker_noise.rst
changes/<PR#>.ramp_fitting.rst
changes/<PR#>.gain_scale.rst
stage 2
changes/<PR#>.assign_wcs.rst
changes/<PR#>.badpix_selfcal.rst
changes/<PR#>.msaflagopen.rst
changes/<PR#>.nsclean.rst
changes/<PR#>.imprint.rst
changes/<PR#>.background.rst
changes/<PR#>.extract_2d.rst
changes/<PR#>.master_background.rst
changes/<PR#>.wavecorr.rst
changes/<PR#>.srctype.rst
changes/<PR#>.straylight.rst
changes/<PR#>.wfss_contam.rst
changes/<PR#>.flatfield.rst
changes/<PR#>.fringe.rst
changes/<PR#>.pathloss.rst
changes/<PR#>.barshadow.rst
changes/<PR#>.photom.rst
changes/<PR#>.pixel_replace.rst
changes/<PR#>.resample_spec.rst
changes/<PR#>.residual_fringe.rst
changes/<PR#>.cube_build.rst
changes/<PR#>.extract_1d.rst
changes/<PR#>.resample.rst
stage 3
changes/<PR#>.assign_mtwcs.rst
changes/<PR#>.mrs_imatch.rst
changes/<PR#>.tweakreg.rst
changes/<PR#>.skymatch.rst
changes/<PR#>.exp_to_source.rst
changes/<PR#>.outlier_detection.rst
changes/<PR#>.tso_photometry.rst
changes/<PR#>.stack_refs.rst
changes/<PR#>.align_refs.rst
changes/<PR#>.klip.rst
changes/<PR#>.spectral_leak.rst
changes/<PR#>.source_catalog.rst
changes/<PR#>.combine_1d.rst
changes/<PR#>.ami.rst
other
changes/<PR#>.wfs_combine.rst
changes/<PR#>.white_light.rst
changes/<PR#>.cube_skymatch.rst
changes/<PR#>.engdb_tools.rst
changes/<PR#>.guider_cds.rst