Skip to content

Correct day angle in ASCE extraterrestrial irradiance model #712

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 6 commits into from
May 8, 2019

Conversation

cwhanse
Copy link
Member

@cwhanse cwhanse commented May 7, 2019

pvlib python pull request guidelines

Thank you for your contribution to pvlib python! You may delete all of these instructions except for the list below.

You may submit a pull request with your code at any stage of completion.

The following items must be addressed before the code can be merged. Please don't hesitate to ask for help if you're unsure of how to accomplish any of the items below:

  • Closes Bug in extraterrestrial radiation calculation #211
  • I am familiar with the contributing guidelines.
  • Fully tested. Added and/or modified tests to ensure correct behavior for all reasonable inputs. Tests (usually) must pass on the TravisCI and Appveyor testing services.
  • Updates entries to docs/sphinx/source/api.rst for API changes.
  • Adds description and name entries in the appropriate docs/sphinx/source/whatsnew file for all changes.
  • Code quality and style is sufficient. Passes LGTM and SticklerCI checks.
  • New code is fully documented. Includes sphinx/numpydoc compliant docstrings and comments in the code where necessary.
  • Pull request is nearly complete and ready for detailed review.

Brief description of the problem and proposed solution (if not already fully described in the issue linked to above):

Change day angle equation to 2 pi / 365 * doy, where doy = 1, …, 365

Copy link
Member

@mikofski mikofski left a comment

Choose a reason for hiding this comment

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

LGTM! Can we add the ASCE reference you mentioned in the issue #211 ?

ASCE (2005), THE ASCE STANDARDIZED REFERENCE EVAPOTRANSPIRATION EQUATION, Environmental and Water Resources Institute of the American Civil Engineers, Ed. R. G. Allen et al.

also fix the what's new conflict

also, I like the TODO: to deligate to submethods - for a rainy day but good idea to keep in mind

@wholmgren wholmgren added the bug label May 7, 2019
@wholmgren wholmgren added this to the 0.6.2 milestone May 7, 2019
Copy link
Member

@wholmgren wholmgren left a comment

Choose a reason for hiding this comment

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

I don't understand the LGTM alert and codecov result. Suggests that the ASCE method is not actually being tested but it looks like it should be. The associated test looks ok though.

@wholmgren
Copy link
Member

wholmgren commented May 7, 2019

Ah, the test fails to pass the method kwarg to the function. Lots of failures when fixed, but these can be mitigated by increasing the test tolerance. Suggested code:

@pytest.mark.parametrize('testval, expected', [
    (doy, value),
    (np.float64(doy), value),
    (dt_date, value),
    (dt_datetime, value),
    (dt_np64, value),
    (np.array([doy]), np.array([value])),
    (pd.Series([doy]), np.array([value])),
    (dt_index, pd.Series([value], index=dt_index)),
    (timestamp, value)
])
@pytest.mark.parametrize('method', [
    'asce', 'spencer', 'nrel', pytest.param('pyephem', marks=requires_ephem)])
def test_get_extra_radiation(testval, expected, method):
    out = irradiance.get_extra_radiation(testval, method=method)
    assert_allclose(out, expected, atol=10)

Copy link
Member

@wholmgren wholmgren left a comment

Choose a reason for hiding this comment

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

Still don't understand the LGTM alert. I confirmed that the kwarg works:

In [5]: import pvlib

In [6]: pvlib.__version__
Out[6]: '0.6.1+23.g12d0678.dirty'

In [7]: pvlib.solarposition._calculate_simple_day_angle?
Signature: pvlib.solarposition._calculate_simple_day_angle(dayofyear, offset=1)
Docstring:
Calculates the day angle for the Earth's orbit around the Sun.

Parameters
----------
dayofyear : numeric
offset : int, default 1
    For the Spencer method, offset=1; for the ASCE method, offset=0

Returns
-------
day_angle : numeric
File:      ~/git_repos/pvlib-python/pvlib/solarposition.py
Type:      function

In [8]: pvlib.solarposition._calculate_simple_day_angle(0)
Out[8]: -0.01721420632103996

In [9]: pvlib.solarposition._calculate_simple_day_angle(0, offset=0)
Out[9]: 0.0

Appveyor failure is unrelated (#713). Merge when ready.

@cwhanse
Copy link
Member Author

cwhanse commented May 8, 2019

Thanks @Schmelzersolar for investigating and reporting the issue.

@cwhanse cwhanse merged commit e5bcf68 into pvlib:master May 8, 2019
@cwhanse cwhanse deleted the asce branch May 8, 2019 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug in extraterrestrial radiation calculation
3 participants