def test_get_angles(self, get_satpos): """Test sun and satellite angle calculation.""" import numpy as np import dask.array as da from satpy.composites.viirs import ReflectanceCorrector # Patch methods get_satpos.return_value = 'sat_lon', 'sat_lat', 12345678 self.orbital.get_observer_look.return_value = 0, 0 self.astronomy.get_alt_az.return_value = 0, 0 area = mock.MagicMock() lons = np.zeros((5, 5)) lons[1, 1] = np.inf lons = da.from_array(lons, chunks=5) lats = np.zeros((5, 5)) lats[1, 1] = np.inf lats = da.from_array(lats, chunks=5) area.get_lonlats.return_value = (lons, lats) vis = mock.MagicMock(attrs={'area': area, 'start_time': 'start_time'}) # Compute angles psp = ReflectanceCorrector(name='dummy') psp.get_angles(vis) # Check arguments of get_orbserver_look() call, especially the altitude # unit conversion from meters to kilometers self.orbital.get_observer_look.assert_called_once() args = self.orbital.get_observer_look.call_args[0] self.assertEqual(args[:4], ('sat_lon', 'sat_lat', 12345.678, 'start_time')) self.assertIsInstance(args[4], da.Array) self.assertIsInstance(args[5], da.Array) self.assertEqual(args[6], 0)
def test_get_angles(self, get_satpos): """Test sun and satellite angle calculation.""" from satpy.composites.viirs import ReflectanceCorrector # Patch methods get_satpos.return_value = 'sat_lon', 'sat_lat', 12345678 self.orbital.get_observer_look.return_value = 0, 0 self.astronomy.get_alt_az.return_value = 0, 0 area = mock.MagicMock() area.get_lonlats_dask.return_value = 'lons', 'lats' vis = mock.MagicMock(attrs={'area': area, 'start_time': 'start_time'}) # Compute angles psp = ReflectanceCorrector(name='dummy') psp.get_angles(vis) # Check arguments of get_orbserver_look() call, especially the altitude # unit conversion from meters to kilometers self.orbital.get_observer_look.assert_called_with( 'sat_lon', 'sat_lat', 12345.678, 'start_time', 'lons', 'lats', 0)