Skip to content

Issue 165: Added calculate_deltaT function into spa.py #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Oct 21, 2016
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/sphinx/source/whatsnew/v0.4.2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Enhancements
~~~~~~~~~~~~

* Adding a complete_irradiance method to the ModelChain to make it possible to calculate missing irradiation data from the existing columns [beta] (:issue:`239`)
* Added calculate_deltat method to the spa module to calculate the time difference between terrestrial time and UT1. Specfiying a scalar is sufficient for most calculations. (:issue:`165`)
* Added calculate_deltat method to the spa module to calculate the time difference between terrestrial time and UT1. Specifying a scalar is sufficient for most calculations. (:issue:`165`)

Code Contributors
~~~~~~~~~~~~~~~~~
Expand Down
1 change: 0 additions & 1 deletion pvlib/test/test_irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def test_extraradiation(input, expected, method):


@requires_numba
@pytest.mark.xfail(raises=ValueError, reason = 'spa.calculate_deltat not implemented for numba yet')
def test_extraradiation_nrel_numba():
result = irradiance.extraradiation(times, method='nrel', how='numba', numthreads=8)
assert_allclose(result, [1322.332316, 1322.296282, 1322.261205, 1322.227091])
Expand Down
24 changes: 18 additions & 6 deletions pvlib/test/test_solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ def expected_solpos():
'apparent_elevation': 39.888378},
index=['2003-10-17T12:30:30Z'])

@pytest.fixture()
def expected_solpos_multi():
return pd.DataFrame({'elevation': [39.872046, 39.505196],
'apparent_zenith': [50.111622, 50.478260],
'azimuth': [194.340241, 194.311132],
'apparent_elevation': [39.888378, 39.521740]},
index=[['2003-10-17T12:30:30Z', '2003-10-18T12:30:30Z']])

# the physical tests are run at the same time as the NREL SPA test.
# pyephem reproduces the NREL result to 2 decimal places.
# this doesn't mean that one code is better than the other.
Expand Down Expand Up @@ -310,19 +318,23 @@ def test_get_solarposition_altitude(altitude, expected):
assert_frame_equal(this_expected, ephem_data[this_expected.columns])


@pytest.mark.xfail(raises=ValueError, reason = 'spa.calculate_deltat not implemented for numba yet')
@pytest.mark.parametrize(
"delta_t, expected", [
(None, expected_solpos()),
(67.0, expected_solpos())
"delta_t, method, expected", [
(None, 'nrel_numpy', expected_solpos_multi()),
(67.0, 'nrel_numpy', expected_solpos_multi()),
(None, 'nrel_numba', expected_solpos_multi()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Only thing is that you need to decorate just this one parameter set so that we don't get XPASS results for the others. I think there's an example in the pytest docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea i was wondering about that. thanks for the heads up

(67.0, 'nrel_numba', expected_solpos_multi())
])
def test_get_solarposition_deltat(delta_t,expected):
def test_get_solarposition_deltat(delta_t, method, expected):
times = pd.date_range(datetime.datetime(2003,10,17,13,30,30),
periods=1, freq='D', tz=golden.tz)
periods=2, freq='D', tz=golden.tz)
ephem_data = solarposition.get_solarposition(times, golden.latitude,
golden.longitude,
pressure=82000,
delta_t=delta_t,
temperature=11)
temperature=11,
method=method)
this_expected = expected.copy()
this_expected.index = times
this_expected = np.round(this_expected, 5)
Expand Down