astropy / reproject

Python-based Astronomical image reprojection :milky_way: - maintainer @astrofrog
https://reproject.readthedocs.io
BSD 3-Clause "New" or "Revised" License
106 stars 66 forks source link

Fixes for mosaic output pixels not covered by inputs #413

Closed svank closed 9 months ago

svank commented 10 months ago

I noticed that, when using reproject_and_coadd with background matching and with combine_function='first', a bounding box around some of the input images can be filled, so that outputs look like this: image instead of this: image

This happens because output pixels not covered by a given input image are set to zero after that image is reprojected, and those zero values get adjusted by the background matching. For the other combine_function options, those out-of-bounds pixels never get used, so their final value doesn't matter, but that wasn't the case for combine_function='first', which this PR rectifies.

While adding a test that works through the options and ensures the final output mosaics are zero outside the returned footprint and filled-in inside the footprint, I noticed an inconsistency in that all the combine_functions produce zeros for pixels not spanned by any input image, except for combine_function='mean', which outputs nans for those unsampled pixels (generated when dividing by sum-of-weight values of zero). This PR also changes those nans to 0, to ensure mean is consistent with the other modes.

codecov[bot] commented 10 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (f9bcc9e) 93.60% compared to head (31c4205) 93.60%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #413 +/- ## ======================================= Coverage 93.60% 93.60% ======================================= Files 25 25 Lines 891 892 +1 ======================================= + Hits 834 835 +1 Misses 57 57 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.