Conversation
|
Locally, this improves runtime for DISC (also used in GTI-DIRINT) by about 20% (from ~25ns/loop to 20ns/loop) in "main":>>> %timeit test_disc_value
# 27.4 ns ± 0.381 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
>>> %timeit test_disc_overirradiance
# 25.6 ns ± 0.378 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)using Horner's>>> %timeit test_disc_value
# 19.5 ns ± 0.526 ns per loop (mean ± std. dev. of 7 runs, 100,000,000 loops each)
>>> %timeit test_disc_overirradiance
# 19.6 ns ± 0.815 ns per loop (mean ± std. dev. of 7 runs, 100,000,000 loops each) |
|
@pvlib/pvlib-maintainer I'm not sure this requires a what's new entry, it's a very minor change, but it does improve runtime for DISC which is used in GTI-DIRINT, but ~20% possibly. |
|
I think we're ok here with a what's new entry |
update whatsnew
|
@mikofski I actually meant to write "without a whatsnew" but no harm in having it :) Could you fix the stickler complaints? |
|
I like Anton’s idea in #1180 (comment):
anyone opposed? |
|
I changed diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py
index 082370d..e916400 100644
--- a/pvlib/irradiance.py
+++ b/pvlib/irradiance.py
@@ -1481,15 +1481,15 @@ def _disc_kn(clearness_index, airmass, max_airmass=12):
am = np.minimum(am, max_airmass) # GH 450
- # Use Horner's method to compure polynomials efficiently
- bools = (kt <= 0.6)
- a = np.where(bools,
+ is_cloudy= (kt <= 0.6)
+ # Use Horner's method to compute polynomials efficiently
+ a = np.where(is_cloudy,
0.512 + kt*(-1.56 + kt*(2.286 - 2.222*kt)),
-5.743 + kt*(21.77 + kt*(-27.49 + 11.56*kt)))
- b = np.where(bools,
+ b = np.where(is_cloudy,
0.37 + 0.962*kt,
41.4 + kt*(-118.5 + kt*(66.05 + 31.9*kt)))
- c = np.where(bools,
+ c = np.where(is_cloudy,
-0.28 + kt*(0.932 - 2.048*kt),
-47.01 + kt*(184.2 + kt*(-222.0 + 73.81*kt))) |
|
@pvlib/pvlib-core please review |
kandersolar
left a comment
There was a problem hiding this comment.
@mikofski is there supposed to be a new asv benchmark included in the PR, or was that just for testing locally?
I changed bools to is_clear not is_cloudy because it is defined for kt<=0.6:
Doesn't low kt correspond to non-clear sky condition? Maybe you are still thinking about diffuse fraction from the Boland PR :P
Fix link to Horner’s method
XXX: don't merge before merging ASV benchmarks fordisc()and perhaps functions that usedisc(), a WIPdocs/sphinx/source/api.rstfor API changes. - unnecessary?docs/sphinx/source/whatsnewfor 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`).Speed up DISC by using Horner's method for polynomials. Don't merge. until ASV benchmarks have been merge to measure runtime of existing
disc()method and other functions that use it