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

Fix masking in DayNightCompositor when composites have partial missing data #447

Merged
merged 3 commits into from
Oct 11, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions satpy/composites/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,10 @@ def __call__(self, projectables, **kwargs):
day_data = add_bands(day_data, night_data['bands'])
night_data = add_bands(night_data, day_data['bands'])

# Replace missing channel data with zeros
day_data = zero_missing_data(day_data, night_data)
night_data = zero_missing_data(night_data, day_data)

# Get merged metadata
attrs = combine_metadata(day_data, night_data)

Expand Down Expand Up @@ -919,6 +923,17 @@ def add_bands(data, bands):
return data


def zero_missing_data(data1, data2):
"""Replace NaN values with zeros in data1 if the data is valid in
data2.
"""
nans = xu.logical_and(xu.isnan(data1),
xu.logical_not(xu.isnan(data2)))
data1 = data1.where(~nans, 0)

return data1


class Airmass(GenericCompositor):

def __call__(self, projectables, *args, **kwargs):
Expand Down