Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_lonlats(self):
if self.lons is not None and self.lats is not None:
return self.lons, self.lats
from pyorbital.orbital import Orbital
from pyorbital.geoloc import compute_pixels, get_lonlatalt
from pyorbital.geoloc_instrument_definitions import avhrr
if self.times is None:
self.times = time_seconds(self._data["timecode"], self.year)
scanline_nb = len(self.times)
scan_points = np.arange(0, 2048, 32)
# scan_points = np.arange(2048)
sgeom = avhrr(scanline_nb, scan_points, apply_offset=False)
# no attitude error
rpy = [0, 0, 0]
s_times = sgeom.times(
self.times[:, np.newaxis]).ravel()
# s_times = (np.tile(sgeom._times[0, :], (scanline_nb, 1)).astype(
# 'timedelta64[s]') + self.times[:, np.newaxis]).ravel()
orb = Orbital(self.platform_name)
pixels_pos = compute_pixels(orb, sgeom, s_times, rpy)
lons, lats, alts = get_lonlatalt(pixels_pos, s_times)
self.lons, self.lats = geo_interpolate(
lons.reshape((scanline_nb, -1)), lats.reshape((scanline_nb, -1)))
return self.lons, self.lats