Пример #1
0
    def _compute_missing_lonlat(self, missed_utcs):
        """compute lon lat values using pyorbital"""
        tic = datetime.datetime.now()

        scan_rate = datetime.timedelta(milliseconds=1/self.scan_freq).total_seconds()
        sgeom = avhrr_gac(missed_utcs.astype(datetime.datetime),
                          self.scan_points, frequency=scan_rate)
        t0 = missed_utcs[0].astype(datetime.datetime)
        s_times = sgeom.times(t0)
        tle1, tle2 = self.get_tle_lines()

        rpy = self.get_attitude_coeffs()
        pixels_pos = compute_pixels((tle1, tle2), sgeom, s_times, rpy)
        pos_time = get_lonlatalt(pixels_pos, s_times)

        missed_lons, missed_lats = pos_time[:2]

        pixels_per_line = self.lats.shape[1]
        missed_lons = missed_lons.reshape(-1, pixels_per_line)
        missed_lats = missed_lats.reshape(-1, pixels_per_line)

        toc = datetime.datetime.now()
        LOG.warning("Computation of geolocation: %s", str(toc - tic))

        return missed_lons, missed_lats
Пример #2
0
    def compute_lonlat(self, width, utcs=None, clock_drift_adjust=True):
        """Compute lat/lon coordinates.

        Args:
            width: Number of coordinates per scanlines
            utcs: Scanline timestamps
            clock_drift_adjust: If True, adjust clock drift.
        """
        tle1, tle2 = self.get_tle_lines()

        scan_points = np.arange(3.5, 2048, 5)

        if utcs is None:
            utcs = self.get_times()

        # adjusting clock for drift
        tic = datetime.datetime.now()
        if clock_drift_adjust:
            from pygac.clock_offsets_converter import get_offsets
            try:
                offset_times, clock_error = get_offsets(self.spacecraft_name)
            except KeyError:
                LOG.info("No clock drift info available for %s",
                         self.spacecraft_name)
            else:
                offset_times = np.array(offset_times, dtype='datetime64[ms]')
                offsets = np.interp(utcs.astype(np.uint64),
                                    offset_times.astype(np.uint64),
                                    clock_error)
                utcs -= (offsets * 1000).astype('timedelta64[ms]')

        t = utcs[0].astype(datetime.datetime)

        if "constant_yaw_attitude_error" in self.head.dtype.fields:
            rpy = np.deg2rad([
                self.head["constant_roll_attitude_error"] / 1e3,
                self.head["constant_pitch_attitude_error"] / 1e3,
                self.head["constant_yaw_attitude_error"] / 1e3
            ])
        else:
            rpy = [0, 0, 0]

        LOG.info("Using rpy: %s", str(rpy))

        from pyorbital.geoloc_instrument_definitions import avhrr_gac
        from pyorbital.geoloc import compute_pixels, get_lonlatalt
        sgeom = avhrr_gac(utcs.astype(datetime.datetime), scan_points, 55.385)
        s_times = sgeom.times(t)

        pixels_pos = compute_pixels((tle1, tle2), sgeom, s_times, rpy)
        pos_time = get_lonlatalt(pixels_pos, s_times)

        toc = datetime.datetime.now()

        LOG.warning("Computation of geolocation: %s", str(toc - tic))

        lons, lats = pos_time[:2]

        return lons.reshape(-1, width), lats.reshape(-1, width)
Пример #3
0
    def compute_lonlat(self, width, utcs=None, clock_drift_adjust=True):
        """Compute lat/lon coordinates.

        Args:
            width: Number of coordinates per scanlines
            utcs: Scanline timestamps
            clock_drift_adjust: If True, adjust clock drift.

        """
        if utcs is None:
            utcs = self.get_times()

        # adjusting clock for drift
        tic = datetime.datetime.now()
        if clock_drift_adjust:
            from pygac.clock_offsets_converter import get_offsets
            try:
                offset_times, clock_error = get_offsets(self.spacecraft_name)
            except KeyError:
                LOG.info("No clock drift info available for %s",
                         self.spacecraft_name)
            else:
                offset_times = np.array(offset_times, dtype='datetime64[ms]')
                offsets = np.interp(utcs.astype(np.uint64),
                                    offset_times.astype(np.uint64),
                                    clock_error)
                utcs = utcs - (offsets * 1000).astype('timedelta64[ms]')

        t = utcs[0].astype(datetime.datetime)

        if "constant_yaw_attitude_error" in self.head.dtype.fields:
            rpy = np.deg2rad([
                self.head["constant_roll_attitude_error"] / 1e3,
                self.head["constant_pitch_attitude_error"] / 1e3,
                self.head["constant_yaw_attitude_error"] / 1e3
            ])
        else:
            try:
                # This needs to be checked thoroughly first
                # rpy_spacecraft = rpy_coeffs[self.spacecraft_name]
                # rpy = [rpy_spacecraft['roll'],
                #        rpy_spacecraft['pitch'],
                #        rpy_spacecraft['yaw']]
                # LOG.debug("Using static attitude correction")
                raise KeyError
            except KeyError:
                LOG.debug("Not applying attitude correction")
                rpy = [0, 0, 0]

        LOG.info("Using rpy: %s", str(rpy))

        from pyorbital.geoloc_instrument_definitions import avhrr_gac
        from pyorbital.geoloc import compute_pixels, get_lonlatalt
        # TODO: Are we sure all satellites have this scan width in degrees ?
        sgeom = avhrr_gac(utcs.astype(datetime.datetime), self.scan_points,
                          55.385)
        s_times = sgeom.times(t)
        tle1, tle2 = self.get_tle_lines()

        pixels_pos = compute_pixels((tle1, tle2), sgeom, s_times, rpy)
        pos_time = get_lonlatalt(pixels_pos, s_times)

        toc = datetime.datetime.now()

        LOG.warning("Computation of geolocation: %s", str(toc - tic))

        lons, lats = pos_time[:2]

        return lons.reshape(-1, width), lats.reshape(-1, width)