-
Notifications
You must be signed in to change notification settings - Fork 300
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
Add an argument to the compositor to switch alpha band on/off in DayNightCompositor #2358
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2358 +/- ##
==========================================
+ Coverage 94.60% 94.64% +0.03%
==========================================
Files 318 324 +6
Lines 47719 48337 +618
==========================================
+ Hits 45146 45747 +601
- Misses 2573 2590 +17
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one inline change to say include_alpha
instead of need_alpha
, but otherwise I have one other question/suggestion:
What if you forced the other data to be NaN in this case instead of 0
(like it is now)? This would mean you'd have to specify fill_value=0
on your save_datasets
call, but I think this is more inline with other composites that Satpy produces...maybe? Put another way, the alpha band would be added during save_datasets
rather than in the compositor.
Co-authored-by: David Hoese <[email protected]>
Yeah I tried that before but didn't work out so I turned to the compositor. It will force an alpha band added to the image and I think that's the reason. Only when it turned off the |
Sorry I wasn't clear. I understand that the existing way the compositor work wasn't working as it was always adding an alpha band. What I'm suggesting is that in this compositor it currently replaces the masked data with 0 making it black. I think when this alpha flag is |
Sorry I got a little confused...
You're talking about these two lines? I could add another IF level for the False flag and make them np.nan. Is that correct? Not quite sure… |
Yeah I think that would work. It might also work to just replace 0 with |
Got it. I’ll finish it tomorrow. Heading to bed now.😁 |
Ah it is because the merging of the day and the night is a multiply and an addition: satpy/satpy/composites/__init__.py Line 750 in fc99734
Doing that with NaN is not going to work. Hhhmm I'm about to go to sleep. I'll have to think about this more. |
What about this? We send |
Whoops… |
The difference you're talking about is how the bottom-right case doesn't "fade" into night time like the alpha=True cases, right? Yeah I think this makes sense. I'm not sure if it will be expected by all users but I think it is the only option if you don't want an alpha channel and also want only day(night) data. @mraspaud @pnuu @gerritholl any opinions on this? |
Yeah that’s what I want to say. |
Anything else I can do to this PR? @mraspaud @pnuu @gerritholl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@yukaribbba thanks for this PR, it looks good to me. However, as @djhoese followed this more closely, I'd like to have his approval before merging this. |
@mraspaud Okay.😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. There is one issue with rendering the docs which I think I've fixed in my other comment. I'll commit that in a second.
Otherwise, my only other concern is something I think you've made the right decision on: the coszen is a value between 0 and 1 so for a day-only case you might want different things masked out. There is the night region, the twilight/mixed region, and the day region. If I say include_alpha=False
do I want the twilight region removed or should it stay in the image? I think it needs to stay in the image which is what I think you've done here. This way it can be overlayed with a night-only image later on and there is no gap in the middle between the two images.
Right?
Well see in my case (a possible future use, not currently doing this) would be having the individual masked day-only and night-only images and then in tiled image viewer (like https://geosphere.ssec.wisc.edu/) I would allow the user to switch the night image but keep the same day image. Generating all those combinations would not be a realistic option. I suppose what you're saying is that since these images would be "blending to black", they'll always have darker night-time transitions than they would if they were combined from the beginning (in satpy). Ya know, I'm OK with having the alpha channel in my images anyway so this probably isn't a realistic problem for me. |
Also, talking about this made me think of #2288 . Now we may have a easier solution.
Considering there could be some unexpected noises on night side, this could be cleaner:
I have tested this recipe and it’s just perfect for me. |
CC @simonrp84 ^ |
Yep. That’s the point. |
Let's merge this and if someone comes up with other use cases that need changes to this implementation we can make additional PRs. Thanks @yukaribbba for putting this together and working with all my requests. |
Oooh, I need to think about this idea, too! |
See #3003 for a continuation of this discussion. I'm now trying to generate the day-only part of RGBs with the night part transparent but without an alpha layer. I can see a use case replacing the night part by black for RGBs mixing solar and terrestrial channels or ratios / differences between solar channels. |
Transparency won't happen without the alpha layer. The "other side" should be |
Pixels set to |
That depends also on the image format. But to be fully pedantic, the image won't have transparency :-) |
This PR is a solution for #2357. It only takes effect in "day only" or "night only" mode.