예제 #1
0
 def test_solar_hour_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):
         calc_solar_hour_angle(self.longitudes, day_of_year,
                               self.utc_hour)
예제 #2
0
 def test_basic_solar_hour_angle_array(self):
     """Test the calc of solar hour_angle for an array of longitudes"""
     result = calc_solar_hour_angle(self.longitudes, self.day_of_year,
                                    self.utc_hour)
     expected_result = np.array(
         [-1.7832741, 8.2167259, -11.7832741, 178.2167259, -180.7832741])
     self.assertIsInstance(result, np.ndarray)
     self.assertArrayAlmostEqual(result, expected_result)
예제 #3
0
 def test_basic_solar_hour_angle_array_360(self):
     """Test the calc of solar hour_angle for longitudes > 180"""
     longitudes = np.array([0.0, 10.0, 350.0, 180.0, 181.0])
     result = calc_solar_hour_angle(longitudes, self.day_of_year,
                                    self.utc_hour)
     expected_result = np.array([-1.7832741, 8.2167259, 360.0-11.7832741,
                                 178.2167259, 360.0-180.7832741])
     self.assertIsInstance(result, np.ndarray)
     self.assertArrayAlmostEqual(result, expected_result)
예제 #4
0
 def test_solar_hour_raises_exception_lon(self):
     """Test an exception is raised if latitudes out of range"""
     longitudes = np.array([0.0, 10.0, -10.0, 181.0, -179.0])
     msg = 'Longitudes must be between -180.0 and 180.0'
     with self.assertRaisesRegex(ValueError, msg):
         calc_solar_hour_angle(longitudes, self.day_of_year, self.utc_hour)
예제 #5
0
 def test_basic_solar_hour_angle(self):
     """Test the calculation of solar hour_angle. Single Value"""
     result = calc_solar_hour_angle(0.0, 10, 0.0)
     expected_result = -181.783274102
     self.assertIsInstance(result, float)
     self.assertAlmostEqual(result, expected_result)
예제 #6
0
 def test_solar_hour_raises_exception_hour(self):
     """Test an exception is raised if latitudes out of range"""
     utc_hour = -10.0
     msg = 'Hour must be between 0 and 24.0'
     with self.assertRaisesRegex(ValueError, msg):
         calc_solar_hour_angle(self.longitudes, self.day_of_year, utc_hour)