Closed Captjackz closed 2 years ago
Still learning this system.
(I've edited your question to add triple-backticks to format your Python as code, but otherwise I think I left your question unaltered.)
The x,y,z coordinates of a Skyfield position are J2000 = ICRS coordinates, as explained at:
https://rhodesmill.org/skyfield/positions.html#the-icrs-reference-system-and-j2000
If you want x,y,z coordinates in another reference frame, you have to do a conversion. Here's code I just tested that I think does what you want:
from skyfield.api import load
from skyfield.framelib import ecliptic_frame
import math
planets = load('de421.bsp')
sun, earth, EMB = (
planets['sun'],
planets['earth'],
planets['earth barycenter'],
)
ts = load.timescale()
t = ts.utc(2021, 6, 30, 15, 19)
t = ts.now()
astrometric = sun.at(t).observe(EMB)
r, v = astrometric.frame_xyz_and_velocity(ecliptic_frame)
earthvx, earthvy, earthvz = v.m_per_s
earth.vel = math.sqrt(earthvx**2 + earthvy**2 + earthvz**2)
print('Earth Vel %16.1f %16.1f %16.1f %8.2f' % (
earthvx, earthvy, earthvz, earth.vel
))
The z-axis velocity should print as zero.
How could the documentation be clearer to help future users understand how to produce ecliptic x,y,z coordinates? Could you point to where you looked in the documentation so that I can add it there? Thanks!
I'm going to close this in the optimistic hope that my answer solved your problem, but feel free to comment further if you have a follow-up question or want to report that the answer worked for you.
To Whom, I have written a python simulation of Starlink launch, insertion, final orbit adjust Crew_Dragon launch and ISS rendezvous Artemis launch-moon orbit Perseverance Earth-Mars launch and mars rendezvous THIS FAILS
In perfecting the Earth-Mars system I needed a needed a precise location of Sun-Earth-Mars on the Perseverance launch date and other dates. I turned to SKYFIELD.
COORDINATE SYSTEM: Sun Centered - Earth Ecliptic plane. In this plane, the earth should be rotating with an sinusoidal X-Y position and velocity. There should be no or little Z-value. I get huge z values for earth, mars, venus and mercury. So I wrote a small test program. (below) That shows a particular bad value for Vz of 11581.3, to point you to the problem. Switching from EMB to earth does not change the result. In my simplified model (for this request), the earth should have NO (little) Z displacement or velocity. I have tried dozens of options and tried to buy numerous books understand my coordinate system problem. If I set the Z values for mercury, Venus, earth, mars to zero my simulation comes close, but now a viable solution. Can you please HELP. If you could recommend a text to clarify my confusion of the reference frame I would appreciate it.
Jack Finley
RESULT: