Exemplo n.º 1
0
 def test_daynight_terminator_raises_exception_hour(self):
     """Test an exception is raised if hour out of range"""
     utc_hour = -10.0
     msg = 'Hour must be between 0 and 24.0'
     with self.assertRaisesRegex(ValueError, msg):
         daynight_terminator(self.longitudes,
                             self.day_of_year, utc_hour)
Exemplo n.º 2
0
 def test_daynight_terminator_raises_exception_day_of_year(self):
     """Test an exception is raised if day of year out of range"""
     day_of_year = 367
     msg = 'Day of the year must be between 0 and 365'
     with self.assertRaisesRegex(ValueError, msg):
         daynight_terminator(self.longitudes,
                             day_of_year, self.utc_hour)
Exemplo n.º 3
0
 def test_basic_sprint_360(self):
     """Test we get the terminator in spring with lon > 180."""
     longitudes = np.linspace(0.0, 360.0, 21)
     result = daynight_terminator(longitudes, 100, 0.0)
     expected_lats = np.array([
         82.7926115,
         82.44008918,
         81.15273499,
         77.95206547,
         68.09955141,
         2.64493534,
         -67.37718951,
         -77.7625883,
         -81.07852035,
         -82.41166928,
         -82.7926115,
         -82.44008918,
         -81.15273499,
         -77.9520655,
         -68.09955141,
         -2.64493534,
         67.37718951,
         77.7625883,
         81.07852035,
         82.41166928,
         82.7926115,
     ])
     self.assertArrayAlmostEqual(result, expected_lats)
Exemplo n.º 4
0
 def test_basic_winter_360(self):
     """Test we get the terminator in winter with lon > 180."""
     longitudes = np.linspace(0.0, 360.0, 21)
     result = daynight_terminator(longitudes, 10, 12.0)
     expected_lats = np.array([
         67.79151577,
         66.97565648,
         63.73454167,
         56.33476507,
         39.67331783,
         4.36090124,
         -34.38678745,
         -54.03238506,
         -62.69165892,
         -66.55543647,
         -67.79151577,
         -66.97565648,
         -63.73454167,
         -56.33476507,
         -39.67331783,
         -4.36090124,
         34.38678745,
         54.03238506,
         62.69165892,
         66.55543647,
         67.79151577,
     ])
     self.assertIsInstance(result, np.ndarray)
     self.assertArrayAlmostEqual(result, expected_lats)
Exemplo n.º 5
0
 def test_daynight_terminator_raises_exception_lon(self):
     """Test an exception is raised if latitudes out of range"""
     longitudes = np.array([-205.0, 0.0, 5.0])
     msg = 'Longitudes must be between -180.0 and 180.0'
     with self.assertRaisesRegex(ValueError, msg):
         daynight_terminator(longitudes, self.day_of_year, self.utc_hour)