-
Notifications
You must be signed in to change notification settings - Fork 180
JP-1649: Add option for user-defined sky levels in skymatch #9053
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9053 +/- ##
==========================================
+ Coverage 76.92% 76.94% +0.01%
==========================================
Files 498 498
Lines 45810 45844 +34
==========================================
+ Hits 35240 35273 +33
- Misses 10570 10571 +1
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
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 = FalseThen 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. |
melanieclarke
left a comment
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 |
mcara
left a comment
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 just noticed that skylist is actually a list and not a text file. I wonder how will this work for very long lists, like 100s. One has to be extremely careful not to swap the order of values or files. If one decides to edit the list of input files and remove a (==one) problematic image from the ASN, how easy it will be to edit this skylist. I simply think this approach is too error-prone.
Personally, I do not like this approach but ultimately it is up to you, @drlaw1558 and @melanieclarke @tapastro . But I just cannot approve this in the current form.
I think for the very least skylist could be (or could be allowed to be) a text file with two columns: filename, skyval.
|
The current implementation doesn't allow providing a list using |
kmacdonald-stsci
left a comment
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.
Looks good to me and I have nothing more to add than what Mihai commented.
For a similar change for tweaking offsets in cube building, we decided to go with an ASDF file as input, listing filenames, RA, and Dec offsets. For consistency, perhaps we should do that here too? |
There are other places in the code (e.g., custom catalog in tweakreg) that require a text file. So regardless of the format it would be consistent with some other steps and inconsistent with others. Happy to make it ASDF if that's what you want to do though. |
I don't have a strong preference -- I think both approaches have drawbacks. It might be useful to consider in the future a more general policy on how we take input for pipeline steps like this. For the filename matching, if the step is run in the middle of a pipeline, which filename is it looking for? The suffix from the step immediately prior to skymatch, or input file suffix? |
Right now it looks for |
Is ASDF file easier for the users than a standard text file? What is the advantage? I would have to look at cube builder to see an example, I guess. Why not just do it in ASN (and skyfile as well, why not)? In tweakreg step catalogs can be provided either via ASN or a simple text file. Wouldn't ASDF make the user learn the structure of the ASDF files? |
Yes, ASDF is more complex and requires more work on the user's part. The advantage is that you can store more complicated structures and that you can validate it. I'm not advocating for it here, but I do think we should start thinking about how we manage input from users more consistently across the pipeline steps. I have no problem with supporting sky values in the ASN file as well, especially if we are using tweakreg as a model for how users provide override inputs in image3. |
I'm not sure I see the advantage of supporting two different ways to define the same background levels. If we allow this to be passed as a parameter or as part of the asn, then we need to:
I already find the way tweakreg does the sky catalog to be perhaps slightly overcomplicated. I also don't quite see the appeal of modifying asn files after they are created in order to do this. Yes, it's a way to keep the filename and the sky level next to each other, but so is a two-column text file and in my experience it's easier to create the latter. If that's what is desired by the various stakeholders I'll happily code it or modify what Mihai already sent earlier, but the original suggestion on the ticket of how this should be implemented is closer to the current solution than to the pass-as-asn solution. |
|
rerunning regtests again https://github.com/spacetelescope/RegressionTests/actions/runs/12656574738 |
I agree that implementing pass-as-asn goes a bit beyond what is currently requested. I suggest we go with the text file solution for now, and I will file a ticket to examine how we take user input for pipeline steps that does not fit neatly into simple parameters. Update: ticket is here: https://jira.stsci.edu/browse/JP-3850 |
melanieclarke
left a comment
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 this is ready to go now. Thanks for all the useful discussions, everyone, and for all the updates, Ned.
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_regteststo update the truth filesnews fragment change types...
changes/<PR#>.general.rst: infrastructure or miscellaneous changechanges/<PR#>.docs.rstchanges/<PR#>.stpipe.rstchanges/<PR#>.datamodels.rstchanges/<PR#>.scripts.rstchanges/<PR#>.fits_generator.rstchanges/<PR#>.set_telescope_pointing.rstchanges/<PR#>.pipeline.rststage 1
changes/<PR#>.group_scale.rstchanges/<PR#>.dq_init.rstchanges/<PR#>.emicorr.rstchanges/<PR#>.saturation.rstchanges/<PR#>.ipc.rstchanges/<PR#>.firstframe.rstchanges/<PR#>.lastframe.rstchanges/<PR#>.reset.rstchanges/<PR#>.superbias.rstchanges/<PR#>.refpix.rstchanges/<PR#>.linearity.rstchanges/<PR#>.rscd.rstchanges/<PR#>.persistence.rstchanges/<PR#>.dark_current.rstchanges/<PR#>.charge_migration.rstchanges/<PR#>.jump.rstchanges/<PR#>.clean_flicker_noise.rstchanges/<PR#>.ramp_fitting.rstchanges/<PR#>.gain_scale.rststage 2
changes/<PR#>.assign_wcs.rstchanges/<PR#>.badpix_selfcal.rstchanges/<PR#>.msaflagopen.rstchanges/<PR#>.nsclean.rstchanges/<PR#>.imprint.rstchanges/<PR#>.background.rstchanges/<PR#>.extract_2d.rstchanges/<PR#>.master_background.rstchanges/<PR#>.wavecorr.rstchanges/<PR#>.srctype.rstchanges/<PR#>.straylight.rstchanges/<PR#>.wfss_contam.rstchanges/<PR#>.flatfield.rstchanges/<PR#>.fringe.rstchanges/<PR#>.pathloss.rstchanges/<PR#>.barshadow.rstchanges/<PR#>.photom.rstchanges/<PR#>.pixel_replace.rstchanges/<PR#>.resample_spec.rstchanges/<PR#>.residual_fringe.rstchanges/<PR#>.cube_build.rstchanges/<PR#>.extract_1d.rstchanges/<PR#>.resample.rststage 3
changes/<PR#>.assign_mtwcs.rstchanges/<PR#>.mrs_imatch.rstchanges/<PR#>.tweakreg.rstchanges/<PR#>.skymatch.rstchanges/<PR#>.exp_to_source.rstchanges/<PR#>.outlier_detection.rstchanges/<PR#>.tso_photometry.rstchanges/<PR#>.stack_refs.rstchanges/<PR#>.align_refs.rstchanges/<PR#>.klip.rstchanges/<PR#>.spectral_leak.rstchanges/<PR#>.source_catalog.rstchanges/<PR#>.combine_1d.rstchanges/<PR#>.ami.rstother
changes/<PR#>.wfs_combine.rstchanges/<PR#>.white_light.rstchanges/<PR#>.cube_skymatch.rstchanges/<PR#>.engdb_tools.rstchanges/<PR#>.guider_cds.rst