def test_avhrr(self): """Test the definition of the avhrr instrument """ avh = avhrr(1, np.array([0, 1023.5 ,2047])) self.assertTrue(np.allclose(np.rad2deg(avh.fovs[:, 0]), np.array([55.37, 0, -55.37]))) avh = avhrr(1, np.array([0, 1023.5 ,2047]), 10) self.assertTrue(np.allclose(np.rad2deg(avh.fovs[:, 0]), np.array([10, 0, -10])))
def test_avhrr(self): """Test the definition of the avhrr instrument """ avh = avhrr(1, np.array([0, 1023.5, 2047])) self.assertTrue( np.allclose(np.rad2deg(avh.fovs[:, 0]), np.array([55.37, 0, -55.37]))) avh = avhrr(1, np.array([0, 1023.5, 2047]), 10) self.assertTrue( np.allclose(np.rad2deg(avh.fovs[:, 0]), np.array([10, 0, -10])))
def get_lonlats(self): """Get the lonlats.""" 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
def test_avhrr(self): """Test the definition of the avhrr instrument """ avh = avhrr(1, np.array([0, 1023.5, 2047])) self.assertTrue( np.allclose(np.rad2deg(avh.fovs[0]), np.array([55.37, 0, -55.37]))) avh = avhrr(1, np.array([0, 1023.5, 2047]), 10) self.assertTrue( np.allclose(np.rad2deg(avh.fovs[0]), np.array([10, 0, -10]))) # This is perhaps a bit odd, to require avhrr to accept floats for # the number of scans? FIXME! avh = avhrr(1.1, np.array([0, 1023.5, 2047]), 10) self.assertTrue( np.allclose(np.rad2deg(avh.fovs[0]), np.array([10, 0, -10])))
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
def test_case_4(): tle1 = "1 26536U 00055A 12312.31001555 .00000182 00000-0 12271-3 0 9594" tle2 = "2 26536 99.0767 356.5209 0011007 44.1314 316.0725 14.12803055625240" scanline_nb = 5428 scan_points = np.arange(24, 2048, 40) t = datetime(2012, 11, 7, 9, 33, 46, 526000) sgeom = avhrr(scanline_nb, scan_points, 55.25) rpy = [ np.deg2rad(-9.0 / 1000), np.deg2rad(-199.0 / 1000), np.deg2rad(-11.0 / 1000) ] s_times = sgeom.times(t) pixels_pos = compute_pixels((tle1, tle2), sgeom, s_times, rpy) pos_time = get_lonlatalt(pixels_pos, s_times) g = PolarFactory.create_scene("noaa", "16", "avhrr", t, orbit="62526") lons, lats = cached_lonlats(g) print np.sqrt( np.max(lons - pos_time[0].reshape(lons.shape))**2 + np.max(lats - pos_time[1].reshape(lats.shape))**2) print "max", np.max(abs(lons - pos_time[0].reshape(lons.shape))) print "max", np.max(abs(lats - pos_time[1].reshape(lats.shape))) plot(pos_time[0], pos_time[1], lons, lats)
def __init__(self, aoi, sat, instrument="AVHRR"): OrbitalLayer.__init__(self,aoi,sat,instrument) # instantiate orbital module config_file_path = "" try: config_file_path = os.environ['PYGRANULE_CONFIG_PATH'] except KeyError: print "pygranule config file path missing. Has the 'PYGRANULE_CONFIG_PATH' environment variable been set?" default_tle_file = config_file_path+"/default.tle" try: self.orbital = Orbital(sat,default_tle_file) except: print "Failed to open default tle file:", default_tle_file print "Downloading from internet:" try: self.orbital = Orbital(sat) except: raise OrbitalLayerError("Pyorbital Failed to fetch TLE from internet.") # create scan geometry - one scan line. if instrument == "AVHRR": scan_steps = np.arange(0,self.instrument_info['scan_steps'],self.instrument_info['scan_steps']/8-1) scan_steps[-1] = self.instrument_info['scan_steps']-1 self.scan_geom = avhrr(1,scan_steps) elif instrument == "VIIRS": self.scan_geom = viirs(1)
def test_case_3(): tle1 = "1 33591U 09005A 12345.45213434 .00000391 00000-0 24004-3 0 6113" tle2 = "2 33591 098.8821 283.2036 0013384 242.4835 117.4960 14.11432063197875" scanline_nb = 351 scan_points = np.arange(24, 2048, 40) t = datetime(2012, 12, 12, 4, 17, 1, 575000) sgeom = avhrr(scanline_nb, scan_points) rpy = (0, 0, 0) s_times = sgeom.times(t) pixels_pos = compute_pixels((tle1, tle2), sgeom, s_times, rpy) pos_time = get_lonlatalt(pixels_pos, s_times) g = PolarFactory.create_scene("noaa", "19", "avhrr", t, orbit="19812") lons, lats = cached_lonlats(g) print np.sqrt( np.max(lons - pos_time[0].reshape(lons.shape))**2 + np.max(lats - pos_time[1].reshape(lats.shape))**2) print "max", np.max(abs(lons - pos_time[0].reshape(lons.shape))) print "max", np.max(abs(lats - pos_time[1].reshape(lats.shape))) plot(pos_time[0], pos_time[1], lons, lats)
def test_case_5(): tle1 = "1 28654U 05018A 08167.42204778 -.00000193 00000-0 -82304-4 0 4671" tle2 = "2 28654 98.8667 108.3736 0013786 323.0689 36.9527 14.11168946158226" scanline_nb = 5121 scan_points = np.arange(24, 2048, 40) t = datetime(2008, 6, 16, 11, 48, 48, 616000) sgeom = avhrr(scanline_nb, scan_points) # 171, 105, 32 #rpy = [np.deg2rad(-37.0/1000), np.deg2rad(-11.0/1000), np.deg2rad(146.0/1000)] rpy = [0, 0, 0] rpy = [ np.deg2rad(171.0 / 1000), np.deg2rad(105.0 / 1000), np.deg2rad(32.0 / 1000) ] s_times = sgeom.times(t) pixels_pos = compute_pixels((tle1, tle2), sgeom, s_times, rpy) pos_time = get_lonlatalt(pixels_pos, s_times) g = PolarFactory.create_scene("noaa", "18", "avhrr", t, orbit="15838") lons, lats = cached_lonlats(g) print np.sqrt( np.max(lons - pos_time[0].reshape(lons.shape))**2 + np.max(lats - pos_time[1].reshape(lats.shape))**2) print "max", np.max(abs(lons - pos_time[0].reshape(lons.shape))) print "max", np.max(abs(lats - pos_time[1].reshape(lats.shape))) plot(pos_time[0], pos_time[1], lons, lats)
def test_case_1(): tle1 = "1 26536U 00055A 13076.42963155 .00000201 00000-0 13237-3 0 1369" tle2 = "2 26536 99.0540 128.2392 0010826 39.9070 85.2960 14.12848373643614" scanline_nb = 5680 scan_points = np.arange(24, 2048, 40) #t = datetime(2013, 3, 18, 8, 15, 21, 186000) t = datetime(2013, 3, 18, 8, 15, 22, 352000) #t = datetime(2013, 3, 18, 8, 15, 23, 186000) sgeom = avhrr(scanline_nb, scan_points, 55.25) rpy = [ np.deg2rad(-37.0 / 1000), np.deg2rad(-11.0 / 1000), np.deg2rad(146.0 / 1000) ] #rpy = [0, 0, 0] s_times = sgeom.times(t) print "s_times", s_times.dtype print(s_times[25::51]) pixels_pos = compute_pixels((tle1, tle2), sgeom, s_times, rpy) pos_time = get_lonlatalt(pixels_pos, s_times) # return pixels_pos g = PolarFactory.create_scene("noaa", "16", "avhrr", t, orbit="64374") lons, lats = cached_lonlats(g) # print lats.shape, pos_time[0].shape # print np.sqrt(np.max(lons - pos_time[0].reshape(lons.shape)) ** 2 + np.max(lats - pos_time[1].reshape(lats.shape)) ** 2) # print "max", np.max(abs(lons - pos_time[0].reshape(lons.shape))) # print "max", np.max(abs(lats - pos_time[1].reshape(lats.shape))) print lons.shape plot(pos_time[0], pos_time[1], lons, lats)
def __init__(self, aoi, sat, instrument="AVHRR"): OrbitalLayer.__init__(self, aoi, sat, instrument) # instantiate orbital module config_file_path = "" try: config_file_path = os.environ['PYGRANULE_CONFIG_PATH'] except KeyError: print "pygranule config file path missing. Has the 'PYGRANULE_CONFIG_PATH' environment variable been set?" default_tle_file = config_file_path + "/default.tle" try: self.orbital = Orbital(sat, default_tle_file) except: print "Failed to open default tle file:", default_tle_file print "Downloading from internet:" try: self.orbital = Orbital(sat) except: raise OrbitalLayerError( "Pyorbital Failed to fetch TLE from internet.") # create scan geometry - one scan line. if instrument == "AVHRR": scan_steps = np.arange(0, self.instrument_info['scan_steps'], self.instrument_info['scan_steps'] / 8 - 1) scan_steps[-1] = self.instrument_info['scan_steps'] - 1 self.scan_geom = avhrr(1, scan_steps) elif instrument == "VIIRS": self.scan_geom = viirs(1)
def test_avhrr(self): """Test the definition of the avhrr instrument """ avh = avhrr(1, np.array([0, 1023.5, 2047])) self.assertTrue(np.allclose(np.rad2deg(avh.fovs[0]), np.array([55.37, 0, -55.37]))) avh = avhrr(1, np.array([0, 1023.5, 2047]), 10) self.assertTrue(np.allclose(np.rad2deg(avh.fovs[0]), np.array([10, 0, -10]))) # This is perhaps a bit odd, to require avhrr to accept floats for # the number of scans? FIXME! avh = avhrr(1.1, np.array([0, 1023.5, 2047]), 10) self.assertTrue(np.allclose(np.rad2deg(avh.fovs[0]), np.array([10, 0, -10])))
def _get_avhrr_tiepoints(self, scan_points, scanline_nb): sgeom = avhrr(scanline_nb, scan_points, apply_offset=False) # no attitude error rpy = [0, 0, 0] s_times = sgeom.times(self.times[:, np.newaxis]) orb = Orbital(self.platform_name) pixels_pos = compute_pixels(orb, sgeom, s_times, rpy) lons, lats, alts = get_lonlatalt(pixels_pos, s_times) return lons, lats