Skip to content

#1352 Fix two bugs related to photon flux normalization when there are negative-flux photons. - #1378

Open
rmjarvis wants to merge 4 commits into
releases/2.8from
#1352
Open

rmjarvis wants to merge 4 commits into
releases/2.8from
#1352

Conversation

@rmjarvis

Copy link
Copy Markdown
Member

@aguinot reported a bug when using a Sum with OpticalPSF and photon shooting. The flux normalization was coming out wrong.

The underlying bug was a line in Sum._shoot that implicitly assumed the photons all had positive flux, which is not normally true for profiles that uses an InterpolatedImage (which is part of the implementation of OpticalPSF). Some photons need to be negative flux, so the line that applied a normalization needs to preserve the sign of the photon's flux.

When writing the tests for this, I uncovered a different, unrelated bug in InterpolatedImage. This was more subtle, but basically the flux normalization in the C++ layer used the wrong value for the totalAbsFlux. It used the sum of the positive and negative absolute fluxes after applying the interpolation kernel, which is wrong. Then we had a line in the python layer that corrected for this, but in a way that only worked if the pixel values used for the InterpolatedImage are all positive. Usually that's true, but it's not required (e.g. if using a noisy image for the base image).

If some pixel values are negative, then the flux normalization came out wrong. Very badly so for the test I wrote for the sum test where I had one component be all negative pixels. So this PR includes a fix for that bug too.

@rmjarvis rmjarvis added this to the v2.8 milestone Nov 12, 2026
@rmjarvis rmjarvis added numerics Involving details of the numerical algorithms for performing some calculation(s) bug report Bug report labels Nov 12, 2026
@rmjarvis
rmjarvis requested a review from aguinot November 12, 2026 01:29

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug report Bug report numerics Involving details of the numerical algorithms for performing some calculation(s)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant