Skip to content

Commit

Permalink
Added unit test for output array specification in coadd
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Sep 11, 2023
1 parent aff1ab4 commit 097327f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 0 additions & 2 deletions reproject/mosaicking/coadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ def reproject_and_coadd(
# up memory usage. We could probably still have references to array
# objects, but we'd just make sure these were memory mapped

# TODO: add support for specifying output array

# Validate inputs

if combine_function not in ("mean", "sum", "median", "first", "last", "min", "max"):
Expand Down
25 changes: 25 additions & 0 deletions reproject/mosaicking/tests/test_coadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,31 @@ def test_coadd_with_overlap(self, reproject_function):

assert_allclose(array, self.array, atol=ATOL)

def test_coadd_with_outputs(self, tmp_path, reproject_function):
# Test the options to specify output array/footprint

input_data = self._get_tiles(self._overlapping_views)

output_array = np.memmap(
tmp_path / "array.np", mode="w+", dtype=float, shape=self.array.shape
)
output_footprint = np.memmap(
tmp_path / "footprint.np", mode="w+", dtype=float, shape=self.array.shape
)

array, footprint = reproject_and_coadd(
input_data,
self.wcs,
shape_out=self.array.shape,
combine_function="mean",
reproject_function=reproject_function,
output_array=output_array,
output_footprint=output_footprint,
)

assert_allclose(output_array, self.array, atol=ATOL)
assert_allclose(output_footprint, footprint, atol=ATOL)

@pytest.mark.parametrize("combine_function", ["first", "last", "min", "max"])
def test_coadd_with_overlap_first_last(self, reproject_function, combine_function):
views = self._overlapping_views
Expand Down

0 comments on commit 097327f

Please sign in to comment.