-
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
Update resample for new reference file type #8242
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #8242 +/- ##
==========================================
- Coverage 75.18% 75.17% -0.01%
==========================================
Files 470 470
Lines 38547 38485 -62
==========================================
- Hits 28980 28931 -49
+ Misses 9567 9554 -13
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Code-wise this is OK. I'm still having an issue conceptually and will ask this only rhetorically: This seems to be a significant complication to remove a reference file to just then implement a reference-within-a-reference file. If stakeholders are happy with the answer to that, then 👍
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.
A general comment here - there should be no need of special handling of a pars-
file for resample. It is all handled by the default code in stpipe
, just like every other step with a pars-
file. The reftype is automatic as well, as soon as the reference file is delivered to CRDS. One only needs to tear out all the old drizpars reffile junk in the code. I.e. _compute_resample_kwargs()
should be unnecessary.
The logic based on number of input images in rows in the old drizpars fits binary table only really varied pixfrac
:
$ showtable jwst_nircam_drizpars_0001.fits
numimages filter pixfrac kernel fillval wht_type stepsize
--------- ------ ------- ------ ------- -------- --------
1 ANY 1.0 square INDEF exptime 10
2 ANY 1.0 square INDEF exptime 10
4 ANY 0.8 square INDEF exptime 10
but this was never tested or optimized and is from 2006 when resample was first implemented. These are all placeholders. Anything other than pixfrac=1.0
in fact is not actually supported mathematically. It's the equivalent of unsharp mask in Photoshop™. stepsize
is not used, exptime
weighting instead of ivm
ruins the uncertainties in output error arrays and the errors in the source catalogs, and INDEF is meaningless.
How about we make proper, tested input parameter sets as reference files that are not tables and do not depend on number of input images?
I'll add that if there's new pars-
reffile to be delivered, this is an excellent time to get rid of all references to values of "INDEF" in this codebase as well, which have no meaning in Python or the C++ code in drizzle
. See #2219 and #7664.
#8258 Do we have a write-up somewhere (I thought I'd seen it detailed in a github issue discussion from 3+ years ago) explaining this to users? |
Thanks all for looking at this. @hbushouse many of the comments here might be relevant to JP-2682 The ticket mentions that keeping the ability to select parameters based on the number of input files "could be useful" for NIRISS and is awaiting feedback about NIRCam. Is there currently a way to provide the number of input files when selecting a One alternative to the approach in this PR would be to update stpipe to provide the number of input images to the parameters provided to crds during |
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.
So the more I think about this, the less likely it seems that we can accomplish the use of multiple settings for a given param via a pars ref file. Like I said in another comment, stpipe is setup to automatically search for and load a pars ref file for each step and when it reads the pars ref file it's just expecting one value for each defined step parameter and returns whatever values it finds in the Step class instance. No idea how we could ever get it to return a list of values for one or more params, which could then be searched through and selected by the step itself.
kernel = string(default='square') # change back to None when drizpar reference files are updated | ||
fillval = string(default='INDEF' ) # change back to None when drizpar reference files are updated | ||
weight_type = option('ivm', 'exptime', None, default='ivm') # change back to None when drizpar ref update | ||
pixfrac = float(default=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.
Is it really necessary to set all of these defaults to None
in order to have the values from the new pars-resamplestep ref file take effect? I know we have to leave the default values set when the drizpars ref files are in use, because of the odd logic that was in the get_drizpars
function. But the normal order of precedence used in stpipe and jwst should allow values from the pars-resamplestep ref files to override defaults set here in the step spec block. We have plenty of active examples of this. For example, several prototype steps have skip=True
set in the step spec blocks, so that when run on their own they get skipped. But then there are pars ref files in place that override that value and allow the step to execute. So I think those comments about setting all the defaults back to None
only applied to the case where we continue to use the drizpars ref files. We've got to set some sensible defaults for some of these, like pixfrac=1.0 and kernel='square', so that when/if the step is run in the absence of pars-resamplestep ref files, it'll do something sensible (the whole purpose of defaults).
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.
These were set to None
as a way to tell that the parameters were "unset". The _compute_resample_kwargs
function overwrote these parameters only if they were None
(that way if a user provided a value the pars-
file, or the default table in _compute_resample_kwargs
wouldn't overwrite the user provided option).
@@ -58,8 +55,10 @@ class ResampleStep(Step): | |||
blendheaders = boolean(default=True) | |||
allowed_memory = float(default=None) # Fraction of memory to use for the combined image. | |||
in_memory = boolean(default=True) | |||
ref_pars_table = list(default=list()) # parameter 'table' read from pars-resample |
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.
Don't need any of this, as @jdavies-st already mentioned. stpipe automatically goes out and finds and loads an appropriate pars ref file, if one exists, and returns the step argument values from them. Or was this necessary in order to allow for having a list/table of different possible values for the params, based on the number of 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.
Your last sentence is spot on. This was needed because the number of input images is not provided to crds during the pars-
file selection.
Until we're able to sort out how multiple values could be implemented within a pars ref file, I think the thing to do in the meantime is to stick with the use of drizpars, get the instrument teams to deliver updated drizpars with appropriate settings for their instrument modes, and remove the default values that are currently hardwired in the resample_step code so that the drizpars values get used instead. |
@braingram While it doesn't seem feasible to store and retrieve multiple parameter values from a parameter reference file, I'm wondering if there's a way that we could go the slightly less convenient route of having multiple pars ref files in CRDS, with NUM_IMAGES being one of the selection criteria? Many pars ref files currently use selection criteria that are based on meta data in the datamodel being processed (same as regular reference files). So the problem to be worked around in this case is the fact that the number of images being processed is not (currently) a meta attribute in the input datamodel (or ModelContainer) being passed into the resample/resample_spec steps. Given that the primary argument to the stpipe Spec class Any brilliant ideas? Or do we just brute force it by letting the Step instance make the call as it does now, but we ignore the results and call it again explicitly from within the resample_step |
I would argue that having the output resample scale (arcsec per pixel) change or pixel shrinking on the input images before drizzling in standard DMS processing based on number of input images is not what you want. First, you don't know the dither pattern based just on the number of images, and you don't know the science use case. Different dither patterns will sample the pixel phase differently. The number of overlapping images will be different than the number of images in the modelcontainer (NIRCam long vs short), and in the end, anything other than Currently the above drizpars reffile shrinks pixels ( The whole reason people played with The standard pipeline should not assume particular science scenes (stars, galaxies, exoplanets) for general processing, but should produce products that are those that are best understood and best calibrated, and for this, no input pixel shrinking and no pixel scaling in the output make the most sense, as we currently do. Scientists are always free to disagree and reprocess their data with custom pipeline parameters, as they all already do. |
If the goal is to use |
@braingram @jdavies-st Thanks for all of your comments. Given the still semi-difficult and off-nominal procedure that would be needed in order to select pars ref files based on a non-meta attribute like |
This PR:
drizpars
resample reference filepars-resamplestep
drizpars removal
The current
resample
code will only allow the reference files to define the following:However, if any of those values are either defined by the user or have a default value the reference file data will not be used. As all of these values have defaults making the reference file data unused:
jwst/jwst/resample/resample_step.py
Lines 46 to 49 in bddb39c
pars-resample
To add support for
pars-resample
this PR adds a new entry to theResampleStep
spec:and sets the above mentioned parameters to
None
to allow them to be set from thepars-resample
file.As this new file is a
pars-
file, it is read at the creation of the step and sets attributes on the step instance (in this case theref_pars_table
attribute). When the step computeskwargs
to pass to the actual resample code the 'table' in this attribute is used (in a way similar to what was done with thedrizpars
table) to only set values that aren't defined by the user. The code is hopefully commented thoroughly enough to explain the details.Documentation (and the spec comments) will need to be updated before this PR is opened for review.
Resolves JP-nnnn
Closes #
This PR addresses ...
Checklist for maintainers
CHANGES.rst
within the relevant release sectionHow to run regression tests on a PR