Example #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']

        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
Example #2
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
Example #3
0
    def _get_area_extent(self):
        """Calculate area extent of dataset."""
        # Load and convert x/y coordinates to degrees as required by the make_ext function
        x = self.nc['x']
        y = self.nc['y']
        x_deg = np.degrees(x)
        y_deg = np.degrees(y)

        # Select the extreme points and calcualte area extent (not: these refer to pixel center)
        ll_x, ur_x = -x_deg.values[0], -x_deg.values[-1]
        ll_y, ur_y = y_deg.values[-1], y_deg.values[0]
        h = float(self._projection.attrs['perspective_point_height'])
        area_extent_pixel_center = make_ext(ll_x, ur_x, ll_y, ur_y, h)

        # Shift area extent by half a pixel to get the area extent w.r.t. the dataset/pixel corners
        scale_factor = (x[1:]-x[0:-1]).values.mean()
        res = abs(scale_factor) * h
        area_extent = tuple(i + res/2 if i > 0 else i - res/2 for i in area_extent_pixel_center)

        return area_extent