Allow hyperbolic orbits to stay within the bounds of a plot #111
Comments
I'm postponing this for the next release too. |
Asking the algorithm to |
Blocked on #218. |
This is no longer blocked. |
When plotting certain hyperbolic paths, the position plots of the objects appear incorrect. PlutoM = Orbit.from_vectors(Sun, [1.197648971483503E+09, -4.443903841678363E+09, -1.747653049536265E+09] * u.km , [5.382941983259522E+00, 8.185732351064959E-01, -1.389415786284875E+00] * u.km/u.s, Time('2015-07-14 07:59',scale='tdb') ) New Horizons is nearly on top of Pluto at that point, however the plot places New Horizons much earlier on its path: And a notebook exhibiting this behavior: |
I confirm I can reproduce this using both 0.8.0 and latest master version. Working on it |
Forget about the old behavior, it's gone anyway. Doing some quick experiments, it seems that the "first" point in the sampling is used as the "dot" where the spacecraft is. Specifically, these lines: poliastro/src/poliastro/plotting.py Lines 158 to 159 in 44dbc6e
Clearly, for hyperbolic orbits the assumption "the first point is the original |
The reason why is that sampling values for the elliptic case start at zero: poliastro/src/poliastro/twobody/orbit.py Lines 294 to 295 in 44dbc6e
whereas for hyperbolas, start at the limit value: poliastro/src/poliastro/twobody/orbit.py Lines 296 to 300 in 44dbc6e
The fix |
I created a new issue #295 |
Is this problem still there? |
Probably, because we did not change anything related to that :) But as usual I failed to provide code to reproduce the issue. Would you like to try? This plot comes from this notebook, which unfortunately is in Spanish: |
Yeah Surely, I would try. I will just copy the code cells. And use google for Spanish! |
And by the way, this is the changes I had to made back in the day to properly plot this: diff --git a/src/poliastro/plotting.py b/src/poliastro/plotting.py
index c30f610..937801b 100644
--- a/src/poliastro/plotting.py
+++ b/src/poliastro/plotting.py
@@ -156,8 +156,8 @@ def _generate_vals(self, state):
if state.ecc >= 1:
# Select a sensible limiting value for non-closed orbits
- # This corresponds to r = 3p
- nu_limit = Angle(np.arccos(-(1 - 1 / 3.) / state.ecc))
+ # This corresponds to r = infinity
+ nu_limit = Angle(np.arccos(-1 / state.ecc))
nu_invalid = ((nu_vals > nu_limit) &
(nu_vals < (-nu_limit).wrap_at('360d')))
nu_vals[nu_invalid] = np.nan |
I'm blocking this issue until we have #274 working. That one is easier and will give us hints on how to fix this. |
This is not blocked anymore. |
What exactly is the problem ? Is it like the hyperbolic plot goes till the edge of the plot or something else? |
the problem is that if you plot a "small" hyperbolic orbit and a big elliptic orbit, the hyperbolic one won't be shown, and if you plot a "big" hyperbolic orbit, it will push the boundaries of the plot and you won't be able to see anything. Not sure if this is an easily solvable problem, since in general plotting closed (elliptical) orbits of very different sizes will always showcase this problem as well. The current behavior treats hyperbolic orbits as closed orbits, and I wonder if we can do better. |
It's not actually clear what to do with this, and also the thread is confusing because we mixed the original problem with other bugs. For the moment, I'm removing the milestone. |
What has to be done for this?
This requires some extra efforts in plotting module! I think we restrict our plotting module to plot very few things. Do you think so? |
Perhaps it's not really something we can solve. Our current APIs allow you to clip the axis and change its limits, so perhaps that's enough. I'm closing this. |
After #19 was fixed plotting only one hyperbolic orbit looks okay, but there can be cases when one wants it to do something like this:
This plot needed a patch in
_generate_vals
(hence tagging it as a bug), but it only works for cases where there's a previous closed orbit plotted. The logic to handle both cases has to be more complex.The text was updated successfully, but these errors were encountered: