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 of AHI HSD space pixels #592

Merged
merged 3 commits into from Jan 25, 2019
Merged

Conversation

sfinkens
Copy link
Member

Replace usage of satpy.readers.ahi_hsd.AHIHSDFileHandler.geo_mask with satpy.readers.utils.get_geostationary_mask because they do the same thing.

A closer analysis revealed that the masks computed by the two methods are shifted vertically by one pixel. The reason for that are incorrect line indices in geo_mask (shifted by one). If applying the following modification, both methods compute exactly the same masks. Therefore it should be safe to replace geo_mask with get_geostationary_mask.

diff --git a/satpy/readers/ahi_hsd.py b/satpy/readers/ahi_hsd.py
index 538b6af9..43fb70e9 100644
--- a/satpy/readers/ahi_hsd.py
+++ b/satpy/readers/ahi_hsd.py
@@ -341,8 +341,8 @@ class AHIHSDFileHandler(BaseFileHandler):
         cols_idx = da.arange(-(coff - local_coff),
                              ncols - (coff - local_coff),
                              dtype=np.float, chunks=CHUNK_SIZE)
-        lines_idx = da.arange(nlines - (loff - local_loff),
-                              -(loff - local_loff),
+        lines_idx = da.arange(nlines - 1 - (loff - local_loff),
+                              -(loff - local_loff) - 1,
                               -1,
                               dtype=np.float, chunks=CHUNK_SIZE)
         return ellipse(lines_idx[:, None], cols_idx[None, :])

satpy/readers/ahi_hsd.py Outdated Show resolved Hide resolved
satpy/tests/reader_tests/test_ahi_hsd.py Show resolved Hide resolved
@djhoese djhoese self-assigned this Jan 25, 2019
@djhoese djhoese added enhancement code enhancements, features, improvements component:readers optimization labels Jan 25, 2019
@djhoese djhoese added bug and removed enhancement code enhancements, features, improvements labels Jan 25, 2019
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.

LGTM. I think I'm going to mark this as a "bug fix" for 0.11.2 and will merge right away. Technically this is a "feature" or at least an optimization but given the off by one issue that was discovered this sounds more like a bug fix. Correct me if I'm wrong.

@sfinkens
Copy link
Member Author

@djhoese Agree!

@coveralls
Copy link

coveralls commented Jan 25, 2019

Coverage Status

Coverage increased (+0.1%) to 77.566% when pulling 9aec74e on sfinkens:fix_531 into 73c1600 on pytroll:master.

@codecov
Copy link

codecov bot commented Jan 25, 2019

Codecov Report

Merging #592 into master will increase coverage by 0.19%.
The diff coverage is 36.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #592      +/-   ##
==========================================
+ Coverage   77.45%   77.64%   +0.19%     
==========================================
  Files         136      136              
  Lines       19168    19248      +80     
==========================================
+ Hits        14846    14946     +100     
+ Misses       4322     4302      -20
Impacted Files Coverage Δ
satpy/tests/reader_tests/test_ahi_hsd.py 96.51% <100%> (+0.79%) ⬆️
satpy/readers/ahi_hsd.py 72.98% <17.85%> (+11.99%) ⬆️
satpy/multiscene.py 83.46% <0%> (+4.34%) ⬆️

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 73c1600...9aec74e. Read the comment docs.

@djhoese djhoese changed the title Factorize masking of AHI HSD space pixels Fix masking of AHI HSD space pixels Jan 25, 2019
@djhoese djhoese merged commit 5c5f0c5 into pytroll:master Jan 25, 2019
@sfinkens sfinkens deleted the fix_531 branch March 4, 2019 16:07
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.

Mask space pixels in AHI HSD reader
4 participants