gisskyfield

Skyfield Moon Coordinate System Conversion


I am working on a project in which I need to calculate the angle of the sun for a position on the moon. I can achieve this with the following code (adapted from Skyfield Docs here):

lunar_latitude = 55.0,
lunar_longitude = 86.4,
lunar_altitude = 2000,
time = "2022,12,20,19,59,12",

input_time = [int(x) for x in time.split(",")]

eph = load('de421.bsp')
sun, moon = eph['sun'], eph['moon']

pc = PlanetaryConstants()
pc.read_text(load('moon_080317.tf'))
pc.read_text(load('pck00008.tpc'))
pc.read_binary(load('moon_pa_de421_1900-2050.bpc'))

frame = pc.build_frame_named('MOON_ME_DE421')
lunar_position = moon + pc.build_latlon_degrees(frame, lunar_latitude, lunar_longitude, elevation_m = lunar_altitude)
ts = load.timescale()
time = ts.utc(*input_time)

apparent = location.at(time).observe(solar_system_body).apparent()
print("apparent", apparent.position)
alt, az, distance = apparent.altaz()
print(alt, 'degrees above the horizon')
print(az, 'degrees around the horizon from north')

The code gives me the sun position relative to the position specified in degrees (55.0, 86.4). However, I have a gis file from which I can extract lunar elevation which is in moon2000_npole format. I want to be able to convert and match locations between the two components of this script, and so I need to be able to convert to and from the skyfield coordinate reference system, however it is not clear to me from the documentation what this format would be?

I'd appreciate any help from those more knowledgeable on the intricacies of skyfield as to whether there is an assumed CRS in the code that I am using here, or whether there is some way to determine what the CRS is.

I have searched for the CRS (or assumed CRS) in the Skyfield Docs (linked above) but can't find any particular references beyond WGS84 being used in the code for Earth positions.


Solution

  • Skyfield does not have any built-in ideas about planetary reference systems. It simply loads the data from .tf files and applies the transforms those files describe. So to learn more about the frame of reference you have loaded, open the moon_080317.tf text file and look for the section entitled Frames Specified by this Kernel.

    You should find there a detailed description of the lunar-surface reference frames defined by the kernel, along with a comparison between them.