Geocentric object does not have center set to Earth
See original GitHub issueI am trying to create my own Geocentric
objects directly using the class constructor. I have data containing satellite states in ICRF that I need to convert to ECEF and lat/lon positions. When I try to get the lat/lon position of an object created with Geocentric
, I get an error that that method can only be used if the center is set to Earth:
from skyfield.positionlib import Geocentric
geo = Geocentric([-2.63970280e-04, 9.92180837e-05, 6.71165223e-07],
velocity_au_per_d=[-6.23751840e-07, -1.66333824e-06, -1.16087148e-10])
geo.subpoint()
ValueError Traceback (most recent call last) <ipython-input-186-7e91b47e36cb> in <module> ----> 1 geo.subpoint()
~/.virtualenvs/ml/lib/python3.7/site-packages/skyfield/positionlib.py in subpoint(self) 463 “”" 464 if self.center != 399: # TODO: should an init() check this? –> 465 raise ValueError(“you can only ask for the geographic subpoint” 466 " of a position measured from Earth’s center") 467 t = self.t
ValueError: you can only ask for the geographic subpoint of a position measured from Earth’s center
geo.center # returns nothing
I tried to set the center to Earth manually with:
from skyfield import api
planets = api.load('de421.bsp')
earth = planets['earth']
geo = Geocentric([-2.63970280e-04, 9.92180837e-05, 6.71165223e-07],
velocity_au_per_d=[-6.23751840e-07, -1.66333824e-06, -1.16087148e-10],
center=earth)
geo.subpoint()
which results in the same error, although geo.center
now shows a VectorSum
object from the solar system barycenter to Earth. I also tried just passing a string 'Earth'
and 'earth'
to the constructor, neither of which helped. It seems to me like a geocentric object should automatically be centered at the Earth. Is this a bug or is there an intended way to initialize these for this use case that you can point me toward?
Thank you.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
I agree that it should default to Earth! I actually had a branch with that modification already on my computer, but hadn’t yet found time to figure out why one test was failing; I’ve now worked out the problem.
Just as a reference, these “399” numbers are called NAIF ids: https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/req/naif_ids.html#Planets and Satellites (I linked to one section, but the whole document is interesting).
The NAIF ids are commonly used in CSPICE, for example