Skip to content

Convert irradiance.liujordan to irradiance.campbell_norman #1104

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 10 commits into from
Dec 10, 2020

Conversation

cwhanse
Copy link
Member

@cwhanse cwhanse commented Dec 8, 2020

  • Closes Docstring for irradiance.liujordan isn't clear #1100
  • I am familiar with the contributing guidelines
  • Tests added
  • Updates entries to docs/sphinx/source/api.rst for API changes.
  • Adds description and name entries in the appropriate "what's new" file in docs/sphinx/source/whatsnew for all changes. Includes link to the GitHub Issue with :issue:`num` or this Pull Request with :pull:`num`. Includes contributor name and/or GitHub username (link with :ghuser:`user`).
  • New code is fully documented. Includes numpydoc compliant docstrings, examples, and comments where necessary.
  • Pull request is nearly complete and ready for detailed review.
  • Maintainer: Appropriate GitHub Labels and Milestone are assigned to the Pull Request and linked Issue.

Replaces irradiance.liujordan with irradiance.campbellnorman. liujordan is deprecated.

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.

also need to deprecate

  1. ForecastModel.cloud_cover_to_irradiance_liujordan and replace with ForecastModel.cloud_cover_to_irradiance_campbell_norman
  2. the 'liujordan' option in ForecastModel.cloud_cover_to_irradiance.

@@ -2184,6 +2187,58 @@ def erbs(ghi, zenith, datetime_or_doy, min_cos_zenith=0.065, max_zenith=87):
return data


def campbellnorman(zenith, transmittance, pressure=101325.0, dni_extra=1367.0):
Copy link
Member

Choose a reason for hiding this comment

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

Mild preference for campbell_norman.

Comment on lines 2228 to 2229
dhi = 0.3 * (1.0 - tau**airmass) * dni_extra * np.cos(np.radians(zenith))
ghi = dhi + dni * np.cos(np.radians(zenith))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
dhi = 0.3 * (1.0 - tau**airmass) * dni_extra * np.cos(np.radians(zenith))
ghi = dhi + dni * np.cos(np.radians(zenith))
cos_zen = np.cos(np.radians(zenith))
dhi = 0.3 * (1.0 - tau**airmass) * dni_extra * cos_zen
ghi = dhi + dni * cos_zen

@@ -295,6 +296,17 @@ def test_liujordan():
assert_frame_equal(out, expected)
Copy link
Member

Choose a reason for hiding this comment

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

This test is going to emit a deprecation warning and we want to avoid that. We could delete it or we could skip the new test_deprecated_09 test, add @fail_on_pvlib_version('0.9') around this test, and add the with pytest.warns... here

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer the option after "or"

@@ -2242,6 +2297,10 @@ def liujordan(zenith, transmittance, airmass, dni_extra=1367.0):
return irrads


liujordan = deprecated('0.8', alternative='campbellnormam',
name='liujordan', removal='0.9')(liujordan)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think there's anything wrong with this, but it might be a little more clear if we change the function definition to _liujordan so that readers of the code cannot miss the deprecation wrapper.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not needed if the deprecation warning and @fail_on_pvlib_version('0.9') are made part of the old test_liujordan, right?

Copy link
Member

Choose a reason for hiding this comment

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

My concern is just that we're redefining what liujordan points to (first it points to the original function, then we redefine it to point to a function that wraps the original function). There's no practical difference for a user of the public API, but a reader of the source code could miss the redefinition of liujordan.

def _liujordan(...)
    # the original docstring and code

liujordan = deprecated(...)(_liujordan)

It's minor and I'm fine to leave it as is.

The tests as written in the latest commit (b2ba8a6) should continue to work without modification.

Copy link
Member Author

Choose a reason for hiding this comment

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

remove irradiance.liujordan from api.rst?

Copy link
Member

Choose a reason for hiding this comment

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

yes

@@ -9,7 +9,7 @@ Breaking changes

Deprecations
~~~~~~~~~~~~

* :py:func:`pvlib.irradiance.liujordan` is deprecated.
Copy link
Member

Choose a reason for hiding this comment

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

these links will break and cause documentation build warnings when we remove the function, so I'd rather use double ticks now

@@ -9,7 +9,7 @@ Breaking changes

Deprecations
~~~~~~~~~~~~

* :py:func:`pvlib.irradiance.liujordan` is deprecated.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* :py:func:`pvlib.irradiance.liujordan` is deprecated.
* ``pvlib.irradiance.liujordan`` is deprecated.

@cwhanse cwhanse added this to the 0.8.1 milestone Dec 9, 2020
@cwhanse
Copy link
Member Author

cwhanse commented Dec 9, 2020

test failures related to get_psm3

@cwhanse
Copy link
Member Author

cwhanse commented Dec 9, 2020

@wholmgren do you think it is worthwhile / necessary to add tests for forecast.cloud_cover_to_irradiance_how for how='campbell_norman' and 'liujordan'? The latter would only be a deprecation test. It looks like it would take a bit of work to assemble the test input.

@wholmgren
Copy link
Member

not necessary

@cwhanse
Copy link
Member Author

cwhanse commented Dec 9, 2020

test failures are get_psm3. coverage decreases because we're not testing the deprecated forecast method. I didn't remove the deprecated method.

correct misspelling

Co-authored-by: Will Holmgren <[email protected]>
@wholmgren wholmgren changed the title Convert irradiance.liujordan to irradiance.campbellnorman Convert irradiance.liujordan to irradiance.campbell_norman Dec 10, 2020
@wholmgren wholmgren merged commit 74df8b6 into pvlib:master Dec 10, 2020
@cwhanse cwhanse deleted the liu branch December 11, 2020 15:13
@kandersolar
Copy link
Member

FYI looks like this introduced a docs build warning in forecast.rst:

>>>-------------------------------------------------------------------------
Warning in /home/docs/checkouts/readthedocs.org/user_builds/pvlib-python/checkouts/latest/docs/sphinx/source/forecasts.rst at block ending on line 281
Specify :okwarning: as an option in the ipython:: block to suppress this message
----------------------------------------------------------------------------
/home/docs/checkouts/readthedocs.org/user_builds/pvlib-python/checkouts/latest/pvlib/forecast.py:637: pvlibDeprecationWarning: The Forecast.cloud_cover_to_irradiance_liujordan function was deprecated in pvlib 0.8 and will be removed in 0.9. Use Forecast.cloud_cover_to_irradiance_campbell_norman instead.
  cloud_cover, **kwargs)
<<<-------------------------------------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docstring for irradiance.liujordan isn't clear
3 participants