Skip to content

Commit

Permalink
Ensure reproject_and_coadd handles bg-matching with one input image
Browse files Browse the repository at this point in the history
  • Loading branch information
svank committed Nov 20, 2023
1 parent a02c082 commit 0b6fab2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion reproject/mosaicking/coadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def reproject_and_coadd(
arrays.append(array)

# If requested, try and match the backgrounds.
if match_background:
if match_background and len(arrays) > 1:
offset_matrix = determine_offset_matrix(arrays)
corrections = solve_corrections_sgd(offset_matrix)
if background_reference:
Expand Down
27 changes: 27 additions & 0 deletions reproject/mosaicking/tests/test_coadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,33 @@ def test_coadd_background_matching(self, reproject_function):

assert_allclose(array - np.mean(array), self.array - np.mean(self.array), atol=ATOL)

def test_coadd_background_matching_one_array(self, reproject_function):
# Test that background matching doesn't affect the output when there's
# only one input image.

input_data = [(self.array, self.wcs)]

array_matched, footprint_matched = reproject_and_coadd(
input_data,
self.wcs,
shape_out=self.array.shape,
combine_function="mean",
reproject_function=reproject_function,
match_background=True,
)

array, footprint = reproject_and_coadd(
input_data,
self.wcs,
shape_out=self.array.shape,
combine_function="mean",
reproject_function=reproject_function,
match_background=False,
)
np.testing.assert_allclose(array, array_matched)
np.testing.assert_allclose(footprint, footprint_matched)


def test_coadd_background_matching_with_nan(self, reproject_function):
# Test out the background matching when NaN values are present. We do
# this by using three arrays with the same footprint but with different
Expand Down

0 comments on commit 0b6fab2

Please sign in to comment.