# How to calculate planet position in ecliptic frame latitude and longitde

**URL:** <https://community.openastronomy.org/t/how-to-calculate-planet-position-in-ecliptic-frame-latitude-and-longitde/228>\
**Category:** Astropy\
**Tags:** astropy, question\
**Created:** [December 4, 2021, 4:27pm UTC](https://community.openastronomy.org/t/how-to-calculate-planet-position-in-ecliptic-frame-latitude-and-longitde/228 "2021-12-04T16:27:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ram3k333](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@ram3k333](https://community.openastronomy.org/u/ram3k333)\
**Post date:** [December 4, 2021, 4:27pm UTC](https://community.openastronomy.org/t/how-to-calculate-planet-position-in-ecliptic-frame-latitude-and-longitde/228/1 "2021-12-04T16:27:37Z")

</div>

Hello everyone I don’t know how to calculate planet position in an ecliptic frame using astropy here’s my code please help me I am new to astropy…

```auto
from astropy.time import Time
from astropy.coordinates import solar_system_ephemeris, EarthLocation
from astropy.coordinates import get_body_barycentric, get_body, get_moon
from astropy import units as u
from astropy.coordinates import SkyCoord, builtin_frames

t = Time("2014-09-22 23:22")
loc = EarthLocation.of_site('greenwich')

x = solar_system_ephemeris.set('de440s')
y = get_body('jupiter',t,loc)
print(builtin_frames.GeocentricTrueEcliptic(y))

```

---

<div class="post-metadata">

**Author:** ![ayshih](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/ayshih/32/84_2.png) [@ayshih](https://community.openastronomy.org/u/ayshih)\
**Post date:** [December 6, 2021, 5:09am UTC](https://community.openastronomy.org/t/how-to-calculate-planet-position-in-ecliptic-frame-latitude-and-longitde/228/2 "2021-12-06T05:09:41Z")

</div>

You’re almost there! Your `y` is a `SkyCoord` instance in the `GCRS` coordinate frame, so a corrected form of your last line is:

```python
print(y.transform_to(builtin_frames.GeocentricTrueEcliptic))

```

The target can be the string `'geocentrictrueecliptic'` instead of the frame class, or it can be a frame instance if you need to transform to a frame with non-default frame attributes (e.g., `equinox` other than J2000.0).
