Skip to main content

Python library to monkeypatch SpiceyPy to allow JSON kernels.

Project description

Python library to monkeypatch SpiceyPy to allow JSON kernels (and Python dictionaries).

CI Status last-commit PyPI Downloads Conda Downloads

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]})

See also

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

jsonspice-1.1.0.tar.gz (72.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsonspice-1.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file jsonspice-1.1.0.tar.gz.

File metadata

  • Download URL: jsonspice-1.1.0.tar.gz
  • Upload date:
  • Size: 72.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for jsonspice-1.1.0.tar.gz
Algorithm Hash digest
SHA256 b538d548be1d14c1c69f526d87001a19aa52fe42d1a1ab17ff3d2a85f88c294b
MD5 944ab3981a76f68eecbba82c3bbe1975
BLAKE2b-256 89abb27a505f71ef97666c2799f39edd7fa00d7382e7029b227b99a60d3da612

See more details on using hashes here.

Provenance

The following attestation bundles were made for jsonspice-1.1.0.tar.gz:

Publisher: publish.yml on jacobwilliams/jsonspice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jsonspice-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: jsonspice-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for jsonspice-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1dd29a1ae11070d4c1becea9404b8b10de0c23195d4a672f699274673c75105
MD5 955f6893e1cf1f2a0b0fc068c0f57f0a
BLAKE2b-256 78b8b563d4d7292bed3a4fe6197d2a169a7584576fc94e047d150912e1ef419b

See more details on using hashes here.

Provenance

The following attestation bundles were made for jsonspice-1.1.0-py3-none-any.whl:

Publisher: publish.yml on jacobwilliams/jsonspice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page