Skip to content

Commit

Permalink
Merge pull request #1262 from ameraner/add_RSS_HRV_navigation
Browse files Browse the repository at this point in the history
Fix handling of HRV channel navigation for RSS data in seviri_l1b_native reader
  • Loading branch information
mraspaud committed Jul 20, 2020
2 parents a8fcba6 + d9a008f commit 5ac3eaf
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 39 deletions.
59 changes: 31 additions & 28 deletions satpy/readers/seviri_l1b_native.py
Expand Up @@ -47,7 +47,6 @@
native_trailer)
from satpy.readers._geos_area import get_area_definition


logger = logging.getLogger('native_msg')


Expand All @@ -59,7 +58,7 @@ class NativeMSGFileHandler(BaseFileHandler, SEVIRICalibrationHandler):
kwargs = {"calib_mode": "gsics",}
"""

def __init__(self, filename, filename_info, filetype_info, calib_mode='nominal'):
def __init__(self, filename, filename_info, filetype_info, calib_mode='nominal'):
"""Initialize the reader."""
super(NativeMSGFileHandler, self).__init__(filename,
filename_info,
Expand Down Expand Up @@ -146,7 +145,6 @@ def get_lrec(cols):
def _get_memmap(self):
"""Get the memory map for the SEVIRI data."""
with open(self.filename) as fp:

data_dtype = self._get_data_dtype()
hdr_size = native_header.itemsize

Expand Down Expand Up @@ -174,11 +172,11 @@ def _read_header(self):
self.mda['platform_name'] = "Meteosat-" + SATNUM[self.platform_id]

equator_radius = data15hd['GeometricProcessing'][
'EarthModel']['EquatorialRadius'] * 1000.
'EarthModel']['EquatorialRadius'] * 1000.
north_polar_radius = data15hd[
'GeometricProcessing']['EarthModel']['NorthPolarRadius'] * 1000.
'GeometricProcessing']['EarthModel']['NorthPolarRadius'] * 1000.
south_polar_radius = data15hd[
'GeometricProcessing']['EarthModel']['SouthPolarRadius'] * 1000.
'GeometricProcessing']['EarthModel']['SouthPolarRadius'] * 1000.
polar_radius = (north_polar_radius + south_polar_radius) * 0.5
ssp_lon = data15hd['ImageDescription'][
'ProjectionDescription']['LongitudeOfSSP']
Expand Down Expand Up @@ -239,7 +237,6 @@ def _read_trailer(self):
self.mda['number_of_lines'])

with open(self.filename) as fp:

fp.seek(hdr_size + data_size)
data = np.fromfile(fp, dtype=native_trailer, count=1)

Expand Down Expand Up @@ -349,29 +346,18 @@ def get_area_extent(self, dataset_id):
)
raise NotImplementedError(msg)

# When dealing with HRV channel and full disk, area extent is
# in two pieces
if (dataset_id.name == 'HRV') and self.mda['is_full_disk']:
# check if data is in Rapid Scanning Service mode (RSS)
is_rapid_scan = self.trailer['15TRAILER']['ImageProductionStats']['ActualScanningSummary']['ReducedScan']

# The HRV channel in full disk mode comes in two separate areas, and each area has its own area extent stored
# in the trailer.
# In Rapid Scanning mode, only the "Lower" area (typically over Europe) is acquired and included in the files.
if (dataset_id.name == 'HRV') and (self.mda['is_full_disk'] or is_rapid_scan):

# get actual navigation parameters from trailer data
data15tr = self.trailer['15TRAILER']
HRV_bounds = data15tr['ImageProductionStats']['ActualL15CoverageHRV']

# upper window
upper_north_line = HRV_bounds['UpperNorthLineActual']
upper_west_column = HRV_bounds['UpperWestColumnActual']
upper_south_line = HRV_bounds['UpperSouthLineActual']
upper_east_column = HRV_bounds['UpperEastColumnActual']

upper_area_extent = self._calculate_area_extent(
center_point, upper_north_line, upper_east_column,
upper_south_line, upper_west_column, we_offset,
ns_offset, column_step, line_step
)

upper_nlines = upper_north_line - upper_south_line + 1
upper_ncols = upper_west_column - upper_east_column + 1

# lower window
lower_north_line = HRV_bounds['LowerNorthLineActual']
lower_west_column = HRV_bounds['LowerWestColumnActual']
Expand All @@ -384,14 +370,31 @@ def get_area_extent(self, dataset_id):
ns_offset, column_step, line_step
)

if is_rapid_scan:
return lower_area_extent

lower_nlines = lower_north_line - lower_south_line + 1
lower_ncols = lower_west_column - lower_east_column + 1

# upper window
upper_north_line = HRV_bounds['UpperNorthLineActual']
upper_west_column = HRV_bounds['UpperWestColumnActual']
upper_south_line = HRV_bounds['UpperSouthLineActual']
upper_east_column = HRV_bounds['UpperEastColumnActual']

upper_area_extent = self._calculate_area_extent(
center_point, upper_north_line, upper_east_column,
upper_south_line, upper_west_column, we_offset,
ns_offset, column_step, line_step
)

upper_nlines = upper_north_line - upper_south_line + 1
upper_ncols = upper_west_column - upper_east_column + 1

return [upper_area_extent, lower_area_extent, upper_nlines, upper_ncols, lower_nlines, lower_ncols]

# Otherwise area extent is in one piece, corner points are
# the same as for VISIR channels, HRV channel is having
# three times the amount of columns and rows
# If the data was ordered in a defined ROI, the area extent is in one piece, the corner points are
# the same as for VISIR channels, and the HRV channel is having three times the amount of columns and rows.
else:

north = coeff * int(sec15hd['NorthLineSelectedRectangle']['Value'])
Expand Down

0 comments on commit 5ac3eaf

Please sign in to comment.