Mean anomaly as a function of the true anomaly elliptical orbits

Click For Summary

Homework Help Overview

The discussion revolves around the calculation of mean anomaly as a function of true anomaly in elliptical orbits, specifically addressing issues related to discontinuities in the output of the function as described in the book "Orbital Mechanics" by Curtis.

Discussion Character

  • Exploratory, Mathematical reasoning, Assumption checking

Approaches and Questions Raised

  • The original poster attempts to understand the discontinuity in their graph of mean anomaly, questioning the behavior of the function at specific values of true anomaly. Some participants suggest that the issue may stem from the properties of the arctan function and propose using arctan2 as a potential solution.

Discussion Status

Participants have explored the problem and suggested a modification to the original approach, which has been successfully implemented by the original poster. The discussion reflects a productive exchange of ideas without a definitive consensus on the initial problem's setup.

Contextual Notes

The original poster's implementation is constrained by their understanding of Python and the specific mathematical functions involved, leading to a reliance on external resources for clarification.

Dustinsfl
Messages
2,217
Reaction score
5
The book Orbital mechanics by Curtis says that the function (I labeled M2evals) is monotonically increasing. However, at pi, I have a discontinuity and the graph jumps below the negative axis when it should continue on; that is, the e = 0 should be the line y = x.

Code:
import pylab
import numpy as np

e = np.arange(0.0, 1.0, 0.15).reshape(-1, 1)
nu = np.linspace(0, 2 * np.pi, 50000)
M2evals = (2 * np.arctan(((1 - e) / (1 + e)) ** 0.5 * np.tan(nu / 2)) -
           e * (1 - e ** 2) ** 0.5 * np.sin(nu) / (1 + e * np.cos(nu)))

fig2 = pylab.figure()
ax2 = fig2.add_subplot(111)

for Me2, _e in zip(M2evals, e.ravel()):
    ax2.plot(nu.ravel(), Me2, label = str(_e))

pylab.legend()
pylab.xlim((0.0, 7.75))
pylab.ylim((-np.pi, np.pi))
pylab.savefig('eccentrueanomfunc.eps', format = 'eps', dpi = 1000)
pylab.show()

Here is the plot:
where the plot jumps down it is supposed to be shifted up to meet the first half.
What is wrong?
http://img96.imageshack.us/img96/5397/pfquestion.png
 

Attachments

  • pfquestion.png
    pfquestion.png
    27.3 KB · Views: 806
Last edited by a moderator:
Physics news on Phys.org
The problem may lie in the arctan function which gives "principle values" as output.

Thus, arctan(tan(x)) does not yield x if x is an angle in the second or third quadrant. If you plot arctan(tan(x)) from x = 0 to x = Pi, you will find that it has a discontinuous jump at x = Pi/2.

I think you can correct for this by using the function arctan2(x1, x2). See http://docs.scipy.org/doc/numpy/reference/generated/numpy.arctan2.html

For your case, instead of writing arctan(arg), I believe you would write arctan2(1, 1/arg) where arg is the argument of your arctan function. That way, when arg becomes negative, arctan2 will yield an angle in the second quadrant rather than the fourth.

I'm not familiar with python, but it appears arctan2 is similar to a function in Mathematica which I have used in similar circumstances.

At least it would be easy to give it a try.
 
Last edited:
  • Like
Likes   Reactions: 1 person
With some help of stackoverflow, I was able to implement your suggestion of arctan2 and it works as intended now.
 
Good.
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
3K