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 31c4205
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
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.
4 changes: 2 additions & 2 deletions reproject/mosaicking/tests/test_coadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ 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
# We're running this test over a somewhat large grid of paramters, so
# We're running this test over a somewhat large grid of parameters, so
# cut down the array size to avoid increasing the total test runtime
# too much.
slice = np.s_[::3, ::3]
Expand Down

0 comments on commit 31c4205

Please sign in to comment.