Skip to content

Keep signed photon weights in Sum._shoot (#1352) - #1364

Open
shaneraphel wants to merge 2 commits into
GalSim-developers:releases/2.8from
shaneraphel:fix-1352-sum-opticalpsf-photon-flux
Open

shaneraphel wants to merge 2 commits into
GalSim-developers:releases/2.8from
shaneraphel:fix-1352-sum-opticalpsf-photon-flux

Conversation

@shaneraphel

@shaneraphel shaneraphel commented Sep 15, 2026

Copy link
Copy Markdown

Fixes #1352.

Sum._shoot assigns each photon to a component, calls that component's _shoot, then overwrites temp.flux with the unsigned weight (positive_flux + negative_flux) / n. ChromaticSum._shoot already copies the component array without that assignment.

That overwrite is an identity for profiles with negative_flux = 0 (Gaussian, Moffat). OpticalPSF is an InterpolatedImage with ringing, so positive_flux + negative_flux is larger than flux (here 1.584 on GalSim 2.8.5, Roman J129). Used as a photon_ops PSF, the unsigned overwrite inflates the drawn flux.

Labeled check on GalSim 2.8.5, Roman J129, n_photons=1000, nx=51, poisson_flux=False, seed 42, Add([OpticalPSF, OpticalPSF])/2:

path image sum / true flux
achromatic Sum (current) 1.565
same dest with the overwrite removed 0.983
ChromaticSum of ChromaticOpticalPSF 1.057

A Gaussian Sum drawn as the object (method='phot') stays flux-faithful with or without the line (0.955 vs 0.956 on a 33² stamp). Existing Gaussian do_shoot coverage should keep passing.

This is a software routing identity with ChromaticSum, not a claim about telescope optics.

AI: a compiled language model drafted the one-line dest (0 gradient-descent training steps). I reviewed the source sibling and the flux lattice before opening this PR.

After each component _shoot, Sum was assigning fluxPerPhoton from the
unsigned (positive+negative) weight. ChromaticSum already keeps the
component fluxes, which OpticalPSF InterpolatedImage needs because of
ringing. Fixes GalSim-developers#1352.

Co-authored-by: Cursor <cursoragent@cursor.com>
@shaneraphel
shaneraphel changed the base branch from main to releases/2.8 September 15, 2026 03:14
@rmjarvis rmjarvis closed this Sep 15, 2026
@rmjarvis rmjarvis reopened this Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error in the flux when summing achromatic opticalPSF using photon shooting

2 participants