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

走远了吗. 提交于 2019-12-14 04:27:26

问题


UPDATE: Skyfield has just had a significant revision, including expanded documentation and a method for angular separation - see the accepted answer.

I'm calculating the apparent angular separation between two objects using Skyfield. I didn't find a method within the package, so I've "invented" a way by calculating the dot product between the two apparent position vectors.

Is this the best way to do it currently? Is it essentially correct, within Skyfield's scope?

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"

回答1:


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

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



来源:https://stackoverflow.com/questions/36111098/better-way-to-calculate-apparent-angular-separation-of-two-objects-in-skyfield

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!