Closed acmpo6ou closed 1 year ago
Because planets are never exactly on the ecliptic, but always at least a few fractions of a degree above or below it, their separation never reaches 180°. You probably want a different value—try computing each planet's ecliptic longitude, and then subtract them, mapping the resulting angular difference into the range 0–360° or -180–+180° as best fits your needs.
I should add this to the Examples page in the docs, since it's not the first time it's been asked. Let's keep this issue open until I have something written up.
Big thanks for your quick reply! I'll try to figure out how to compute each planet's ecliptic longitude, etc... And otherwise I'll wait for you to update the tutorial.
Thank you for your amazing work :)
@acmpo6ou — I think you'll want something similar to this code from the almanac module:
https://github.com/skyfielders/python-skyfield/blob/master/skyfield/almanac.py#L168
Thank you Brandon, you're a legend! 🥰 Let the stars and planets always shine your way!
I tried this:
e = planets['earth'].at(t)
_, slon1, _ = e.observe(mars).apparent().ecliptic_latlon()
_, slon2, _ = e.observe(moon).apparent().ecliptic_latlon()
arr = np.abs(slon1.degrees - slon2.degrees)
arr[arr > 180] = 360 - arr[arr > 180]
print(arr)
The result is very good :) But a bit imprecise, is there a way to take latitude into account too?
If you take latitude into account, then you will get exactly the angles shown in the list you started your question with—because if you take latitude into account, then the separation is never quite 180°.
That's exactly what I was thinking could happen. Thank you again Brandon :)
Also you're replying insanely quickly, what's the secret? Are you working full time on skyfield?
I use a browser plugin that lights up with a notification count whenever I have unread notifications on GitHub:
https://github.com/sindresorhus/notifier-for-github
That way, if I happen to have my laptop open, I can respond quickly—which can save time: a quick response means that someone might still have the error message sitting in front of them, and can answer questions immediately instead of a few days later when they get back to it!
True, that's very nice!
There! In 67e23e6424bc45af0ff7030e531adae1afcccb53 I have added a discussion of this topic to the documentation, on the Examples page. It will be published online the next time Skyfield is released. Hopefully it explains things well enough that users can figure out what's going on.
Perfect! Amazing work Brandon! I could understand everything :heart:
Hello!
I'm using
separation_from
to calculate the separation between 2 planets. Here's an example code:Output:
You can see that as the separation between Mars and Moon is approaching 180°, it goes 177.3, 177.7, 178.0, 178.2, 178.3, 178.0, 177.79, ... So it skips 179 and 180.
Same problem happens with 0°: 2.7, 2.49, 2.3, 2.28, 2.3, 2.47, 2.69, 2.97. It skips 2.0, 1.0, 0.0.
Is there a way to calculate separation without skipping degrees on the edges? Thank you.