Skip to content

Commit

Permalink
Ensure "empty" output pixels come out as 0, not nan, for "mean" moasic
Browse files Browse the repository at this point in the history
  • Loading branch information
svank authored and astrofrog committed Dec 8, 2023
1 parent e46fbd7 commit 059aeb5
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions reproject/mosaicking/coadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ def reproject_and_coadd(
if combine_function == "mean":
with np.errstate(invalid="ignore"):
output_array /= output_footprint
output_array[output_footprint == 0] = 0

elif combine_function in ("first", "last", "min", "max"):
for array in arrays:
Expand Down
Binary file modified reproject/mosaicking/tests/reference/test_coadd_solar_map.fits
Binary file not shown.
2 changes: 1 addition & 1 deletion reproject/mosaicking/tests/test_coadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def test_coadd_background_matching_one_array(self, reproject_function):
np.testing.assert_allclose(array, array_matched)
np.testing.assert_allclose(footprint, footprint_matched)

@pytest.mark.parametrize("combine_function", ["first", "last", "min", "max", "sum"])
@pytest.mark.parametrize("combine_function", ["first", "last", "min", "max", "sum", "mean"])
@pytest.mark.parametrize("match_background", [True, False])
def test_footprint_correct(self, reproject_function, combine_function, match_background):
# Test that the output array is zero outside the returned footprint
Expand Down

0 comments on commit 059aeb5

Please sign in to comment.