Python library to monkeypatch SpiceyPy to allow JSON kernels.
Project description
Python library to monkeypatch SpiceyPy to allow JSON kernels (and Python dictionaries).
Description
The standard text kernel format for the SPICE Toolkit is the "PCK" file (with extension .tpc). Examples of these files can be seen here.
The PCK file is a data file format that exists in no other domain. So, it may be more convenient to use a standard file format such as JSON, as well as native Python dictionaries. The jsonspice library allows you to do this by monkey patching SpiceyPy so that JSON kernels will "just work".
Installation
PyPi
pip install jsonspice
conda
conda install conda-forge::jsonspice
JSON kernel format
The following PCK file:
KPL/PCK
\begintext
An example kernel
\begindata
TIME3 = @1972-JAN-1
AAA = 1
AAA += 2
VARIABLE = (1.0 2.0 3.0)
VARIABLE2 = 42.0
Has the equivalent JSON kernel representation:
// An example kernel
{
"TIME3": "@1972-JAN-1",
"AAA" : 1,
"+AAA" : 2,
"VARIABLE": [1.0, 2.0, 3.0],
"VARIABLE2": 42.0
}
Some things to note about the JSON version:
- Optional comments are supported (using the JSON5 library). Other than this, the file is a standard JSON file.
- The SPICE "@" format for time variables is supported using a normal string that begins with the "@" character.
- The SPICE "+=" assignment to append to an existing variable is supported by prepending the variable name with the "+" character.
The JSON version of SPICE "meta-kernels" is also supported. See the SPICE documentation for details of that format.
Example usage
To use this library, if must be imported BEFORE SpiceyPy. Once that is done, the normal furnsh() method can be used.
import jsonspice # import first to monkeypatch spiceypy
import spiceypy
# load a normal kernel
spiceypy.furnsh('de-403-masses.tpc')
# load a JSON kernel
spiceypy.furnsh('de-403-masses.json')
# also works with dicts:
spiceypy.furnsh({"BODY8_GM": 6836534.064})
spiceypy.furnsh({"time": '@1972-JAN-1'})
spiceypy.furnsh({"+abc": [4,5,6]})
Documentation
The API documentation for the latest master branch can be found here.
See also
- NAIF -- NASA's Navigation and Ancillary Information Facility
- PCK Required Reading (NAIF)
- SpiceyPy -- SpiceyPy: a Pythonic Wrapper for the SPICE Toolkit
- J. Williams, JSON + SPICE, Feb 5, 2018 (degenerateconic.com)
- jsonspice at the Python Package Index
- jsonspice at conda-forge.
- jsonspice-feedstock repo.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsonspice-1.2.0.tar.gz.
File metadata
- Download URL: jsonspice-1.2.0.tar.gz
- Upload date:
- Size: 72.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81f09e741f30163d5c887d10a7ecf917759b258f244d24ecc4caeb093c948a92
|
|
| MD5 |
3dc936713f8b5ee44e6448fc1c7bcfeb
|
|
| BLAKE2b-256 |
b517053107af8ca5ab8252c7c78a9e58c1b1f01a66e605deaa14ed9e3ccfbfdc
|
Provenance
The following attestation bundles were made for jsonspice-1.2.0.tar.gz:
Publisher:
publish.yml on jacobwilliams/jsonspice
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsonspice-1.2.0.tar.gz -
Subject digest:
81f09e741f30163d5c887d10a7ecf917759b258f244d24ecc4caeb093c948a92 - Sigstore transparency entry: 206510692
- Sigstore integration time:
-
Permalink:
jacobwilliams/jsonspice@3efba7d37f451ca2b2071859333a654916cd7cfb -
Branch / Tag:
refs/tags/1.2.0 - Owner: https://github.com/jacobwilliams
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3efba7d37f451ca2b2071859333a654916cd7cfb -
Trigger Event:
release
-
Statement type:
File details
Details for the file jsonspice-1.2.0-py3-none-any.whl.
File metadata
- Download URL: jsonspice-1.2.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ba441b119cb9064e56940b6e55580600540ee6475cf9ae371251a07f4af0c39
|
|
| MD5 |
b56717bb64fe058d27b03c54f94f5759
|
|
| BLAKE2b-256 |
0378851bb874ee0709a46bd14ea745f0752706ff85b98deab0db630e3d72ec2c
|
Provenance
The following attestation bundles were made for jsonspice-1.2.0-py3-none-any.whl:
Publisher:
publish.yml on jacobwilliams/jsonspice
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsonspice-1.2.0-py3-none-any.whl -
Subject digest:
0ba441b119cb9064e56940b6e55580600540ee6475cf9ae371251a07f4af0c39 - Sigstore transparency entry: 206510694
- Sigstore integration time:
-
Permalink:
jacobwilliams/jsonspice@3efba7d37f451ca2b2071859333a654916cd7cfb -
Branch / Tag:
refs/tags/1.2.0 - Owner: https://github.com/jacobwilliams
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3efba7d37f451ca2b2071859333a654916cd7cfb -
Trigger Event:
release
-
Statement type: