Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure reproject_and_coadd handles bg-matching with one input image #412

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
26 changes: 26 additions & 0 deletions reproject/mosaicking/tests/test_coadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,32 @@ 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
Loading