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

Conversation

pnuu
Copy link
Member

@pnuu pnuu commented Oct 8, 2018

If one of the two composites passed to DayNightCompositor has partially missing data the resulting merged composite had holes at those locations. This discrepancy between the composites can be e.g. due to reflectances below zero on the night side being masked out by the reader. This behavior can be correct for other use cases, but here it creates distracting holes in the images.

This PR replaces the masked ares with zeros if they are valid in the other composite.

  • Tests added
  • Tests passed
  • Passes git diff origin/master **/*py | flake8 --diff

@coveralls
Copy link

coveralls commented Oct 8, 2018

Coverage Status

Coverage increased (+0.3%) to 73.33% when pulling 5134681 on bugfix-DNC-masking into 75e8cb8 on master.

@codecov
Copy link

codecov bot commented Oct 8, 2018

Codecov Report

Merging #447 into master will decrease coverage by 0.21%.
The diff coverage is 16.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #447      +/-   ##
==========================================
- Coverage   73.07%   72.86%   -0.22%     
==========================================
  Files         134      134              
  Lines       17662    17871     +209     
==========================================
+ Hits        12907    13022     +115     
- Misses       4755     4849      +94
Impacted Files Coverage Δ
satpy/composites/__init__.py 32.64% <16.66%> (-0.15%) ⬇️
satpy/tests/test_readers.py 98.82% <0%> (+0.3%) ⬆️
satpy/readers/eps_l1b.py 18.29% <0%> (+0.48%) ⬆️
satpy/tests/reader_tests/test_hdf5_utils.py 93.47% <0%> (+0.94%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 75e8cb8...5134681. Read the comment docs.

nans = xu.logical_and(xu.isnan(data1),
xu.logical_not(xu.isnan(data2)))
attrs = data1.attrs.copy()
data1 = xr.where(nans, 0, data1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does using data1.where(~nans, 0) preserve the attributes?

xu.logical_not(xu.isnan(data2)))
attrs = data1.attrs.copy()
data1 = xr.where(nans, 0, data1)
data1.attrs = attrs.copy()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are copying the attributes dictionary twice.

@pnuu
Copy link
Member Author

pnuu commented Oct 10, 2018

Indeed, that data1.where(~nans, 0) kept the attributes intact. Updated accordingly. Thanks @djhoese!

Copy link
Member

@djhoese djhoese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit test?

@pnuu
Copy link
Member Author

pnuu commented Oct 11, 2018

Don't have time for adding unit tests during this week, and next week I'm out of office.

@djhoese djhoese merged commit e16c6d9 into master Oct 11, 2018
@djhoese djhoese deleted the bugfix-DNC-masking branch October 11, 2018 16:39
@djhoese djhoese added the bug label Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants