-
Notifications
You must be signed in to change notification settings - Fork 20
DM-53418: Further robustify the pedestal background subtraction in calibrateImage #1197
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
e70d7eb to
2a0c73f
Compare
bb4b5b6 to
fd4adfa
Compare
| # start an iteration with a small bin size, then double it on each | ||
| # iteration until the relative or absolute change criterion is met. | ||
| # If those are never achieved, the iteration stops when the bin size | ||
| # gets bigger than the exposure's bounding box. |
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 comment should be moved up to line 2036?
| self.log.info("Initial pedestal binSize = %d pixels", pedestalBackgroundConfig.binSize) | ||
| inPedestalIteration = True | ||
| cumulativePedestalLevel = 0.0 | ||
| relativeStoppingCriterion = 0.05 # Relative change in cumulative pedestal value. |
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 should have a longer comment (above it): "When the cumulative pedestal value changes by less than 5% from one bin size to the next we assume we are converged"
| inPedestalIteration = True | ||
| cumulativePedestalLevel = 0.0 | ||
| relativeStoppingCriterion = 0.05 # Relative change in cumulative pedestal value. | ||
| absoluteStoppingCriterion = 0.5 # Absolute change in cumulative pedestal value. |
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 should have a longer comment (above it): "When the cumulative pedestal value changes by less than 0.5 counts (electrons or adu) from one bin size to the next, we assume we are converged".
Meanwhile, is this the right convergence amount? Seems larger than I would naively expect, but you've run the numbers.
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.
Yeah, in all my testing, any smaller than this and it just started bouncing around at each iteration (which is what this is trying to avoid).
| pedestalBackgroundLevel, cumulativePedestalLevel, | ||
| relativeDelta, absoluteDelta) | ||
| if (relativeDelta > relativeStoppingCriterion | ||
| and absoluteDelta > absoluteStoppingCriterion): |
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 logic as it is written is hard to parse. Would it be clearer if it was (somewhat):
if relativeDelta < relativeStoppingCriterion or absoluteDelta < absoluteStoppingCriterion:
# We are converged
inPedestalIteration = False
else:
# We have not yet converged; grow the bin size if possible.
if binsize < blah:
binsize = newbinsize
log.info
# (No need to set this to True again)
else:
# We have reached the maximum binsize.
log.warning
inPedestalIteration = False
This adds an extra safeguard on the pedestal background measurement by adding an iteration on the measurement, increasing (doubling) the bin size at each stage. The bin size starts very small and there is at least one iteration. The stopping criterion is if either the change in the cumulative pedestal between the current and subsequent level is less than 5% of the current measured (cumulative) pedestal (relative change) or 0.5 "counts" (absolute change) or if the bin size has reached a value greater than the size of the exposure's bounding box.
fd4adfa to
7eccbd0
Compare
No description provided.