-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Remove pandas series usage from ephemeris #2626
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
base: main
Are you sure you want to change the base?
Conversation
|
@pvlib I think this is ready to review |
|
@dfulu would be interested to know the difference in performance with 1000s of timesteps. |
On my machine with 1000 timestamps it goes from 2.88 ms ± 22.1 μs to 1.01 ms ± 9.47 μs I'm not certain, but I think the overhead of using the pandas series as in the current implementation is constant. i.e. it would add ~2ms no matter how many timestamps it is for |
|
We have benchmarking suite for exactly this kind of PR: https://github.com/pvlib/pvlib-python/tree/main/benchmarks It includes ephemeris pvlib-python/benchmarks/benchmarks/solarposition.py Lines 32 to 34 in 770bcd1
|
d95120e to
68dd4f7
Compare
|
@dfulu code changes look good to me. Please add a note to docs\sphinx\source\whatsnew v0.13.2.rst |
|
@cwhanse sorry for the delay. I've added the note to v0.13.2.rst. Let me know if I'm too last for that release, or anything else you need from me |
Hi maintainers,
I'd like to propose these changes which seed up the ephemeris function significantly when using very few timestamps.
This PR removes the use of the pandas series towards the end of that function and instead replaces its use with masking. This is more efficient and avoids the slow pandas indexing logic. The PR also constructs the pandas DataFrame in a single shot rather that the multiple column assigns that are currently used.
In some local testing using 16 timesteps, I found that this reduced the average time for the function to run from 2.5ms to 0.5ms.
docs/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`).remote-data) and Milestone are assigned to the Pull Request and linked Issue.