-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
There was a problem hiding this 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
ForecastModel.cloud_cover_to_irradiance_liujordan
and replace withForecastModel.cloud_cover_to_irradiance_campbell_norman
- the
'liujordan'
option inForecastModel.cloud_cover_to_irradiance
.
pvlib/irradiance.py
Outdated
@@ -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): |
There was a problem hiding this comment.
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
.
pvlib/irradiance.py
Outdated
dhi = 0.3 * (1.0 - tau**airmass) * dni_extra * np.cos(np.radians(zenith)) | ||
ghi = dhi + dni * np.cos(np.radians(zenith)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"
pvlib/irradiance.py
Outdated
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* :py:func:`pvlib.irradiance.liujordan` is deprecated. | |
* ``pvlib.irradiance.liujordan`` is deprecated. |
test failures related to |
@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. |
not necessary |
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]>
FYI looks like this introduced a docs build warning in
|
docs/sphinx/source/api.rst
for API changes.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`
).Replaces
irradiance.liujordan
withirradiance.campbellnorman
.liujordan
is deprecated.