Skip to content

Commit

Permalink
Fix area_extent definition.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoro committed May 4, 2018
1 parent 9362dea commit 118f534
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 44 deletions.
51 changes: 34 additions & 17 deletions satpy/etc/areas.def
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 )
};


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -809,7 +827,7 @@ REGION: northamerica_10km {

# ------------------------------------------------------------------

proj4_string =
proj4_string =

REGION: romania {
NAME: Romania - 3km
Expand Down Expand Up @@ -894,4 +912,3 @@ REGION: robinson {
YSIZE: 3296
AREA_EXTENT: (-2049911.5256036147, 5326895.725982913, 2049911.5256036168, 8625155.12857459)
};

36 changes: 17 additions & 19 deletions satpy/readers/native_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
15 changes: 7 additions & 8 deletions satpy/readers/native_msg_hdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@

"""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.
"""


import numpy as np


class GSDTRecords(object):

"""MSG Ground Segment Data Type records.
Reference Document: MSG Ground Segment Design Specification (GSDS)
Expand Down Expand Up @@ -96,6 +95,9 @@ class GSDTRecords(object):


class Msg15NativeHeaderRecord(object):
"""
SEVIRI Level 1.5 header for native-format
"""

def get(self):

Expand All @@ -120,7 +122,6 @@ class L15PhData(object):


class L15MainProductHeaderRecord(object):

"""
Reference Document:
MSG Level 1.5 Native Format File Definition
Expand Down Expand Up @@ -169,7 +170,6 @@ def get(self):


class L15SecondaryProductHeaderRecord(object):

"""
Reference Document:
MSG Level 1.5 Native Format File Definition
Expand Down Expand Up @@ -204,7 +204,6 @@ def get(self):


class L15DataHeaderRecord(GSDTRecords):

"""
Reference Document:
MSG Level 1.5 Image Data Format Description
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 118f534

Please sign in to comment.