Vectorize pvlib.bifacial.utils._vf_ground_sky_2d across surface_tilt#1682
Vectorize pvlib.bifacial.utils._vf_ground_sky_2d across surface_tilt#1682kandersolar merged 20 commits intopvlib:mainfrom
pvlib.bifacial.utils._vf_ground_sky_2d across surface_tilt#1682Conversation
also a few other micro-optimizations
|
It occurred to me that this PR might have objectionably large memory requirements (similar to #1402) so I did some memory profiling and found that a call to The memory load is still larger than I'd like, but with that reduction I'd say it's an acceptable price to pay for the runtime improvement. I'm curious what others think. |
|
1 year of 1 minute data is about half a million points. If memory usage scales linearly with that dimension, then I think some users will run into a problem. |
|
Good point. Well, taking full advantage of numpy's Updated plot: |
|
If we add a |
|
I'm not a numpy expert, especially in regards to performance, but this looks reasonable to me. Perhaps a numba element by element calculation would combine readability, performance, and reasonable memory usage. Perhaps. |
|
Ok, I added a new Here's an asv runtime comparison: |
|
This PR is ready for another look if @cwhanse or @wholmgren (or anyone else, of course) is interested. The new vectorized calculation path is now gated behind an optional |
cwhanse
left a comment
There was a problem hiding this comment.
@kanderso-nrel this PR changes the output (shape of vf) of bifacial.utils._solar_projection_tangent. That's a private function, so I suppose a deprecation is optional. I'm OK without deprecation, but raising the issue in case there are differing opinions.
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>


[ ] Tests added[ ] Updates entries indocs/sphinx/source/referencefor API changes.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`).[ ] New code is fully documented. Includes numpydoc compliant docstrings, examples, and comments where necessary.remote-data) and Milestone are assigned to the Pull Request and linked Issue.I could not get satisfactory benchmarking results using asv (perhaps this computer is too noisy for asv's defaults?) so I wrote a one-off benchmarking script that yielded the following runtime comparison for
infinite_sheds.get_irradiance()with inputs for a generic single-axis tracking simulation:I don't deal with multidimensional numpy arrays very often. I will happily make changes if what I've done here is unnecessarily clunky or inefficient and someone suggests improvements.