Exemple #1
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
    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
Exemple #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
Exemple #4
0
    def _get_area_extent(self, pdict):
        """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>`_.
        """
        aex = get_area_extent(pdict)

        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
            aex = (aex[0] + xadj, aex[1] + yadj,
                   aex[2] + xadj, aex[3] + yadj)

        return aex
Exemple #5
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
 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
Exemple #7
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
Exemple #8
0
    def test_geos_area(self):
        """Test area extent calculation with N->S scan then S->N scan."""
        # North -> South full disk
        pdict, extent = self.make_pdict_ext(1, 'N2S')
        aex = get_area_extent(pdict)
        np.testing.assert_allclose(aex, extent)

        # South -> North full disk
        pdict, extent = self.make_pdict_ext(1, 'S2N')
        aex = get_area_extent(pdict)
        np.testing.assert_allclose(aex, extent)

        # North -> South one sector
        pdict, extent = self.make_pdict_ext(2, 'N2S')
        aex = get_area_extent(pdict)
        np.testing.assert_allclose(aex, extent)

        # South -> North one sector
        pdict, extent = self.make_pdict_ext(2, 'S2N')
        aex = get_area_extent(pdict)
        np.testing.assert_allclose(aex, extent)
Exemple #9
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)
 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)