Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
put back deltaT test
  • Loading branch information
kandersolar committed Jun 20, 2023
commit c4a1adfe972c2ec7ee442c193217b8c36c60f621
31 changes: 31 additions & 0 deletions 31 pvlib/tests/test_spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@
theta0 = 90 - e0
Gamma = 14.340241
Phi = 194.340241
year = 1985
month = 2
year_array = np.array([-499, 500, 1000, 1500, 1800, 1860, 1900, 1950,
1970, 1985, 1990, 2000, 2005, 2050, 2150])
# `month_array` is used with `year_array` in `test_calculate_deltat`.
# Both arrays need to have the same length for the test, hence the duplicates.
month_array = np.array([1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 12, 12])
dt_actual = 54.413442486
dt_actual_array = np.array([1.7184831e+04, 5.7088051e+03, 1.5730419e+03,
1.9801820e+02, 1.3596506e+01, 7.8316585e+00,
-2.1171894e+00, 2.9289261e+01, 4.0824887e+01,
5.4724581e+01, 5.7426651e+01, 6.4108015e+01,
6.5038015e+01, 9.4952955e+01, 3.3050693e+02])
mix_year_array = np.full((10), year)
mix_month_array = np.full((10), month)
mix_year_actual = np.full((10), dt_actual)
mix_month_actual = mix_year_actual


class SpaBase:
"""Test functions common to numpy and numba spa"""
Expand Down Expand Up @@ -341,6 +359,19 @@ def test_earthsun_distance(self):
result = self.spa.earthsun_distance(unixtimes, 64.0, 1)
assert_almost_equal(R, result, 6)

def test_calculate_deltat(self):
result_mix_year = self.spa.calculate_deltat(mix_year_array, month)
assert_almost_equal(mix_year_actual, result_mix_year)

result_mix_month = self.spa.calculate_deltat(year, mix_month_array)
assert_almost_equal(mix_month_actual, result_mix_month)

result_array = self.spa.calculate_deltat(year_array, month_array)
assert_almost_equal(dt_actual_array, result_array, 3)

result_scalar = self.spa.calculate_deltat(year, month)
assert_almost_equal(dt_actual, result_scalar)


class NumpySpaTest(unittest.TestCase, SpaBase):
"""Import spa without compiling to numba then run tests"""
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.