-
Notifications
You must be signed in to change notification settings - Fork 171
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-1657: Make ivm default weight_type for resample #5738
JP-1657: Make ivm default weight_type for resample #5738
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5738 +/- ##
==========================================
+ Coverage 75.92% 75.95% +0.02%
==========================================
Files 406 406
Lines 36255 36254 -1
==========================================
+ Hits 27528 27536 +8
+ Misses 8727 8718 -9
*This pull request uses carry forward flags. Click here to find out more.
Continue to review full report at Codecov.
|
971becd
to
d151abe
Compare
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.
Did you ever figure out why the current WHT arrays looked like they had Poisson noise included, even though it was supposed to be weighting by only exptime?
@@ -164,8 +163,7 @@ def do_drizzle(self): | |||
inwht = resample_utils.build_driz_weight(img, | |||
weight_type=self.weight_type, | |||
good_bits=self.good_bits) | |||
driz.add_image(img.data, img.meta.wcs, inwht=inwht, | |||
expin=img.meta.exposure.exposure_time) |
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 given that exptime is still an allowed choice for weighting (just no longer the default), what happens when someone selects exptime but the exposure_time is no longer being passed to the lower-level functions?
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.
Ah, good catch. Let me look at my unit tests and see what I missed.
That raises the larger question, should we even allow exposure time to be used? It clearly gives the wrong answer for multi-read up-the-ramp data, so maybe it should just be completely removed?
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 what's the verdict here? Does it still work when selecting "exptime" weighting?
jwst/resample/resample_utils.py
Outdated
# elif weight_type == 'ivm': | ||
# _inwht = img.buildIVMmask(chip._chip,dqarr,pix_ratio) | ||
if weight_type == 'ivm': | ||
with np.errstate(divide="ignore", invalid="ignore"): |
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.
Ooh, nice. I have to remember to use this in the future.
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.
Yes, useful! Though it has it's pitfalls. I only did it after I made sure the arrays looked how I expected them to, as the warning messages were telling me something. For instance, dividing by zero variance produced np.inf
, but the original code here that used np.nan_to_num
then turned that np.inf
into:
In [2]: np.nan_to_num(np.inf)
Out[2]: 1.7976931348623157e+308
which is clearly wrong. Hence the call below to np.isfinite
.
from jwst.assign_wcs import AssignWcsStep | ||
from jwst.extract_2d import Extract2dStep | ||
from jwst.resample import ResampleSpecStep, ResampleStep | ||
|
||
@pytest.fixture | ||
def nirspec_rate(): | ||
shape = (2048, 2048) | ||
ysize = 2048 |
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.
Hey, I thought we were supposed to keep test images small?!
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 needs to stay large because it is NIRSpec for some reason? I didn't change it from the original test that was put here (not by me). It still runs fast, because it is not doing any jump detection or ramp fitting.
As mentioned above, some of our input regression test data is very old and predates the population of Without mocking it up, the |
Yes, and it turns out that got fixed in the 0.17.x releases. 🙄 |
d151abe
to
de2c78d
Compare
Yes, I guess we'll need to fix the input files to the regtests by just adding some generic readnoise value. The simulated NRS data we get from the team is already in the form of a countrate image (equivalent to rate file) and hence it doesn't go through caldetector1 or ramp_fit to get |
0358737
to
b2dd930
Compare
As you suggested, perhaps it would be best to check if the array exists. If it doesn't then use weight of 1 for everything and emit a warning. This would be a more general purpose solution that chasing down all our data that doesn't have a |
So, for datasets that start Also, at this point, it also has NaNs in it due scaling by the flat (I assume, which introduces the NaNs), so it's a mess - a combination of zeros and NaNs. Will think on this a bit more and find a solution. |
069bd29
to
a04b82c
Compare
So the solution is to raise a |
I have updated the rate.fits files in our nightly regression tests that are old enough to not have This PR is done. Next step is to figure out what goes into the |
Given that JP-1567 was really just concerned with turning on IVM weighting, which this PR accomplishes, I wonder if it would be cleanest to also close JP-1567 and start a new ticket to continue the discussion of how to create an ERR array in resampled products. They really are 2 different things (as you've explained to me). |
00ecb35
to
c283048
Compare
Well, it turns out raising errors in |
This adds
weight_type="ivm"
as the default weight scheme forResampleStep
.This will obviously cause changes in the _s2d.fits, _i2d.fits, _x1d.fits and _cat.ecsv outputs in our regression tests. Further, some of the input _rate.fits files (NIRSpec MOS) do not have
var_rnoise
, so when it is accessed, it is all zeros, which gives zero weight to everything in the output. So those will have to have dummyvar_rnoise
arrays added to the input files.Resolves #800 / JP-1657