Best way to calculate the apparent angular separation of two objects in Skyfield?

UPDATE: Skyfield has just had a significant revision, including extended documentation and angular split method - see accepted answer.

I compute the apparent separation of angular between two objects using Skyfield . I did not find the method inside the package, so I “invented” the method by computing a point product between two visible positional vectors.

Is this the best way to do it now? Is this essentially correct within Skyfield?

def separation(seconds, lat, lon):

    lat, lon, seconds = float(lat), float(lon), float(seconds) # necessary it seems

    place = earth.topos(lat, lon)

    jd = JulianDate(utc=(2016, 3, 9, 0, 0, seconds))

    mpos = place.at(jd).observe(moon).apparent().position.km
    spos = place.at(jd).observe(sun).apparent().position.km

    mlen = np.sqrt((mpos**2).sum())
    slen = np.sqrt((spos**2).sum())

    sepa = ((3600.*180./np.pi) *
            np.arccos(np.dot(mpos, spos)/(mlen*slen)))

    return sepa


from skyfield.api import load, now, JulianDate
import numpy as np
from scipy.optimize import minimize

data = load('de421.bsp')

sun   = data['sun']
earth = data['earth']
moon  = data['moon']

sep = separation(12000, 32.5, 215.1)

print "sun-moon aparent separation: ", sep, " arcsec"
+4
source share
1 answer

Skyfield now supports a method that returns the angular split between two positions:

http://rhodesmill.org/skyfield/api-position.html#skyfield.positionlib.ICRF.separation_from

+2

All Articles