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

Blank pixels should be set to ... #426

Open
keflavich opened this issue Feb 12, 2024 · 1 comment
Open

Blank pixels should be set to ... #426

keflavich opened this issue Feb 12, 2024 · 1 comment

Comments

@keflavich
Copy link
Contributor

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
@keflavich
Copy link
Contributor Author

relevant commit: keflavich@0054941

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant