Esempio n. 1
0
    def get_area_def(self, dataset_id):
        """Get the area definition of the band."""
        pdict = {}
        pdict['a'] = self.mda['projection_parameters']['a']
        pdict['b'] = self.mda['projection_parameters']['b']
        pdict['h'] = self.mda['projection_parameters']['h']
        pdict['ssp_lon'] = self.mda['projection_parameters']['ssp_longitude']

        if dataset_id['name'] == 'HRV':
            pdict['nlines'] = self.mda['hrv_number_of_lines']
            pdict['ncols'] = self.mda['hrv_number_of_columns']
            pdict['a_name'] = 'geos_seviri_hrv'
            pdict['a_desc'] = 'SEVIRI high resolution channel area'
            pdict['p_id'] = 'seviri_hrv'

            if self.mda['is_full_disk']:
                # handle full disk HRV data with two separated area definitions
                [
                    upper_area_extent, lower_area_extent, upper_nlines,
                    upper_ncols, lower_nlines, lower_ncols
                ] = self.get_area_extent(dataset_id)

                # upper area
                pdict[
                    'a_desc'] = 'SEVIRI high resolution channel, upper window'
                pdict['nlines'] = upper_nlines
                pdict['ncols'] = upper_ncols
                upper_area = get_area_definition(pdict, upper_area_extent)

                # lower area
                pdict[
                    'a_desc'] = 'SEVIRI high resolution channel, lower window'
                pdict['nlines'] = lower_nlines
                pdict['ncols'] = lower_ncols
                lower_area = get_area_definition(pdict, lower_area_extent)

                area = geometry.StackedAreaDefinition(lower_area, upper_area)
                area = area.squeeze()
            else:
                # if the HRV data is in a ROI, the HRV channel is delivered in one area
                area = get_area_definition(pdict,
                                           self.get_area_extent(dataset_id))

        else:
            pdict['nlines'] = self.mda['number_of_lines']
            pdict['ncols'] = self.mda['number_of_columns']
            pdict['a_name'] = 'geos_seviri_visir'
            pdict['a_desc'] = 'SEVIRI low resolution channel area'
            pdict['p_id'] = 'seviri_visir'

            area = get_area_definition(pdict, self.get_area_extent(dataset_id))

        return area
Esempio n. 2
0
    def get_area_def(self, dsid):
        """Get the area definition."""
        del dsid

        pdict = {}
        pdict['cfac'] = np.uint32(self.proj_info['CFAC'])
        pdict['lfac'] = np.uint32(self.proj_info['LFAC'])
        pdict['coff'] = np.float32(self.proj_info['COFF'])
        pdict['loff'] = -np.float32(self.proj_info['LOFF']) + 1
        pdict['a'] = float(self.proj_info['earth_equatorial_radius'] * 1000)
        pdict['h'] = float(self.proj_info['distance_from_earth_center'] *
                           1000 - pdict['a'])
        pdict['b'] = float(self.proj_info['earth_polar_radius'] * 1000)
        pdict['ssp_lon'] = float(self.proj_info['sub_lon'])
        pdict['nlines'] = int(self.data_info['number_of_lines'])
        pdict['ncols'] = int(self.data_info['number_of_columns'])
        pdict['scandir'] = 'N2S'

        pdict['loff'] = pdict['loff'] + (self.segment_number * pdict['nlines'])

        aex = get_area_extent(pdict)

        pdict['a_name'] = self.observation_area
        pdict['a_desc'] = "AHI {} area".format(self.observation_area)
        pdict['p_id'] = 'geosh8'

        area = get_area_definition(pdict, aex)

        self.area = area
        return area
Esempio n. 3
0
    def get_area_def(self, ds_id):
        ds_get_name = self._get_dsname(ds_id)
        ds_shape = self[ds_get_name + '/shape']
        geoloc = self.geoloc

        pdict = {}
        pdict['cfac'] = np.int32(geoloc[0])
        pdict['lfac'] = np.int32(geoloc[1])
        pdict['coff'] = np.float32(geoloc[2])
        pdict['loff'] = -np.float32(geoloc[3])

        # Unfortunately this dataset does not store a, b or h.
        # We assume a and b here, and calculate h from altitude
        # a and b are from SEVIRI data HRIT header (201912101300)
        pdict['a'] = 6378169
        pdict['b'] = 6356583.8
        pdict['h'] = self.alt - pdict['a']
        pdict['ssp_lon'] = self.projlon
        pdict['ncols'] = int(ds_shape[0])
        pdict['nlines'] = int(ds_shape[1])

        # Force scandir to SEVIRI default, not known from file
        pdict['scandir'] = 'S2N'
        pdict['a_name'] = 'geosmsg'
        if ds_id.name == 'HRV':
            pdict['a_desc'] = 'MSG/SEVIRI HRV channel area'
            pdict['p_id'] = 'msg_hires'
        else:
            pdict['a_desc'] = 'MSG/SEVIRI low resolution channel area'
            pdict['p_id'] = 'msg_lowres'

        aex = get_area_extent(pdict)
        area = get_area_definition(pdict, aex)

        return area
Esempio n. 4
0
    def get_area_def(self, dataset_id):
        """Get the area definition of the band.

        In general, image data from one window/area is available. For the HRV channel in FES mode, however,
        data from two windows ('Lower' and 'Upper') are available. Hence, we collect lists of area-extents
        and corresponding number of image lines/columns. In case of FES HRV data, two area definitions are
        computed, stacked and squeezed. For other cases, the lists will only have one entry each, from which
        a single area definition is computed.

        Note that the AreaDefinition area extents returned by this function for Native data will be slightly
        different compared to the area extents returned by the SEVIRI HRIT reader.
        This is due to slightly different pixel size values when calculated using the data available in the files. E.g.
        for the 3 km grid:

        ``Native: data15hd['ImageDescription']['ReferenceGridVIS_IR']['ColumnDirGridStep'] == 3000.4031658172607``
        ``HRIT:                            np.deg2rad(2.**16 / pdict['lfac']) * pdict['h'] == 3000.4032785810186``

        This results in the Native 3 km full-disk area extents being approx. 20 cm shorter in each direction.

        The method for calculating the area extents used by the HRIT reader (CFAC/LFAC mechanism) keeps the
        highest level of numeric precision and is used as reference by EUM. For this reason, the standard area
        definitions defined in the `areas.yaml` file correspond to the HRIT ones.

        """
        pdict = {}
        pdict['a'] = self.mda['projection_parameters']['a']
        pdict['b'] = self.mda['projection_parameters']['b']
        pdict['h'] = self.mda['projection_parameters']['h']
        pdict['ssp_lon'] = self.mda['projection_parameters']['ssp_longitude']

        area_naming_input_dict = {
            'platform_name': 'msg',
            'instrument_name': 'seviri',
            'resolution': int(dataset_id['resolution'])
        }
        area_naming = get_geos_area_naming({
            **area_naming_input_dict,
            **get_service_mode('seviri', pdict['ssp_lon'])
        })

        pdict['a_name'] = area_naming['area_id']
        pdict['a_desc'] = area_naming['description']
        pdict['p_id'] = ""

        area_extent = self.get_area_extent(dataset_id)
        areas = list()
        for aex, nlines, ncolumns in zip(area_extent['area_extent'],
                                         area_extent['nlines'],
                                         area_extent['ncolumns']):
            pdict['nlines'] = nlines
            pdict['ncols'] = ncolumns
            areas.append(get_area_definition(pdict, aex))

        if len(areas) == 2:
            area = geometry.StackedAreaDefinition(areas[0], areas[1])
            area = area.squeeze()
        else:
            area = areas[0]

        return area
Esempio n. 5
0
    def get_area_def(self, dsid):
        """Get area definition for this file."""
        pdict = {}
        pdict['a'] = self.nc.attrs['earth_equatorial_radius']
        pdict['b'] = self.nc.attrs['earth_polar_radius']
        pdict['h'] = self.nc.attrs['nominal_satellite_height'] - pdict['a']
        pdict['ssp_lon'] = self.nc.attrs['sub_longitude'] * 180 / np.pi  # it's in radians?
        pdict['ncols'] = self.nc.attrs['number_of_columns']
        pdict['nlines'] = self.nc.attrs['number_of_lines']
        obs_mode = self.nc.attrs['observation_mode']
        resolution = self.nc.attrs['channel_spatial_resolution']

        pdict['cfac'] = self.nc.attrs['cfac']
        pdict['coff'] = self.nc.attrs['coff']
        pdict['lfac'] = self.nc.attrs['lfac']
        pdict['loff'] = self.nc.attrs['loff']

        # AMI grid appears offset, we can not use the standard get_area_extent
        bit_shift = 2**16
        ll_x = (0 - pdict['coff'] - 0.5) * bit_shift / pdict['cfac']
        ll_y = -(0 - pdict['loff'] - 0.5) * bit_shift / pdict['lfac']
        ur_x = (pdict['ncols'] - pdict['coff'] + 0.5) * bit_shift / pdict['cfac']
        ur_y = -(pdict['nlines'] - pdict['loff'] + 0.5) * bit_shift / pdict['lfac']

        area_extent = make_ext(ll_x, ur_x, ll_y, ur_y, pdict['h'])

        pdict['a_name'] = 'ami_geos_{}'.format(obs_mode.lower())
        pdict['a_desc'] = 'AMI {} Area at {} resolution'.format(obs_mode, resolution)
        pdict['p_id'] = 'ami_fixed_grid'

        fg_area_def = get_area_definition(pdict, area_extent)

        return fg_area_def
Esempio n. 6
0
 def get_area_def(self, dataset_id):
     """Get the area definition of the band."""
     proj_dict = self._get_proj_dict(dataset_id)
     area_extent = get_area_extent(proj_dict)
     area = get_area_definition(proj_dict, area_extent)
     self.area = area
     return area
Esempio n. 7
0
    def get_area_def(self, dsid):
        """Get the area definition of the band."""
        pdict = {}
        pdict['cfac'] = np.int32(self.mda['cfac'])
        pdict['lfac'] = np.int32(self.mda['lfac'])
        pdict['coff'] = np.float32(self.mda['coff'])
        pdict['loff'] = np.float32(self.mda['loff'])

        pdict['a'] = 6378169.00
        pdict['b'] = 6356583.80
        pdict['h'] = 35785831.00
        pdict['scandir'] = 'N2S'

        pdict['ssp_lon'] = self.mda['projection_parameters']['SSP_longitude']

        pdict['nlines'] = int(self.mda['number_of_lines'])
        pdict['ncols'] = int(self.mda['number_of_columns'])

        pdict['loff'] = pdict['nlines'] - pdict['loff']

        pdict['a_name'] = 'geosgoms'
        pdict['a_desc'] = 'Electro-L/GOMS channel area'
        pdict['p_id'] = 'goms'

        area_extent = get_area_extent(pdict)
        area = get_area_definition(pdict, area_extent)

        self.area = area

        return area
Esempio n. 8
0
    def get_area_def(self, dsid):
        """Get area definition for this file."""
        pdict = {}
        pdict['a'] = self.nc.attrs['earth_equatorial_radius']
        pdict['b'] = self.nc.attrs['earth_polar_radius']
        pdict['h'] = self.nc.attrs['nominal_satellite_height'] - pdict['a']
        pdict['ssp_lon'] = self.nc.attrs[
            'sub_longitude'] * 180 / np.pi  # it's in radians?
        pdict['ncols'] = self.nc.attrs['number_of_columns']
        pdict['nlines'] = self.nc.attrs['number_of_lines']
        obs_mode = self.nc.attrs['observation_mode']
        resolution = self.nc.attrs['channel_spatial_resolution']

        # Example offset: 11000.5
        # the 'get_area_extent' will handle this half pixel for us
        pdict['cfac'] = self.nc.attrs['cfac']
        pdict['coff'] = self.nc.attrs['coff']
        pdict['lfac'] = -self.nc.attrs['lfac']
        pdict['loff'] = self.nc.attrs['loff']
        pdict['scandir'] = 'N2S'
        pdict['a_name'] = 'ami_geos_{}'.format(obs_mode.lower())
        pdict['a_desc'] = 'AMI {} Area at {} resolution'.format(
            obs_mode, resolution)
        pdict['p_id'] = 'ami_fixed_grid'

        area_extent = get_area_extent(pdict)
        fg_area_def = get_area_definition(pdict, area_extent)
        return fg_area_def
Esempio n. 9
0
    def get_area_def(self, key):
        """Get the area definition."""
        # Coordination Group for Meteorological Satellites LRIT/HRIT Global Specification
        # https://www.cgms-info.org/documents/cgms-lrit-hrit-global-specification-(v2-8-of-30-oct-2013).pdf
        res = key['resolution']
        pdict = {}
        pdict['coff'] = _COFF_list[_resolution_list.index(res)]
        pdict['loff'] = _LOFF_list[_resolution_list.index(res)]
        pdict['cfac'] = _CFAC_list[_resolution_list.index(res)]
        pdict['lfac'] = _LFAC_list[_resolution_list.index(res)]
        pdict['a'] = self.file_content['/attr/dEA'] * 1E3  # equator radius (m)
        pdict['b'] = pdict['a'] * (
            1 - 1 / self.file_content['/attr/dObRecFlat'])  # polar radius (m)
        pdict['h'] = self.file_content[
            '/attr/NOMSatHeight']  # the altitude of satellite (m)

        pdict['ssp_lon'] = self.file_content['/attr/NOMCenterLon']
        pdict['nlines'] = self.file_content['/attr/RegLength']
        pdict['ncols'] = self.file_content['/attr/RegWidth']

        pdict['scandir'] = 'S2N'

        b500 = ['C02']
        b1000 = ['C01', 'C03']
        b2000 = ['C04', 'C05', 'C06', 'C07']

        pdict['a_desc'] = "AGRI {} area".format(
            self.filename_info['observation_type'])

        if (key['name'] in b500):
            pdict['a_name'] = self.filename_info['observation_type'] + '_500m'
            pdict['p_id'] = 'FY-4A, 500m'
        elif (key['name'] in b1000):
            pdict['a_name'] = self.filename_info['observation_type'] + '_1000m'
            pdict['p_id'] = 'FY-4A, 1000m'
        elif (key['name'] in b2000):
            pdict['a_name'] = self.filename_info['observation_type'] + '_2000m'
            pdict['p_id'] = 'FY-4A, 2000m'
        else:
            pdict['a_name'] = self.filename_info['observation_type'] + '_2000m'
            pdict['p_id'] = 'FY-4A, 4000m'

        pdict['coff'] = pdict['coff'] + 0.5
        pdict['nlines'] = pdict['nlines'] - 1
        pdict['ncols'] = pdict['ncols'] - 1
        pdict['loff'] = (pdict['loff'] -
                         self.file_content['/attr/End Line Number'] + 0.5)
        area_extent = get_area_extent(pdict)
        area_extent = (area_extent[0] + 2000, area_extent[1],
                       area_extent[2] + 2000, area_extent[3])

        pdict['nlines'] = pdict['nlines'] + 1
        pdict['ncols'] = pdict['ncols'] + 1
        area = get_area_definition(pdict, area_extent)

        return area
Esempio n. 10
0
    def get_area_def(self, dataset_id):
        """Return the area definition for a dataset."""
        # The area extension depends on the resolution of the dataset
        area_dict = self._area_dict.copy()
        area_dict['resolution'] = dataset_id.resolution
        area_extent = calculate_area_extent(area_dict)

        # Call the get_area_definition function to obtain the area
        area_def = get_area_definition(self._pdict, area_extent)

        return area_def
Esempio n. 11
0
    def get_area_def(self, dataset_id):
        """Return the area definition for a dataset."""
        self._area_dict['column_step'] = dataset_id.resolution
        self._area_dict['line_step'] = dataset_id.resolution

        area_extent = calculate_area_extent(self._area_dict)

        # Call the get_area_definition function to obtain the area
        area_def = get_area_definition(self._pdict, area_extent)

        return area_def
Esempio n. 12
0
    def _compute_area_def(self):
        """Compute the area definition.

        Returns:
            AreaDefinition: A pyresample AreaDefinition object containing the area definition.

        """
        # Read the projection data from the mtg_geos_projection variable
        a = float(self._projection.attrs['semi_major_axis'])
        b = float(self._projection.attrs['semi_minor_axis'])
        h = float(self._projection.attrs['perspective_point_height'])

        # TODO sweep_angle_axis value not handled at the moment, therefore commented out
        # sweep_axis = self._projection.attrs['sweep_angle_axis']

        # Coordinates of the pixel in radians
        x = self.nc['x']
        y = self.nc['y']
        # TODO conversion to radians: offset and scale factor are missing from some test NetCDF file
        # TODO the next two lines should be removed when the offset and scale factor are correctly configured
        if not hasattr(x, 'standard_name'):
            x = np.radians(x * 0.003202134 - 8.914740401)
            y = np.radians(y * 0.003202134 - 8.914740401)

        # Convert to degrees as required by the make_ext function
        x_deg = np.degrees(x)
        y_deg = np.degrees(y)

        # Select the extreme points of the extension area
        x_l, x_r = x_deg.values[0], x_deg.values[-1]
        y_l, y_u = y_deg.values[0], y_deg.values[-1]

        # Compute the extension area in meters
        area_extent = make_ext(x_l, x_r, y_l, y_u, h)

        # Assemble the projection definition dictionary
        p_dict = {
            'nlines': self.nlines,
            'ncols': self.ncols,
            'ssp_lon': self.ssp_lon,
            'a': a,
            'b': b,
            'h': h,
            'a_name': 'FCI Area',  # TODO to be confirmed
            'a_desc': 'Area for FCI instrument',  # TODO to be confirmed
            'p_id': 'geos'
        }

        # Compute the area definition
        area_def = get_area_definition(p_dict, area_extent)

        return area_def
Esempio n. 13
0
    def test_get_area_definition(self):
        """Test the retrieval of the area definition."""
        pdict, extent = self.make_pdict_ext(1, 'N2S')
        good_res = (-3000.4032785810186, -3000.4032785810186)

        a_def = get_area_definition(pdict, extent)
        self.assertEqual(a_def.area_id, pdict['a_name'])
        self.assertEqual(a_def.resolution, good_res)
        self.assertEqual(a_def.proj_dict['proj'], 'geos')
        self.assertEqual(a_def.proj_dict['units'], 'm')
        self.assertEqual(a_def.proj_dict['a'], 6378169)
        self.assertEqual(a_def.proj_dict['b'], 6356583.8)
        self.assertEqual(a_def.proj_dict['h'], 35785831)
Esempio n. 14
0
    def get_area_def(self, dataset_id):
        """Get the area def.

        Note that the AreaDefinition area extents returned by this function for NetCDF data will be slightly
        different compared to the area extents returned by the SEVIRI HRIT reader.
        This is due to slightly different pixel size values when calculated using the data available in the files. E.g.
        for the 3 km grid:

        ``NetCDF:  self.nc.attrs['vis_ir_column_dir_grid_step'] == 3000.4031658172607``
        ``HRIT: np.deg2rad(2.**16 / pdict['lfac']) * pdict['h'] == 3000.4032785810186``

        This results in the Native 3 km full-disk area extents being approx. 20 cm shorter in each direction.

        The method for calculating the area extents used by the HRIT reader (CFAC/LFAC mechanism) keeps the
        highest level of numeric precision and is used as reference by EUM. For this reason, the standard area
        definitions defined in the `areas.yaml` file correspond to the HRIT ones.

        """
        pdict = {}
        pdict['a'] = self.mda['projection_parameters']['a']
        pdict['b'] = self.mda['projection_parameters']['b']
        pdict['h'] = self.mda['projection_parameters']['h']
        pdict['ssp_lon'] = self.mda['projection_parameters']['ssp_longitude']

        area_naming_input_dict = {
            'platform_name': 'msg',
            'instrument_name': 'seviri',
            'resolution': int(dataset_id['resolution'])
        }
        area_naming = get_geos_area_naming({
            **area_naming_input_dict,
            **get_service_mode('seviri', pdict['ssp_lon'])
        })

        if dataset_id['name'] == 'HRV':
            pdict['nlines'] = self.mda['hrv_number_of_lines']
            pdict['ncols'] = self.mda['hrv_number_of_columns']
            pdict['a_name'] = area_naming['area_id']
            pdict['a_desc'] = area_naming['description']
            pdict['p_id'] = ""
        else:
            pdict['nlines'] = self.mda['number_of_lines']
            pdict['ncols'] = self.mda['number_of_columns']
            pdict['a_name'] = area_naming['area_id']
            pdict['a_desc'] = area_naming['description']
            pdict['p_id'] = ""

        area = get_area_definition(pdict, self.get_area_extent(dataset_id))

        return area
Esempio n. 15
0
    def test_get_area_definition(self):
        """Test the retrieval of the area definition."""
        from pyresample.utils import proj4_radius_parameters
        pdict, extent = self.make_pdict_ext(1, 'N2S')
        good_res = (-3000.4032785810186, -3000.4032785810186)

        a_def = get_area_definition(pdict, extent)
        self.assertEqual(a_def.area_id, pdict['a_name'])
        self.assertEqual(a_def.resolution, good_res)
        self.assertEqual(a_def.proj_dict['proj'], 'geos')
        self.assertEqual(a_def.proj_dict['units'], 'm')
        a, b = proj4_radius_parameters(a_def.proj_dict)
        self.assertEqual(a, 6378169)
        self.assertEqual(b, 6356583.8)
        self.assertEqual(a_def.proj_dict['h'], 35785831)
Esempio n. 16
0
    def get_area_def(self, dataset_id):
        """Get the area definition of the band.

        In general, image data from one window/area is available. For the HRV channel in FES mode, however,
        data from two windows ('Lower' and 'Upper') are available. Hence, we collect lists of area-extents
        and corresponding number of image lines/columns. In case of FES HRV data, two area definitions are
        computed, stacked and squeezed. For other cases, the lists will only have one entry each, from which
        a single area definition is computed.
        """
        pdict = {}
        pdict['a'] = self.mda['projection_parameters']['a']
        pdict['b'] = self.mda['projection_parameters']['b']
        pdict['h'] = self.mda['projection_parameters']['h']
        pdict['ssp_lon'] = self.mda['projection_parameters']['ssp_longitude']

        if dataset_id['name'] == 'HRV':
            res = 1.0
            pdict['p_id'] = 'seviri_hrv'
        else:
            res = 3.0
            pdict['p_id'] = 'seviri_visir'

        service_mode = get_service_mode(pdict['ssp_lon'])
        pdict['a_name'] = 'msg_seviri_%s_%.0fkm' % (service_mode['name'], res)
        pdict[
            'a_desc'] = 'SEVIRI %s area definition with %.0f km resolution' % (
                service_mode['desc'], res)

        area_extent = self.get_area_extent(dataset_id)
        areas = list()
        for aex, nlines, ncolumns in zip(area_extent['area_extent'],
                                         area_extent['nlines'],
                                         area_extent['ncolumns']):
            pdict['nlines'] = nlines
            pdict['ncols'] = ncolumns
            areas.append(get_area_definition(pdict, aex))

        if len(areas) == 2:
            area = geometry.StackedAreaDefinition(areas[0], areas[1])
            area = area.squeeze()
        else:
            area = areas[0]

        return area
Esempio n. 17
0
 def _get_area_def(self):
     """Get the area definition of the band."""
     pdict = {
         'cfac': np.int32(self.mda['cfac']),
         'lfac': np.int32(self.mda['lfac']),
         'coff': np.float32(self.mda['coff']),
         'loff': self._get_line_offset(),
         'ncols': int(self.mda['number_of_columns']),
         'nlines': int(self.mda['number_of_lines']),
         'scandir': 'N2S',
         'a': float(self.mda['projection_parameters']['a']),
         'b': float(self.mda['projection_parameters']['b']),
         'h': float(self.mda['projection_parameters']['h']),
         'ssp_lon': float(self.mda['projection_parameters']['SSP_longitude']),
         'a_name': AREA_NAMES[self.area_id]['short'],
         'a_desc': AREA_NAMES[self.area_id]['long'],
         'p_id': 'geosmsg'
     }
     area_extent = get_area_extent(pdict)
     return get_area_definition(pdict, area_extent)
Esempio n. 18
0
    def get_area_def(self, dsid):

        pdict = {}
        pdict['a'] = self.mda['projection_parameters']['a']
        pdict['b'] = self.mda['projection_parameters']['b']
        pdict['h'] = self.mda['projection_parameters']['h']
        pdict['ssp_lon'] = self.mda['projection_parameters']['ssp_longitude']

        if dsid.name == 'HRV':
            pdict['nlines'] = self.mda['hrv_number_of_lines']
            pdict['ncols'] = self.mda['hrv_number_of_columns']
            pdict['a_name'] = 'geosmsg_hrv'
            pdict['a_desc'] = 'MSG/SEVIRI high resolution channel area'
            pdict['p_id'] = 'msg_hires'
        else:
            pdict['nlines'] = self.mda['number_of_lines']
            pdict['ncols'] = self.mda['number_of_columns']
            pdict['a_name'] = 'geosmsg'
            pdict['a_desc'] = 'MSG/SEVIRI low resolution channel area'
            pdict['p_id'] = 'msg_lowres'

        area = get_area_definition(pdict, self.get_area_extent(dsid))
        return area
Esempio n. 19
0
 def get_area_def(self, im_size, projection_longitude):
     """Create MVIRI area definition."""
     proj_params = self._get_proj_params(im_size, projection_longitude)
     extent = get_area_extent(proj_params)
     return get_area_definition(proj_params, extent)
Esempio n. 20
0
    def get_area_def(self, dsid):
        """Get the area definition of the band."""
        # Common parameters for both HRV and other channels
        nlines = int(self.mda['number_of_lines'])
        loff = np.float32(self.mda['loff'])
        pdict = {}
        pdict['cfac'] = np.int32(self.mda['cfac'])
        pdict['lfac'] = np.int32(self.mda['lfac'])
        pdict['coff'] = np.float32(self.mda['coff'])

        pdict['a'] = self.mda['projection_parameters']['a']
        pdict['b'] = self.mda['projection_parameters']['b']
        pdict['h'] = self.mda['projection_parameters']['h']
        pdict['ssp_lon'] = self.mda['projection_parameters']['SSP_longitude']

        pdict['nlines'] = nlines
        pdict['ncols'] = int(self.mda['number_of_columns'])
        if (self.prologue['ImageDescription']['Level15ImageProduction']
                         ['ImageProcDirection'] == 0):
            pdict['scandir'] = 'N2S'
        else:
            pdict['scandir'] = 'S2N'

        # Compute area definition for non-HRV channels:
        if dsid['name'] != 'HRV':
            pdict['loff'] = loff - nlines
            aex = self._get_area_extent(pdict)
            pdict['a_name'] = 'geosmsg'
            pdict['a_desc'] = 'MSG/SEVIRI low resolution channel area'
            pdict['p_id'] = 'msg_lowres'
            area = get_area_definition(pdict, aex)
            self.area = area
            return self.area

        segment_number = self.mda['segment_sequence_number']

        current_first_line = ((segment_number -
                               self.mda['planned_start_segment_number'])
                              * pdict['nlines'])

        # Or, if we are processing HRV:
        pdict['a_name'] = 'geosmsg_hrv'
        pdict['p_id'] = 'msg_hires'
        bounds = self.epilogue['ImageProductionStats']['ActualL15CoverageHRV'].copy()
        if self.fill_hrv:
            bounds['UpperEastColumnActual'] = 1
            bounds['UpperWestColumnActual'] = HRV_NUM_COLUMNS
            bounds['LowerEastColumnActual'] = 1
            bounds['LowerWestColumnActual'] = HRV_NUM_COLUMNS
            pdict['ncols'] = HRV_NUM_COLUMNS

        upper_south_line = bounds[
            'LowerNorthLineActual'] - current_first_line - 1
        upper_south_line = min(max(upper_south_line, 0), pdict['nlines'])
        lower_coff = (5566 - bounds['LowerEastColumnActual'] + 1)
        upper_coff = (5566 - bounds['UpperEastColumnActual'] + 1)

        # First we look at the lower window
        pdict['nlines'] = upper_south_line
        pdict['loff'] = loff - upper_south_line
        pdict['coff'] = lower_coff
        pdict['a_desc'] = 'MSG/SEVIRI high resolution channel, lower window'
        lower_area_extent = self._get_area_extent(pdict)
        lower_area = get_area_definition(pdict, lower_area_extent)

        # Now the upper window
        pdict['nlines'] = nlines - upper_south_line
        pdict['loff'] = loff - pdict['nlines'] - upper_south_line
        pdict['coff'] = upper_coff
        pdict['a_desc'] = 'MSG/SEVIRI high resolution channel, upper window'
        upper_area_extent = self._get_area_extent(pdict)
        upper_area = get_area_definition(pdict, upper_area_extent)

        area = geometry.StackedAreaDefinition(lower_area, upper_area)

        self.area = area.squeeze()
        return self.area