fix: weight oversample_thick/polar/omega per-contribution, not on the running sum#5
Open
gcmullen wants to merge 1 commit into
Open
fix: weight oversample_thick/polar/omega per-contribution, not on the running sum#5gcmullen wants to merge 1 commit into
gcmullen wants to merge 1 commit into
Conversation
oversample_thick/polar/omega multiply the per-pixel running accumulator I by capture_fraction/polar/omega_pixel on every innermost iteration. Since I already holds all prior contributions, each factor re-multiplies earlier contributions on every later iteration, compounding across the subpixel/source/phi/mosaic/thick loops (oversample_thick diverges 2.3x->42x as detector_thicksteps grows 2->25; oversample_omega collapses corr to 0.34). Fold each factor into a per-contribution term before accumulating, matching the intended single weighting (and what the CUDA port does). Default (non-oversample) path is byte-identical.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In the per-pixel accumulation, oversample_thick/polar/omega multiply the running
accumulator I by capture_fraction/polar/omega_pixel on every innermost iteration
(:3026-3028). Since I already holds all prior contributions, each factor
re-multiplies earlier contributions on every later iteration — it compounds
across the subpixel/source/phi/mosaic/thick loops.
Effect
detector_thicksteps goes 2 -> 25 (layer 1's contribution ends up scaled by
cf_1cf_2...*cf_N).
Fix
Fold each factor into a per-contribution term before accumulating:
Verification
is identical to the old I += ...).
Scope
nanoBragg.c, +6/-4, one hunk. No API/CLI change. Proposal for your review.