Python package for NAIF WebGeoCalc API
Project description
In december 2018, JPL/NAIF announced an experimental API RESTful interface for their new WebGeocalc server (which make online SPICE calculations). Documentation and JavaScript examples are already available.
This package is an early attempt to provide a Python interface to make SPICE calculation through this API.
Note the user
WebGeoCalc is not design to handle heavy calculation. If you need to make intensive queries, use Spiceypy or SpiceMiner package with locally hosted kernels.
Install
With pip:
$ pip install webgeocalc
With the source files:
$ git clone https://github.com/seignovert/python-webgeocalc.git webgeocalc
$ cd webgeocalc ; python setup.py install
Usage
>>> from webgeocalc import API
>>> API.url
'https://wgc2.jpl.nasa.gov:8443/webgeocalc/api'
>>> API.kernel_sets() # /kernel-sets
[
<KernelSetDetails> Solar System Kernels (id: 1),
...
<KernelSetDetails> Cassini Huygens (id: 5),
...
<KernelSetDetails> SPICE Class -- Binary PCK Lesson Kernels (Earth) (id: 39)
]
>>> API.bodies(5) # /kernel-sets/{kernelSetId}/bodies
[
<BodyData> CASSINI (id: -82),
<BodyData> CAS (id: -82),
...
<BodyData> SOLAR SYSTEM BARYCENTER (id: 0)
]
>>> API.frames('Cassini Huygens') # /kernel-sets/{kernelSetId}/frames
[
<FrameData> CASSINI_SATURN_SKR4N_LOCK (id: -82982),
...
<FrameData> ITRF93 (id: 13000)
]
>>> API.instruments('Cassini Huygens') # /kernel-set/{kernelSetId}/intruments
[
<InstrumentData> CASSINI_CIRS_RAD (id: -82898),
...
<InstrumentData> CASSINI_SRU-A (id: -82001)
]
Prepare calculation payload:
>>> from webgeocalc import Calculation
>>> calc = Calculation(
kernels = 'Cassini Huygens',
times = '2012-10-19T08:24:00.000',
calculation_type = 'STATE_VECTOR',
target = 'CASSINI',
observer = 'SATURN',
reference_frame = 'IAU_SATURN',
aberration_correction = 'NONE',
state_representation = 'PLANETOGRAPHIC',
)
>>> calc.payload
{
'kernels': [{'type': 'KERNEL_SET', 'id': 5}],
'times': ['2012-10-19T08:24:00.000'],
'calculationType': 'STATE_VECTOR',
'target': 'CASSINI',
'observer': 'SATURN',
'referenceFrame': 'IAU_SATURN',
'aberrationCorrection': 'NONE',
'stateRepresentation': 'PLANETOGRAPHIC',
'timeSystem': 'UTC',
'timeFormat': 'CALENDAR'
}
Run calculation:
>>> calc.submit()
[Calculation submitted] Status: LOADING_KERNELS (id: 19fd1c05-3bfe-47c7-bd16-28612249ae89)
>>> calc.update()
[Calculation update] Status: COMPLETE (id: 19fd1c05-3bfe-47c7-bd16-28612249ae89)
>>> calc.results
{
'DATE': '2012-10-19 08:24:00.000000 UTC',
'LONGITUDE': 46.18900522,
'LATITUDE': 21.26337134,
'ALTITUDE': 694259.8921163,
'D_LONGITUDE_DT': 0.00888655,
'D_LATITUDE_DT': -0.00031533,
'D_ALTITUDE_DT': 4.77080305,
'SPEED': 109.34997994,
'TIME_AT_TARGET': '2012-10-19 08:24:00.000000 UTC',
'LIGHT_TIME': 2.51438831
}
>>> from webgeocalc import AngularSeparation
>>> AngularSeparation(
kernel_paths = ['pds/wgc/kernels/lsk/naif0012.tls', 'pds/wgc/kernels/spk/de430.bsp'],
times = '2012-10-19T08:24:00.000',
target_1 = 'VENUS',
target_2 = 'MERCURY',
observer = 'SUN',
).run()
[Calculation submitted] Status: COMPLETE (id: 24739881-c068-45a1-8e52-b3cd87f47866)
{'DATE': '2012-10-19 08:24:00.000000 UTC', 'ANGULAR_SEPARATION': 175.17072258}
More details can be found in the Jupyter Notebooks.
Disclaimer
This project is not supported or endorsed by either JPL, NAIF or NASA. The code is provided “as is”, use at your own risk.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for webgeocalc-0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9d55bbcab572aeacdfe697c9db9b4aee863e46354034faf59f363517ac96289 |
|
MD5 | 6ddc61df4432416ff3acb0886dfa26cb |
|
BLAKE2b-256 | c3e4f4356637ba5ecbfdc94314e09b886c653da2b37db1746c97b3353f23057b |