-
-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support SPICE ephemeris with multi-segments #975
base: master
Are you sure you want to change the base?
Conversation
SPK files for celestial small bodies tend to be multi-segmented. But ... they probably consist of type 21 segments which aren't supported in Skyfield (yet). |
Test multi-segmented DE441
from skyfield.api import load
from skyfield.jpl_multikernel import MultiKernel
ts = load.timescale()
kernel = MultiKernel()
# it's possible to create ` MultiSegments` in advance
earth = kernel['earth']
mars = kernel['mars'] # thanks to `MultiSegment._fallback_target` this will work
kernel.load_kernel('de441.bsp')
# a time covered by first segment
t = ts.tdb_jd(1440432)
barycentric = earth.at(t)
# a time covered by second segment
t = ts.tdb_jd(3440432)
barycentric = earth.at(t)
## critical tdb: obeserve() requires mars-vectors from both segments
t = ts.tdb_jd(2440432.501)
barycentric = earth.at(t)
astrometric = barycentric.observe(mars) |
The fact that E.g. when a MultiSegment is involved in a Without major changes to existing code, the only solution I can think of, is:
For example topocentric coordinates: from skyfield.api import load, N, W, wgs84
from skyfield.jpl_multikernel import MultiKernel
ts = load.timescale()
t = ts.now()
eph = MultiKernel()
eph.load_kernel('de441.bsp')
earth = eph['earth']
mars = eph['mars']
# !important: initialize earth's center before adding
earth.at(t)
boston = earth + wgs84.latlon(42.3583 * N, 71.0636 * W)
astrometric = boston.at(t).observe(mars)
alt, az, d = astrometric.apparent().altaz()
print(alt)
print(az) |
@Tontyna — I'm not sure I'll have time this month to respond in detail, but I at least want to say, thanks for your interest in getting Skyfield set up to handle ephemerides that have two or more segments per target; it's definitely a use case I want to see added to Skyfield this year. I'm not sure I'll want to merge a solution that uses a |
Of course, looping over time in a for-loop, isn't great. But what else is there to find the segment suitable for the requested time? Of course, a BTW.: My major intention for this MultiKernel wasn't the two-segmented DE441. My pet project is an astrological application, so I wanted a class that automatically builds the proper heliocentric VectorFunction chains for various asteroids (some of them in multi-planet-multi-segmented SPK files, some of them of Typ 21). Covering a time span as big as possible. |
Anyway, there is no need to merge this single |
resolves #691
MultiKernel
can load multipleSpiceKernels
and combines their segments.When a target's position is queried, the appropriate
SPICESegments
are picked from all segments available in all loaded SPK files.Per definition that includes support of ephemerides that have more than 1 segment per planet.