<p>The &quot;mean anomaly&quot; is actually a measure of <em>time</em> expressed in terms of an angle.  It is just <span class="math-container">$360^\circ\times(t-t_{\text{periapse}})/(\text{orbital period})$</span>. (If you are working in degrees, you may find it convenient to work in radians.)</p>
<p>To find the mean anomaly, you need to know the time of periapsis   This seems to be <code>tp_tbd</code> in your data. Also you need the orbital period.  That is <code>p_yr*365.25</code> (the factor of 365.25 is to convert the period to days, as the time is given as a Julian day number).   And finally you need to know the time at which you want to calculate the position of the comet, again this should be as a Julian day number, your software will probably have a routine for converting a date-time to JD.</p>

CC BY-SA 4.0
2023-04-22T18:01:10.290Z
Note that tp_tdb strongly implies the time is in Barycentric Dynamic Time (TDB; the acronym is TDB regardless of language). TDB differs slightly from Terrestrial Time (TT), plus or minus at most a couple of milliseconds, which in turn differs from International Atomic Time (TAI) by about 16.184 seconds. Finally, TAI differs from UTC by an integer number of seconds; these are the much hated leap seconds. Those differences might or might not be important.
David Hammen
CC BY-SA 4.0
2023-04-23T13:50:42.843Z
Thank you I calculated the mean anomaly as you mentioned (but in radians). My current problem is, when for some of the time that is greater than tp_tbd + P or less than tp_tbd, the comet teleports to a location along the orbit instead of following it. For example: When time is equal to tp_tbd + P + 5, the comet teleports to somewhere very near perihelion (backwards) instead of following its course. Why is this happening and how can I solve it?
Ege Can
CC BY-SA 4.0
2023-04-23T14:35:33.107Z
You should reduce the value of M to the range 0 to 2pi (by repeatedly subtracting multiples of 2pi) some programming languages call this `fmod`.
James K
CC BY-SA 4.0
2023-04-23T22:57:08.237Z
@JamesK This is it! Thank you so much!
Ege Can
CC BY-SA 4.0
2023-04-22T11:59:18.577Z
2023-04-22T13:20:21.530Z
2023-04-22T13:20:21.530Z
James K
<p>I have some orbital elements for comet P/2004 R1 (McNaught) from <a href="https://data.nasa.gov/Space-Science/Near-Earth-Comets-Orbital-Elements/b67r-rgxc" rel="nofollow noreferrer">this dataset</a> and I would like to calculate its position around the sun (x, y, z coordinates where the sun is at the origin) at a specific Julian date. Here is the data I have:</p>
<ul>
<li><p>object: P/2004 R1 (McNaught)</p>
<p>epoch_tdb: 54629</p>
<p>tp_tdb: 2455248.548</p>
<p>e: 0.682526943</p>
<p>i_deg: 4.894555854</p>
<p>w_deg: 0.626837835</p>
<p>node_deg: 295.9854497</p>
<p>q_au_1: 0.986192006</p>
<p>q_au_2: 5.23</p>
<p>p_yr: 5.48</p>
<p>moid_au: 0.027011</p>
<p>a1_au_d_2: NA</p>
<p>a2_au_d_2: NA</p>
<p>a3_au_d_2: NA</p>
<p>dt_d: NA</p>
<p>ref: 20</p>
<p>object_name: P/2004 R1 (McNaught)</p>
</li>
</ul>
<p>I already know how to calculate eccentric anomaly from kepler's equation. However I am struggling on calculating the mean anomaly.</p>
<p>Can you give me a step by step guide on the subject?</p>

CC BY-SA 4.0
2023-04-22T11:03:43.050Z
These elements are a few years newer. https://ssd.jpl.nasa.gov/tools/sbdb_lookup.html#/?sstr=P%2F2004%20R1 I *assume* the epoch in your data is a Modified Julian Date (in JPL's Barycentric Dynamical Time).
PM 2Ring
CC BY-SA 4.0
2023-04-22T11:09:52.920Z
I'm not quite sure what you're having difficulty with. All 3 of mean, eccentric, and true anomalies are 0° at the instant of perihelion passage.
PM 2Ring
<orbit><comets><kepler>
Calculating Comet Position at a Given Julian Date with Available Orbital Elements
Ege Can
# Calculating Comet Position at a Given Julian Date with Available Orbital Elements

(Asked by: username_0 on 2023-04-22)

I have some orbital elements for comet P/2004 R1 (McNaught) from [this dataset](https://data.nasa.gov/Space-Science/Near-Earth-Comets-Orbital-Elements/b67r-rgxc) and I would like to calculate its position around the sun (x, y, z coordinates where the sun is at the origin) at a specific Julian date. Here is the data I have:

* object: P/2004 R1 (McNaught)

  epoch\_tdb: 54629

  tp\_tdb: 2455248.548

  e: 0.682526943

  i\_deg: 4.894555854

  w\_deg: 0.626837835

  node\_deg: 295.9854497

  q\_au\_1: 0.986192006

  q\_au\_2: 5.23

  p\_yr: 5.48

  moid\_au: 0.027011

  a1\_au\_d\_2: NA

  a2\_au\_d\_2: NA

  a3\_au\_d\_2: NA

  dt\_d: NA

  ref: 20

  object\_name: P/2004 R1 (McNaught)

I already know how to calculate eccentric anomaly from kepler's equation. However I am struggling on calculating the mean anomaly.

Can you give me a step by step guide on the subject?

**Tags:** orbit, comets, kepler

> **Comments:**
> **username_1**: These elements are a few years newer. https://ssd.jpl.nasa.gov/tools/sbdb_lookup.html#/?sstr=P%2F2004%20R1 I *assume* the epoch in your data is a Modified Julian Date (in JPL's Barycentric Dynamical Time).  
> **username_1**: I'm not quite sure what you're having difficulty with. All 3 of mean, eccentric, and true anomalies are 0° at the instant of perihelion passage.  

---

## 1 answers

### Answer by username_2 on 2023-04-22. Score: 1 | Accepted answer

The "mean anomaly" is actually a measure of *time* expressed in terms of an angle. It is just $360^\circ\times(t-t\_{\text{periapse}})/(\text{orbital period})$. (If you are working in degrees, you may find it convenient to work in radians.)

To find the mean anomaly, you need to know the time of periapsis This seems to be `tp_tbd` in your data. Also you need the orbital period. That is `p_yr*365.25` (the factor of 365.25 is to convert the period to days, as the time is given as a Julian day number). And finally you need to know the time at which you want to calculate the position of the comet, again this should be as a Julian day number, your software will probably have a routine for converting a date-time to JD.

> **Comments:**
> **username_3**: Note that tp_tdb strongly implies the time is in Barycentric Dynamic Time (TDB; the acronym is TDB regardless of language). TDB differs slightly from Terrestrial Time (TT), plus or minus at most a couple of milliseconds, which in turn differs from International Atomic Time (TAI) by about 16.184 seconds. Finally, TAI differs from UTC by an integer number of seconds; these are the much hated leap seconds. Those differences might or might not be important.  
> **username_0**: Thank you I calculated the mean anomaly as you mentioned (but in radians). My current problem is, when for some of the time that is greater than tp_tbd + P or less than tp_tbd, the comet teleports to a location along the orbit instead of following it. For example: When time is equal to tp_tbd + P + 5, the comet teleports to somewhere very near perihelion (backwards) instead of following its course. Why is this happening and how can I solve it?  
> **username_2**: You should reduce the value of M to the range 0 to 2pi (by repeatedly subtracting multiples of 2pi) some programming languages call this `fmod`.  
> **username_0**: @JamesK This is it! Thank you so much!  

---

