# Where is the sun relative to my lunar rover?

I'm a robotics researcher writing orienteering code for a solar-powered lunar rover. I have two similar problems:

1. Given the position of a robot on the moon in lunar latitude/longitude, where is the sun? That is, which direction should I orient my solar panel to maximize incidence?

2. For testing purposes, I need to solve the same problem on Earth. Given Earth lat/lon, where is the sun?

To be honest, I'm not even sure what coordinate system to use to express the answer to these questions. I was considering a coordinate frame centered on the rover with East, North, and Up axes, but I'm open to a better suggestion!

So far, I've found some information about VSOP87 and ELP2000, and I've started reading "Astronomical Algorithms", but I'd appreciate help from the experts.

## Edit

Here's what I've got so far. I can get the coordinates of the Earth-Moon barycenter using VSOP2013. If I can get from the barycenter to the center of the Earth, I can probably use EPS2000/82 to find the position of the Moon in heliocentric coordinates.

Sun->VSOP->Earth-Moon Barycenter->Earth->EPS2000->Moon

At very least, I think this would get me the moon coordinates in the sun frame. I'm hoping it would also give me the orientation of the Moon in the sun frame?

• Part 2 is fairly easy (assuming you don't need high precision). You should take a look at some resources on sundial theory. There are several websites with that material. It's also helpful to have some familiarity with spherical trig, to do the various coordinate transformations that crop up in this sort of work. – PM 2Ring Apr 20 at 16:54
• You're right, reading about sundials is definitely helpful here. – J. Ford Apr 20 at 21:21
• only tangentially related to sundials: How many sundials & Sun compasses are there on solar system bodies? – uhoh Apr 21 at 5:56

If you like Python then see Skyfield; Observing from a Moon location which I believe will do exactly what you need! Also see for example this answer to Ephemeris for lunar body-centered body-fixed coordinates? written by Skyfield's author.

For example, you posted your question at 2020-04-20 15:21:36 UTC. Let's say your rover has just driven up to Surveyor III at 3° 0′ 58.03″ S, 23° 25′ 4.48″ W  (-3.01612°, -23.41791°) (read more about Surveyor III in How did Apollo-12 manage to land next to Surveyor-3? First “Space-Tourists”?)

At that moment the Sun was below the horizon. The output of the script below is

RA:  01h 54m 39.28s
Dec:  +11deg 45' 38.6"
alt:  -38deg 30' 34.6" degrees (below the horizon)
az:  265deg 50' 21.5" degrees around the horizon from north


I can get the coordinates of the Earth-Moon barycenter using VSOP2013

factoids: VSOP is what PyEphem uses under the hood. It is currently in maintenance mode maintained by the same person who wrote Skyfield.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

t = ts.utc(2020, 4, 20, 15, 21, 36)

earth, moon, sun = [eph[thing] for thing in ('earth', 'moon', 'sun')]

pc = PlanetaryConstants()

frame = pc.build_frame_named('MOON_ME_DE421')
Surveyor_III = moon + pc.build_latlon_degrees(frame, latitude_degrees = -3.01612,
longitude_degrees = -23.41791)

apparent = Surveyor_III.at(t).observe(sun).apparent()
print('RA: ', ra)
print('Dec: ', dec)

alt, az, distance = apparent.altaz()
if alt.degrees >= 0:
print('alt: ', alt, 'degrees (above the horizon)')
else:
print('alt: ', alt, 'degrees (below the horizon)')
print('az: ', az, 'degrees around the horizon from north')

• Wow! Awesome! I actually found skyfield and used it to solve this problem on Earth, but for the life of me I couldn't figure out how to do the same on the Moon. Thank you so much! – J. Ford Apr 21 at 13:26
• @J.Ford Skyfield is a really excellent package and under constant development and expansion. I've linked to a 2013 talk by the author in How to pronounce “Ephemerides”? and it seems to have been a real labor of love. It also has a github page and an active discussions in the issues section. – uhoh Apr 21 at 14:07

All you really need to know is that the moon is rotating and one day on the moon is one month long.

The axial tilt of the moon is 1.5 degrees, so there are no significant seasons.

The path of the sun is (close to) a great circle in the sky. And is much like the path of sun on the Equinox on Earth. It rises, takes 7.4 days to reach the Meridian (at which point its altitude is equal to 90-latitude) and then it slowly sets over another 7.4 days. It is then dark until the sun rises again. The whole period takes one month, 29.5 days

If you need greater accuracy (if you want to point a telescope at the sun, not just a solar panel) you would need to account for the axial tilt, which is tricky because the moon's orbit is complex and non-Keplarian.

You don't need to account for the motion of the moon around the Earth. The parallax is not enough to invalidate the calculation of the position, for the sake of pointing a solar panel. So just treat the moon as a slowly spinning body with almost not axial tilt and forget about the Earth.

The prime meridian on the moon is the meridian facing Earth. On the Prime meridian the sun culminates at full moon

If you are 90degrees East then the sun will culminate 1/4 month earlier and 90degrees West, then 1/4 month later.

• Cool! That does make it a lot simpler. Do you know how I could figure out the timing of the day/night cycle given an arbitrary location on the moon? – J. Ford Apr 20 at 21:21
• On the prime meridian sun rise at first quarter, midday on full moon, sun set on third quarter. At other longitudes add 7.4 days for every 90 degrees West. – James K Apr 20 at 21:29