-
-
Notifications
You must be signed in to change notification settings - Fork 217
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
ValueError: operands could not be broadcast together with remapped shapes #539
Comments
Thanks for the question! This is a general NumPy issue, about which I am hoping to write up some documentation on within the next month or two. We can look at the error using simple NumPy addition and leaving Skyfield out:
The result:
Because NumPy addition wants natively to do pairwise addition (and the same is true with multiplication and division and everything else), it runs into a problem when one array is a different length than the other. The solution is to move the two lengths (here, 4 and 10) on to two different dimensions. NumPy is always willing to broadcast an operation when either of the lengths is 1. So here’s the solution:
By keeping the 4 in the first axis and moving the 10 to the second axis, there's no conflict, and we get out a grid of 40×10 results:
My advice would be to try the same trick with the arrays you are passing in for the time and the longitude. Fingers crossed, there's a chance that Skyfield — which is careful pretty much to only pay attention to the first axis of an array, and ignore its deeper structure — will go ahead and compute n×m positions for you. But maybe it won't and improvements will have to be made; try out the idea and see what happens! My guess is that keeping time as the first dimension and pushing longitude to the second dimension will work best, but please try both ways and let us know what happens. Thanks! |
Thank you very much brandon-rhodes for your comment. Your trick really make NumPy broadcasts and does what we want. However, when applied to Skyfield, it seems that the broadcasting problem is still there. Here are what I tried:
And I got this error:
If I do
I get this error:
I haven't looked at the issue #526 that you mentioned yet. |
Thanks for those specific exceptions! I will plan to jump in soon and figure out what Skyfield is doing in each case — hopefully I will comment here again with further information within a few days, as soon as I'm able to schedule some work on the topic. It's a direction it would be fun to see Skyfield and its documentation expand in! |
It would be a nice feature to have in Skyfield I believe. Thanks for your helping responses. |
(Whoops, that commit was by accident; it named the wrong issue.) |
@brandon-rhodes, just wondering if you have you any update on this issue? |
No; my recent efforts have been spent on Skyfield's estimates of where the Earth is pointing over the next few years, because its primitive ∆T curve was getting steeper and steeper every year as the Earth's rotation failed to match the rate of estimates from a decade or two ago. But that's now fixed so I should have time within the next couple of months to return to the |
I am new to Skyfield and have the following question.
I got the following error:
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (3,3,10)->(3,10,3) (3,4)->(4,3).
It is OK if do
g = sites.at(time[0])
. Does it mean that I cannot propagate "sites" over a time interval? And is there a way to solve my challenge without looping?The text was updated successfully, but these errors were encountered: