Use NAIF SPICE TOOLKIT with Python

SPICE for Python The SPICE TOOLKIT provided by NAIF is a tool for calculating the geometric information of the spacecraft from the SPICE kernel. So far, it has been developed in FORTRAN and C, but it seems that you can use Liplari to read functions from Python!

NAIF HP http://naif.jpl.nasa.gov/naif/

SpiceyPy installation

The python riplary is below. https://github.com/AndrewAnnex/SpiceyPy

pip install spiceypy

You can install it with. A simple document is here

Test program

import spiceypy as spice
spice.tkvrsn('TOOLKIT')

If you run, you should see the version name. If cspice is (function name) _c, spice. (function name) is basically OK. Input variables etc. are the same as cspice.

Time conversion by SpiceyPy

An example by the Cassini spacecraft.

import numpy as np
import spiceypy as spice

#Kernel loading
spice.furnsh('./spice/sclk/cas00084.tsc')
spice.furnsh('./spice/lsk/naif0009.tls')

utctim='2005-06-20T19:00:00'
#Convert from UTC to ET
et_ex=spice.str2et(utctim)
print 'ET:',et_ex

ti_0='0x58C448C2'#Hexadecimal
ti=int(ti_0,16)
print "TI (Decimal number): ",ti
scid=-90 #Spacecraft ID
#Convert from TI to ET
et= spice.sct2e(scid,ti)
#Convert from ET to UTC
time=spice.et2utc(et,"ISOC",6)
print "UTC: ",time


To get help

help(spice.str2et)

Note

Note that you got caught

et2utc and etcal

et2utc https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/et2utc.html A function that converts to UTC when you enter ET. On the other hand etcal https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/etcal.html Is a function that converts to calendar time when you enter ET.

The calculation result is different! What's the difference? Leap seconds are not taken into consideration in etcal, and it is unclear when to use it, but ** Generally, it seems better to use et2utc. ** **

Recommended Posts

Use NAIF SPICE TOOLKIT with Python
[Python] Use JSON with Python
Use mecab with Python3
Use DynamoDB with Python
Use Python 3.8 with Anaconda
Use python with docker
Use Trello API with python
Use Twitter API with Python
Use subsonic API with python3
Python: How to use async with
Use PointGrey camera with Python (PyCapture2)
Use vl53l0x with Raspberry Pi (python)
[Python] Use Basic/Digest authentication with Flask
Use rospy with virtualenv in Python3
Use Python in pyenv with NeoVim
How to use FTP with Python
Use Windows 10 speech synthesis with Python
Use OpenCV with Python 3 in Window
Use PostgreSQL with Lambda (Python + psycopg2)
Use smbus with python3 under pyenv environment
Use DeepL with python (for dissertation translation)
Use Amazon Simple Notification Service with Python
[Python] Use string data with scikit-learn SVM
[Introduction to Python] Let's use foreach with Python
Use PIL and Pillow with Cygwin Python
Use cryptography library cryptography with Docker Python image
Use Application Insights with Python 3 (including bottles)
Use C ++ functions from python with pybind11
Use selenium phantomjs webdriver with python unittest
Until you can use opencv with python
Use Python and MeCab with Azure Functions
FizzBuzz with Python3
Scraping with Python
Statistics with python
Scraping with Python
Python with Go
Integrate with Python
Play with 2016-Python
AES256 with python
Tested with Python
python starts with ()
with syntax (Python)
Bingo with python
Zundokokiyoshi with python
Excel with Python
Microcomputer with Python
Cast with python
I want to use MATLAB feval with python
Use additional Python packages with Serverless Framework (v1.x)
Use logger with Python for the time being
Python> Run with run-time arguments> Use import argparse
Use multiple versions of python environment with pyenv
Wrap C with Cython for use from Python
The easiest way to use OpenCV with python
Use various rabbimq features with pika in python
I want to use Temporary Directory with Python2
How to use tkinter with python in pyenv
Use Python in Anaconda environment with VS Code
Use Python and word2vec (learned) with Azure Databricks
Until you use PhantomJS with Python on Heroku
Wrap C ++ with Cython for use from Python