mexpvat_demo.print_position
ΒΆ
An example to print out the position of MEX.
Command line tool - irfpy-mexpvat-print will also help.
""" An example to print out the position of MEX.
Command line tool
- irfpy-mexpvat-print
will also help.
"""
if __name__ == "__main__":
### Spice binding (SpiceyPy) is used. Installation of SpiceyPy is needed.
### If the following ``import`` fails, the installation of SpiceyPy has not done.
### See https://irfpy.irf.se/projects/aspera/quickinstall.html
import spiceypy as spice
### MEX Spice related functionalites.
### See https://irfpy.irf.se/projects/aspera/api/api_irfpy.mexpvat.mexspice.html
### for the setup of MEX spice setting.
from irfpy.mexpvat import mexspice
mexspice.init() # Initialize the spice.
### Use get_position function to get the position at the given time.
import datetime
t = datetime.datetime(2008, 6, 27, 0, 0, 0) # 2008-06-27T00:00:00
pos = mexspice.get_position(t, target='MEX', origin='MARS', frame='MSO')
print(t, pos) # Position (x, y, z) in the MSO frame. Unit is km.
# -> 2008-06-27 00:00:00 [ 4444.25255226 -3517.22617822 -10726.45069066]