Skip to content
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

DM-8982: Incorrect binning in overscan spline interpolation #25

Merged
merged 2 commits into from
Jan 13, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion python/lsst/ip/isr/isr.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ def overscanCorrection(ampMaskedImage, overscanImage, fitType='MEDIAN', order=1,
diff = numpy.abs(biasArray - medianBiasArr[:, numpy.newaxis])
biasMaskedArr = numpy.ma.masked_where(diff > collapseRej*stdevBiasArr[:, numpy.newaxis], biasArray)
collapsed = numpy.mean(biasMaskedArr, axis=1)
if collapsed.mask.sum() > 0:
collapsed.data[collapsed.mask] = numpy.mean(biasArray.data[collapsed.mask], axis=1)
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize you are adding the original values back into the masked pixels in order to plot them below, but might this be a gotcha for anyone later using collapsed.data and expecting the non-modified values? I'm not familiar with the object here, so am not sure what the masked pixels would've been assigned in collapsed.data, so forgive my naïveté if this is a non-issue!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this change, the masked pixels have a value of zero and are therefore useless.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's sort of my point, i.e. someone expecting a value of zero in collapsed.data for masked pixels (I don't imagine a use case here...but you never know!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know why someone would want a zero value for masked pixels, except for my particular use of this below! I use collapsed.data*~collapsedMask, which provides exactly that (collapsedMask is True for bad pixels). So the possibility is still there just in case.

del biasArray, percentiles, stdevBiasArr, diff, biasMaskedArr

if shortInd == 0:
Expand Down Expand Up @@ -398,7 +400,9 @@ def overscanCorrection(ampMaskedImage, overscanImage, fitType='MEDIAN', order=1,
figure = plot.figure(1)
figure.clear()
axes = figure.add_axes((0.1, 0.1, 0.8, 0.8))
axes.plot(indices, collapsed, 'k+')
axes.plot(indices[~collapsedMask], collapsed[~collapsedMask], 'k+')
if collapsedMask.sum() > 0:
axes.plot(indices[collapsedMask], collapsed.data[collapsedMask], 'b+')
axes.plot(indices, fitBiasArr, 'r-')
figure.show()
prompt = "Press Enter or c to continue [chp]... "
Expand Down