Skip to content

Blank pixels should be set to ... #426

Closed
@keflavich

Description

@keflavich

Before #413, pixels that were not covered by the footprint were set to nan, and they are now set to zero.

31c4205

I have a lot of code that relied on the nan behavior, even though it apparently only affected the mean combination, so this was a major behavior change from my side.

I recommend we make the blank pixel value explicit and user-specifiable. I have a commit that suggests that, but I'm experiencing network issues, so I'll just paste the diff here:

--- a/reproject/mosaicking/coadd.py
+++ b/reproject/mosaicking/coadd.py
@@ -26,6 +26,7 @@ def reproject_and_coadd(
     output_footprint=None,
     block_sizes=None,
     progressbar=False,
+    blank_pixel_value=np.nan,
     **kwargs,
 ):
     """
@@ -337,7 +338,7 @@ def reproject_and_coadd(
         if combine_function == "mean":
             with np.errstate(invalid="ignore"):
                 output_array /= output_footprint
-                output_array[output_footprint == 0] = 0
+                output_array[output_footprint == 0] = blank_pixel_value

     elif combine_function in ("first", "last", "min", "max"):
         if match_background:
@@ -369,7 +370,6 @@ def reproject_and_coadd(
         # this is redundant, but left as a note-to-devs about where such an implementation belongs
         raise NotImplementedError("combine_function='median' is not yet implemented")

-    if combine_function in ("min", "max"):
-        output_array[output_footprint == 0] = 0.0
+    output_array[output_footprint == 0] = blank_pixel_value

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions