<p>I cant help you with skyfield, but I usually use JPL Horizons Web interface. No installation required, you can also print it in a text file if you want:</p>
<p><a href="https://ssd.jpl.nasa.gov/horizons.cgi" rel="nofollow noreferrer">https://ssd.jpl.nasa.gov/horizons.cgi</a></p>
<p>Otherwise I found the documentation for skyfield:
<a href="https://rhodesmill.org/skyfield/toc.html" rel="nofollow noreferrer">https://rhodesmill.org/skyfield/toc.html</a></p>
<p>And if nothing of that works, I made a little astropy script for you</p>
<pre><code>from astropy import units as u
from astropy.coordinates import SkyCoord, EarthLocation, AltAz, get_body
from astropy.time import Time
import numpy as np

# Create 1000 Timepoints between Time 1 and Time 2 (one year later)
t = np.linspace(2451545, 2451545+365, 1000)


pointlist = []

#Loop through this times
for tn in t:
    # For every timepoint, create an astropy_time object
    astropy_time = Time(tn, format=&quot;jd&quot;)
    # Get Planet (as string, &quot;earth&quot;, &quot;moon&quot;, &quot;mercury&quot; etc. in aequatorial coordinates
    planet_aequatorial = get_body(&quot;moon&quot;, time = astropy_time)
    #Transform to Barycentric True Ecliptic (relative to the center of mass of the solar system).
    planet_ecliptic =  planet_aequatorial.transform_to(&quot;barycentrictrueecliptic&quot;)

    # Add a point to the orbit. Every point is described as (longitude [deg], latitude (ecliptic coords), distance (km))
    pointlist.append([planet_ecliptic.lon.deg, planet_ecliptic.lat.deg, planet_ecliptic.distance.km])
    print(planet_ecliptic.distance.km)
    # So pointslist is a 2D array. The rows are all the 1000 points of the orbit

# In every point there is 3 columns for [Long, Lat, Distance]
print(pointlist)


# You can also save the result with
pointlist = np.array(pointlist)
</code></pre>
<p>np.save(&quot;results.npy&quot;, pointlist)</p>

CC BY-SA 4.0
2019-11-29T17:44:34.717Z
thanks or the reply, it gives me a single point, however i want complete orbit, is that possible, my question may look silly, apologise
Rasika
CC BY-SA 4.0
2019-12-09T22:47:56.070Z
create a list of times (in julian days) with 
>import numpy as np
>t = np.linspace(2451545, 2451545+365, 2000)
then loop over the above code but create Time object with
>t = Time(t1, format="jd")
instead
Andres Huster
CC BY-SA 4.0
2020-01-18T19:01:30.580Z
yes, please. that will be really helpful
Rasika
CC BY-SA 4.0
2020-01-23T11:11:04.770Z
can you give me your e-mail or something? i cant post all the code here i think...
Andres Huster
CC BY-SA 4.0
2020-01-23T18:25:32.560Z
I edited the first answer up here
Andres Huster
CC BY-SA 4.0
2020-03-22T12:16:14.617Z
Sorry for the late reply, i used it, but the output latitude does not go beyond 2 degree
Rasika
CC BY-SA 4.0
2020-01-03T13:01:25.913Z
did that help or should i do it for you?
Andres Huster
CC BY-SA 4.0
2019-11-29T17:32:32.457Z
2022-11-25T10:21:26.623Z
2022-11-25T10:21:26.623Z
Andres Huster
<p>I am new to using <code>skyfield</code>, is there any doc or help file that can show me on how to get the orbit of Sun and moon in ecliptic coordinate for a particular date and time. This is a follow up question of this <a href="https://astronomy.stackexchange.com/questions/34084/orbits-of-planets-in-ecliptic-coordinates">question</a></p>

CC BY-SA 4.0
2019-11-28T10:21:25.543Z
I don't really see how this question is different from the one you link to.
usernumber
CC BY-SA 4.0
2019-11-28T10:26:52.090Z
@usernumber that was how can be done, this is for how can be done using `skyfield`
Rasika
<the-sun><orbit><the-moon><ecliptic>
Sun and moon's orbit in ecliptic coordinates using skyfield
Rasika
# Sun and moon's orbit in ecliptic coordinates using skyfield

(Asked by: username_0 on 2019-11-28)

I am new to using `skyfield`, is there any doc or help file that can show me on how to get the orbit of Sun and moon in ecliptic coordinate for a particular date and time. This is a follow up question of this [question](https://astronomy.stackexchange.com/questions/34084/orbits-of-planets-in-ecliptic-coordinates)

**Tags:** the-sun, orbit, the-moon, ecliptic
> **Comments:**
> **username_1**: I don't really see how this question is different from the one you link to.  
> **username_0**: @usernumber that was how can be done, this is for how can be done using `skyfield`  

---

## 1 answers

### Answer by username_2 on 2019-11-29. Score: 3 | Accepted answer

I cant help you with skyfield, but I usually use JPL Horizons Web interface. No installation required, you can also print it in a text file if you want:
https://ssd.jpl.nasa.gov/horizons.cgi
Otherwise I found the documentation for skyfield:
https://rhodesmill.org/skyfield/toc.html
And if nothing of that works, I made a little astropy script for you
from astropy import units as u
from astropy.coordinates import SkyCoord, EarthLocation, AltAz, get_body
from astropy.time import Time
import numpy as np

# Create 1000 Timepoints between Time 1 and Time 2 (one year later)
t = np.linspace(2451545, 2451545+365, 1000)


pointlist = []

#Loop through this times
for tn in t:
    # For every timepoint, create an astropy_time object
    astropy_time = Time(tn, format="jd")
    # Get Planet (as string, "earth", "moon", "mercury" etc. in aequatorial coordinates
    planet_aequatorial = get_body("moon", time = astropy_time)
    #Transform to Barycentric True Ecliptic (relative to the center of mass of the solar system).
    planet_ecliptic =  planet_aequatorial.transform_to("barycentrictrueecliptic")

    # Add a point to the orbit. Every point is described as (longitude [deg], latitude (ecliptic coords), distance (km))
    pointlist.append([planet_ecliptic.lon.deg, planet_ecliptic.lat.deg, planet_ecliptic.distance.km])
    print(planet_ecliptic.distance.km)
    # So pointslist is a 2D array. The rows are all the 1000 points of the orbit

# In every point there is 3 columns for [Long, Lat, Distance]
print(pointlist)


# You can also save the result with
pointlist = np.array(pointlist)

np.save("results.npy", pointlist)

> **Comments:**
> **username_0**: thanks or the reply, it gives me a single point, however i want complete orbit, is that possible, my question may look silly, apologise  
> **username_2**: create a list of times (in julian days) with  >import numpy as np >t = np.linspace(2451545, 2451545+365, 2000) then loop over the above code but create Time object with >t = Time(t1, format="jd") instead  
> **username_2**: did that help or should i do it for you?  
> **username_0**: yes, please. that will be really helpful  
> **username_2**: can you give me your e-mail or something? i cant post all the code here i think...  
> **username_2**: I edited the first answer up here  
> **username_0**: Sorry for the late reply, i used it, but the output latitude does not go beyond 2 degree  

---

