Skip to content

Commit

Permalink
bugfix, but leaves open a question: do the min/max first/last make se…
Browse files Browse the repository at this point in the history
…nse with background matching?
  • Loading branch information
keflavich committed Dec 3, 2023
1 parent 318763b commit d1319d1
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions reproject/mosaicking/coadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ def reproject_and_coadd(

if combine_function in ("mean", "sum"):
if match_background:
# if we're not matching the background, this part has already been done
for array in arrays:
# By default, values outside of the footprint are set to NaN
# but we set these to 0 here to avoid getting NaNs in the
Expand All @@ -338,27 +339,28 @@ def reproject_and_coadd(
output_array /= output_footprint

elif combine_function in ("first", "last", "min", "max"):
for array in arrays:
if combine_function == "first":
mask = output_footprint[array.view_in_original_array] == 0
elif combine_function == "last":
mask = array.footprint > 0
elif combine_function == "min":
mask = (array.footprint > 0) & (
array.array < output_array[array.view_in_original_array]
if match_background:
for array in arrays:
if combine_function == "first":
mask = output_footprint[array.view_in_original_array] == 0
elif combine_function == "last":
mask = array.footprint > 0
elif combine_function == "min":
mask = (array.footprint > 0) & (

Check warning on line 349 in reproject/mosaicking/coadd.py

View check run for this annotation

Codecov / codecov/patch

reproject/mosaicking/coadd.py#L343-L349

Added lines #L343 - L349 were not covered by tests
array.array < output_array[array.view_in_original_array]
)
elif combine_function == "max":
mask = (array.footprint > 0) & (

Check warning on line 353 in reproject/mosaicking/coadd.py

View check run for this annotation

Codecov / codecov/patch

reproject/mosaicking/coadd.py#L352-L353

Added lines #L352 - L353 were not covered by tests
array.array > output_array[array.view_in_original_array]
)

output_footprint[array.view_in_original_array] = np.where(

Check warning on line 357 in reproject/mosaicking/coadd.py

View check run for this annotation

Codecov / codecov/patch

reproject/mosaicking/coadd.py#L357

Added line #L357 was not covered by tests
mask, array.footprint, output_footprint[array.view_in_original_array]
)
elif combine_function == "max":
mask = (array.footprint > 0) & (
array.array > output_array[array.view_in_original_array]
output_array[array.view_in_original_array] = np.where(

Check warning on line 360 in reproject/mosaicking/coadd.py

View check run for this annotation

Codecov / codecov/patch

reproject/mosaicking/coadd.py#L360

Added line #L360 was not covered by tests
mask, array.array, output_array[array.view_in_original_array]
)

output_footprint[array.view_in_original_array] = np.where(
mask, array.footprint, output_footprint[array.view_in_original_array]
)
output_array[array.view_in_original_array] = np.where(
mask, array.array, output_array[array.view_in_original_array]
)

elif combine_function == "median":
# Here we need to operate in chunks since we could otherwise run
# into memory issues
Expand Down

0 comments on commit d1319d1

Please sign in to comment.