Allow ellipse model integration to continue after hitting image edge #2156
+57
−29
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.
In the existing implementation, ellipse integration stops entirely as soon as it steps out of the bounds of the image. Actually, it's slightly more premature than that, since the flux is split across four pixels. This fixed version instead checks each of those four pixels and only adds to their values if they're within bounds.
I added a unit test to check that the residual at the edge of the image is relatively small. For reference, on my install (Linux, py3.13) the mean value is about 0.69, so I set the threshold at 2. With the existing code, it's almost 20.
From the unit test, this what the old and new data - model residuals look like, with vmin, vmax = -5, 5.
Old, with integration stopping at the top edge near the top right corner:


New: