NASA spice tipbod spiceypy

NASA spice tipbod spiceypy

正在尝试使用 NASA 示例获取行星、RA、DEC、PM 的固定条件。 ftp://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/tipbod.html

TIPBOD 用于将J2000 惯性坐标中的位置转换为固定坐标系中的状态。 TIPM = TIPBOD ('J2000', BODY, ET)

然后将STATE的前三个元素position转换为bodyfixed坐标。什么是状态? BDPOS = MXVG(TIPM, POSTN)

我的代码:

Targ = 399 (Earth)
et = spice.str2et(indate)
TIPM = spice.tipbod( "J2000", Targ, et )  
BDPOS = spice.mxvg(TIPM, POSTN, BDPOS )

但是什么是 POSTN 什么是 BDPOS?

您可以通过搜索相关函数来获得有关 spiceypy 函数输入的更多详细信息 here

在您的特定情况下,TIPM 将是一个 3x3 二维矩阵,它提供惯性框架中的 object 和固定框架中的 body 之间的转换。 mxvg 函数所需的输入已给出 here。在您的情况下,POSTN 应该是一个包含 3 个值的列表(或 numpy 数组),给出您感兴趣的 body 的 x、y 和 z 位置。BODPOS 将是mxvg 的输出,它将是矩阵 TIPM 乘以向量 POSTN,因此将是一个包含三个值的向量:[= 变换后的 x、y 和 z 位置31=].

我不完全确定你需要什么,但一个例子可能是:

from astropy.time import Time
from spiceypy import spiceypy as spice

# create a time
t = Time('2010-03-19 11:09:00', format='iso')

# put in spice format - this may require a leap seconds kernel to be
# downloaded, e.g. download https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/naif0012.tls
# and then load it with spice.furnsh('naif0012.tls')
et = spice.str2et(t.iso)

# get the transformation matrix - this may require a kernel to be
# downloaded, e.g. download https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/pck00010.tpc
# and then load it with spice.furnsh('pck00010.tpc')
target = 399 # Earth
TIPM = spice.tipbod( "J2000", target, et )

# get the position that you want to convert
from astropy.coordinates import Angle, ICRS
ra = Angle('12:32:12.23', unit='hourangle')
dec= Angle('-01:23:52.21', unit='deg')

# make an ICRS object (you can also input a proper motion as a radial velocity or using 'pm_dec' and 'pm_ra_cosdec' keyword arguments)
sc = ICRS(ra=ra, dec=dec)

# get position in xyz
xyz = sc.cartesian.xyz.value

# perform conversion to body centred frame
newpos = spice.mxvg(TIPM, xyz, 3, 3)

# convert to latitude and longitude
scnew = SkyCoord(x=newpos[0], y=newpos[1], z=newpos[2], representation_type='cartesian')

# print out new RA and dec
print(scnew.spherical.lon, scnew.spherical.lat)

可能有一些方法可以完全在 astropy 中完成此操作,使用预定义的框架或根据您自己的定义,并使用 ICRS object. For example, you could convert from ICRS to GCRStransform_to() 方法。

谢谢马特,看起来 tipbod 和 reclat 很有效。告诉我,如果我错了,但数字看起来不错。

#Saturn Tilt Negative rotation
    Targ = 699
    TIPM = spice.tipbod( "J2000", Targ, et )   
    #Rotation
    Radius, Long, lat = spice.reclat(TIPM[0])
    fy = r2d * Long
    if fy < 0.0:
        fy = fy + 360.0 #if degrees/radians are negative, add 360
    #print 'X Longitude  = ' +str(fy)

    #Tilt
    Radius, Long, lat = spice.reclat(TIPM[1])
    fy = r2d * Long
    if fy < 0.0:
        fy = fy + 360.0
    #print 'Y Longitude = ' +str(fy)