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 offset correction in seviri_l1b_hrit #688

Merged
merged 2 commits into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
19 changes: 17 additions & 2 deletions satpy/readers/seviri_l1b_hrit.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,16 @@ def get_xy_from_linecol(self, line, col, offsets, factors):
return x__, y__

def get_area_extent(self, size, offsets, factors, platform_height):
"""Get the area extent of the file."""
"""Get the area extent of the file.

Until December 2017, the data is shifted by 1.5km SSP North and West against the nominal GEOS projection. Since
December 2017 this offset has been corrected. A flag in the data indicates if the correction has been applied.
If no correction was applied, adjust the area extent to match the shifted data.

For more information see Section 3.1.4.2 in the MSG Level 1.5 Image Data Format Description. The correction
of the area extent is documented in a `developer's memo <https://github.com/pytroll/satpy/wiki/
SEVIRI-georeferencing-offset-correction>`_.
"""
nlines, ncols = size
h = platform_height

Expand All @@ -416,8 +425,14 @@ def get_area_extent(self, size, offsets, factors, platform_height):
np.deg2rad(ur_x) * h, np.deg2rad(ur_y) * h)

if not self.mda['offset_corrected']:
# Geo-referencing offset present. Adjust area extent to match the shifted data. Note that we have to adjust
# the corners in the *opposite* direction, i.e. S-E. Think of it as if the coastlines were fixed and you
# dragged the image to S-E until coastlines and data area aligned correctly.
#
# Although the image is flipped upside-down and left-right, the projection coordinates retain their
# properties, i.e. positive x/y is East/North, respectively.
xadj = 1500
yadj = 1500
yadj = -1500
aex = (aex[0] + xadj, aex[1] + yadj,
aex[2] + xadj, aex[3] + yadj)

Expand Down
7 changes: 7 additions & 0 deletions satpy/tests/reader_tests/test_seviri_l1b_hrit.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ def test_get_area_def(self):
(-77771774058.38356, -3720765401003.719,
30310525626438.438, 77771774058.38356))

# Data shifted by 1.5km to N-W
self.reader.mda['offset_corrected'] = False
area = self.reader.get_area_def(DatasetID('VIS006'))
self.assertEqual(area.area_extent,
(-77771772558.38356, -3720765402503.719,
30310525627938.438, 77771772558.38356))

@mock.patch('satpy.readers.hrit_base.np.memmap')
def test_read_band(self, memmap):
nbits = self.reader.mda['number_of_bits_per_pixel']
Expand Down