-
Notifications
You must be signed in to change notification settings - Fork 2
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
Ewm8086 remove background by smoothing before cross-correlation #505
Conversation
fb0ad87
to
229ae09
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #505 +/- ##
==========================================
+ Coverage 95.57% 95.76% +0.19%
==========================================
Files 68 68
Lines 5086 5081 -5
==========================================
+ Hits 4861 4866 +5
+ Misses 225 215 -10 ☔ View full report in Codecov by Sentry. |
27dbf93
to
07bc638
Compare
9728ac3
to
5500cd9
Compare
self.overallDMin: float = min(dMin) | ||
self.overallDMax: float = max(dMax) | ||
self.dBin: float = max([abs(d) for d in dBin]) | ||
self.dBin: float = min([abs(d) for d in dBin]) |
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.
Note: this line satisfies one of the acceptance criteria
scale_num = sum(y_new) / len(y_new) | ||
|
||
y_new = y_new - (scale_num / scale_denom) * y_smooth | ||
y_new[y_new < 0] = 0 |
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.
Note: this line satisfies one of the acceptance criteria
0113861
to
c187354
Compare
MERGE AFTER PR #523 |
c187354
to
7f4a20c
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.
Tested and remove background works correctly.
Description of work
This improves
RemoveEventBackground
, and renames it toRemoveSmoothedBackground
Explanation of work
It was determined that inside each group, an averaged background can be calculated by averaging all the spectra in that group then using SmoothDataExcludingPeaks to make a group average background.
This background is subtracted from each individual spectra in the group so that only the peaks remain. After the subtraction, all negatives are zeroed out.
To prevent complications from weak pixels, the background is suitably scaled prior to subtraction, with the scale factor determined by the mean values across the averaged and individual spectra. This step is crucial in keeping peaks in pixels with very weak signal.
To test
Dev testing
You will need an otherwise good calibration run with high background. I suggest 58882.
Run without remove background, and at tweak peak take a screen shot of the graphs. Also look at the mask workspace (
diffract_consts_mask_58882
), and note how many bins are masked.Run with remove background (note: you may have to clear all the workspaces for this to happen). Compare the new graphs at tweak peak. Notice the lumpy background is gone, with much sharper peaks.
Check masks. Fewer pixels have been masked. Complete the workflow and save.
CIS testing
First, run the script
check_remove.py
. This tests the background removal algorithm only. Inspect the workspacespeaks_extractDSP_before
andpeaks_extractDSP_after
, and their focused counterparts (+_foc
). Make sure everything is as expected.Next, run the script
cc-and-smooth.py
. This mirrors SNAPRed's cross-correlation process, including both the group-by-group cross-correlation and the convergence by median offset. This tests three different ways of removing the background. The ones of interest will have the prefix "total" and "peaks". Look at the CC result (+_cc
), the offsets, the before and after, etc.Finally, run
diffcal_pixel_diffraction_background_subtraction_script.py
. This will run SNAPRed's PixelDiffCalRecipe with background removal turned on. Inspect the results.Link to EWM item
EWM#8086
Verification
Acceptance Criteria
This list is for ease of reference, and does not replace reading the EWM story as part of the review. Verify this list matches the EWM story before reviewing.