From 118f534aecf9c46b8c8d6c8dd257c24654ae7d06 Mon Sep 17 00:00:00 2001 From: Sauli Joro Date: Fri, 4 May 2018 07:22:49 +0000 Subject: [PATCH] Fix area_extent definition. --- satpy/etc/areas.def | 51 ++++++++++++++++++++++----------- satpy/readers/native_msg.py | 36 +++++++++++------------ satpy/readers/native_msg_hdr.py | 15 +++++----- 3 files changed, 58 insertions(+), 44 deletions(-) diff --git a/satpy/etc/areas.def b/satpy/etc/areas.def index 7c6e0bbe82..d990539e31 100644 --- a/satpy/etc/areas.def +++ b/satpy/etc/areas.def @@ -44,14 +44,14 @@ REGION: iber { AREA_EXTENT: (-342379.698, 4432580.06, 723701.52, 5029648.75) }; -REGION: SouthAmerica { - NAME: South America - PCS_ID: geos0 - PCS_DEF: proj=geos,lon_0=0.0,a=6378169.00,b=6356583.80,h=35785831.0 - XSIZE: 3000 - YSIZE: 1200 - AREA_EXTENT: (-5570248.4773392612, -4263473.5610361192, -384719.90821206354, 1339786.2707295895) -}; +REGION: SouthAmerica { + NAME: South America + PCS_ID: geos0 + PCS_DEF: proj=geos,lon_0=0.0,a=6378169.00,b=6356583.80,h=35785831.0 + XSIZE: 3000 + YSIZE: 1200 + AREA_EXTENT: (-5570248.4773392612, -4263473.5610361192, -384719.90821206354, 1339786.2707295895) +}; REGION: brazil2 { NAME: brazil, platecarree @@ -72,12 +72,12 @@ REGION: sudeste { }; REGION: SouthAmerica_flat{ - NAME: South America flat + NAME: South America flat PCS_ID: eqc0 - PCS_DEF: proj='eqc', a=6378137.0, b=6378137.0, units='m' + PCS_DEF: proj='eqc', a=6378137.0, b=6378137.0, units='m' XSIZE: 1442 YSIZE: 1213 - AREA_EXTENT: (-8326322.8279089704,-4609377.085697311,-556597.45396636787, 1535833.8895192828 ) + AREA_EXTENT: (-8326322.8279089704,-4609377.085697311,-556597.45396636787, 1535833.8895192828 ) }; @@ -269,6 +269,24 @@ REGION: met09globeFull { AREA_EXTENT: (-5570248.4773392612, -5567248.074173444, 5567248.074173444, 5570248.4773392612) }; +REGION: seviri_0deg { + NAME: Full globe MSG image 0 degrees + PCS_ID: geos0 + PCS_DEF: proj=geos, lon_0=0, a=6378169.00, b=6356583.80, h=35785831.0 + XSIZE: 3712 + YSIZE: 3712 + AREA_EXTENT: (-5570248.4773392612, -5567248.074173444, 5567248.074173444, 5570248.4773392612) +}; + +REGION: seviri_iodc { + NAME: Full globe MSG image 41.5 degrees + PCS_ID: geos0 + PCS_DEF: proj=geos, lon_0=41.5, a=6378169.00, b=6356583.80, h=35785831.0 + XSIZE: 3712 + YSIZE: 3712 + AREA_EXTENT: (-5570248.4773392612, -5567248.074173444, 5567248.074173444, 5570248.4773392612) +}; + REGION: msg_resample_area { NAME: Full globe MSG image 20.75 degrees PCS_ID: geos0 @@ -567,7 +585,7 @@ REGION: eport1 { }; REGION: eport10 { - NAME: eport reduced resolution + NAME: eport reduced resolution PCS_ID: ps90n PCS_DEF: proj=stere,lat_0=90,lon_0=0,ellps=WGS84,units=m XSIZE: 1057 @@ -576,7 +594,7 @@ REGION: eport10 { }; REGION: eport4 { - NAME: eport reduced resolution + NAME: eport reduced resolution PCS_ID: ps90n PCS_DEF: proj=stere,lat_0=90,lon_0=0,ellps=WGS84,units=m XSIZE: 2642 @@ -585,7 +603,7 @@ REGION: eport4 { }; REGION: eport2 { - NAME: eport reduced resolution + NAME: eport reduced resolution PCS_ID: ps90n PCS_DEF: proj=stere,lat_0=90,lon_0=0,ellps=WGS84,units=m XSIZE: 5285 @@ -669,7 +687,7 @@ REGION: ease_nh { REGION: barents_sea { NAME: Barents and Greenland seas - PCS_ID: barents_sea + PCS_ID: barents_sea PCS_DEF: proj=stere,ellps=WGS84,lat_0=90,lon_0=40,lat_ts=75 XSIZE: 3000 YSIZE: 1700 @@ -809,7 +827,7 @@ REGION: northamerica_10km { # ------------------------------------------------------------------ -proj4_string = +proj4_string = REGION: romania { NAME: Romania - 3km @@ -894,4 +912,3 @@ REGION: robinson { YSIZE: 3296 AREA_EXTENT: (-2049911.5256036147, 5326895.725982913, 2049911.5256036168, 8625155.12857459) }; - diff --git a/satpy/readers/native_msg.py b/satpy/readers/native_msg.py index e789eb29d2..5fa9ad84ee 100644 --- a/satpy/readers/native_msg.py +++ b/satpy/readers/native_msg.py @@ -201,7 +201,6 @@ def _get_header(self): self.mda['number_of_lines'] = int(sec15hd['NumberLinesVISIR']['Value'][0]) self.mda['number_of_columns'] = int(cols_visir / 1.25) self.mda['hrv_number_of_lines'] = int(sec15hd["NumberLinesHRV"]['Value'][0]) - # The number of HRV columns seem to be correct in the UMARF header: self.mda['hrv_number_of_columns'] = int(cols_hrv / 1.25) # Check the calculated row,column dimensions against the header information: @@ -228,10 +227,14 @@ def _get_header(self): line_step = data15hd['ImageDescription'][ "ReferenceGridVIS_IR"]["LineDirGridStep"][0] * 1000.0 - area_extent = ((1856 - west - 0.5) * column_step, - (1856 - north + 0.5) * line_step, - (1856 - east + 0.5) * column_step, - (1856 - south + 1.5) * line_step) + # get corner points for lower left and upper right + # columns and lines + ll_c = (1856 - west - 0.5) * column_step + ll_l = (south - 1856 + 1.5) * line_step + ur_c = (1856 - east + 0.5) * column_step + ur_l = (north - 1856 + 0.5) * line_step + + area_extent = (ll_c, ll_l, ur_c, ur_l) self.area_extent = area_extent @@ -336,30 +339,25 @@ def calibrate(self, data, dataset_id): data15hdr = self.header['15_DATA_HEADER'] calibration = dataset_id.calibration channel = dataset_id.name - # locate the channel index as not all channels - # may be present in the Image files so self._channel_list - # cannot be used to locate their index - - for v, i in enumerate(CHANNEL_NAMES): - if CHANNEL_NAMES[i] == channel: - break - # arrax index will start at 0 of course - i = i - 1 + # even though all the channels may not be present in the file, + # the header does have calibration coefficients for all the channels + # hence, this channel index needs to refer to full channel list + i = list(CHANNEL_NAMES.values()).index(channel) if calibration == 'counts': return if calibration in ['radiance', 'reflectance', 'brightness_temperature']: # you cant apply GSICS values to the VIS channels - vis_ids = ['HRV', 'VIS006', 'VIS008', 'IR_016'] + visual_channels = ['HRV', 'VIS006', 'VIS008', 'IR_016'] # determine the required calibration coefficients to use # for the Level 1.5 Header calMode = os.environ.get('CAL_MODE', 'NOMINAL') - # NB gsics doesnt apply to VIS channels so ignore them - if (calMode.upper() != 'GSICS' or channel in vis_ids): + # NB GSICS doesn't have calibration coeffs for VIS channels + if (calMode.upper() != 'GSICS' or channel in visual_channels): coeffs = data15hdr[ 'RadiometricProcessing']['Level15ImageCalibration'] gain = coeffs['CalSlope'][0][i] @@ -399,7 +397,7 @@ def get_available_channels(header): retv = {} - for idx, chmark in zip(range(12), chlist_str): - retv[CHANNEL_NAMES[idx + 1]] = (chmark == 'X') + for idx, char in zip(range(12), chlist_str): + retv[CHANNEL_NAMES[idx + 1]] = (char == 'X') return retv diff --git a/satpy/readers/native_msg_hdr.py b/satpy/readers/native_msg_hdr.py index 6419d7996f..13273011fd 100644 --- a/satpy/readers/native_msg_hdr.py +++ b/satpy/readers/native_msg_hdr.py @@ -23,8 +23,8 @@ """Definition of Header Records for the MSG Level 1.5 data (hrit or native) `impf_configuration` in `L15DataHeaderRecord` - Padding of 4 bytes has been added, believed to be down to Structure - padding by the compiler. + Padding of 4 bytes has been added, believed to be down to Structure + padding by the compiler. """ @@ -32,7 +32,6 @@ class GSDTRecords(object): - """MSG Ground Segment Data Type records. Reference Document: MSG Ground Segment Design Specification (GSDS) @@ -96,6 +95,9 @@ class GSDTRecords(object): class Msg15NativeHeaderRecord(object): + """ + SEVIRI Level 1.5 header for native-format + """ def get(self): @@ -120,7 +122,6 @@ class L15PhData(object): class L15MainProductHeaderRecord(object): - """ Reference Document: MSG Level 1.5 Native Format File Definition @@ -169,7 +170,6 @@ def get(self): class L15SecondaryProductHeaderRecord(object): - """ Reference Document: MSG Level 1.5 Native Format File Definition @@ -204,7 +204,6 @@ def get(self): class L15DataHeaderRecord(GSDTRecords): - """ Reference Document: MSG Level 1.5 Image Data Format Description @@ -220,7 +219,7 @@ def get(self): ('ImageDescription', self.image_description), ('RadiometricProcessing', self.radiometric_processing), ('GeometricProcessing', self.geometric_processing)] - + record.append(('IMPFConfiguration', self.impf_configuration)) return record @@ -676,6 +675,6 @@ def impf_configuration(self): ('OverallConfiguration', overall_configuration), ('SUDetails', (su_details, 50)), ('WarmStartParams', warm_start_params), - ('Padding', (np.void, 4))] # FIXME! + ('Padding', (np.void, 4))] return record