Skip to main content

Author: Behrouz Safari
License: MIT

bspice

Working with SPICE kernels

Installation

You can install the latest version of bspice from PyPI:

pip install bspice

The requirements are numpy, requests and spiceypy.

Download Kernels

import bspice as bs

bs.download_kernels(overwrite=False, solsys=True, jupiter=True)

Apparent position of Saturn

import bspice as bs
from datetime import datetime

t = datetime.utcnow()
obs_loc = (7.744083817548831, 48.58313582900411, 140)

adr = 'C:/Moi/_py/Astronomy/Solar System/kernels/'

kernels = [adr+i for i in bs.main_kernels]
kernels = kernels + [adr+'de440_2030.bsp']

r, az, alt = bs.get_apparent(6, t, obs_loc, kernels)
print(az, alt)

Apparent position of Jupiter Moons

import bspice as bs
from datetime import datetime
import matplotlib.pyplot as plt

t = datetime.utcnow()
obs_loc = (7.744083817548831, 48.58313582900411, 140)

adr = 'C:/Moi/_py/Astronomy/Solar System/kernels/'

kernels = [adr+i for i in bs.main_kernels]
kernels = kernels + [adr+'jup4_2030.bsp']

bodies = [599, 501, 502, 503, 504]
r_az_alt = bs.get_apparent_bodies(bodies, t, obs_loc, kernels, abcorr='LT+S')
print(r_az_alt)

fig, ax = plt.subplots()
ax.scatter(r_az_alt[0,1], r_az_alt[0,2])
ax.scatter(r_az_alt[1:,1], r_az_alt[1:,2])
plt.show()

Apparent position of the Sun during 24 hours

import bspice as bs
from datetime import datetime

obs_loc = (7.744083817548831, 48.58313582900411, 140)

adr = 'C:/Moi/_py/Astronomy/Solar System/kernels/'

kernels = [adr+i for i in bs.main_kernels]
kernels = kernels + [adr+'de440_2030_earth_sun_moon.bsp']

t1 = datetime(2022, 9, 10)
t2 = datetime(2022, 9, 11)

r_az_alt = bs.get_apparent_window(10, t1, t2, 24, obs_loc, kernels, abcorr='LT+S')

for i in r_az_alt:
    print(f'Az:{i[1]} ||| Alt:{i[2]}')

Local and absolute minimum angular positions of Sun and Moon

import bspice as bs

t1 = '2022-01-01'
t2 = '2023-01-01'

adr = 'C:/Users/H21/Desktop/Desktop/Behrouz/Astronomy/kernels/'

kernels = [
    adr + 'naif0012.tls',
    adr + 'pck00010.tpc',
    adr + 'de440s.bsp',
    ]

print('Local:')
times = bs.conjunction(t1=t1, t2=t2, targ1='sun', targ2='moon', kernels=kernels)

for i in times:
    print(i)

print('Absolute:')
times = bs.conjunction(t1=t1, t2=t2, targ1='sun', targ2='moon', kernels=kernels, relate='ABSMIN')

for i in times:
    print(i)
Local:
2022-01-02 18:08:14
2022-02-01 05:32:21
2022-03-02 17:49:18
2022-04-01 06:53:57
2022-04-30 20:41:32
2022-05-30 11:11:34
2022-06-29 02:19:09
2022-07-28 17:40:45
2022-08-27 08:34:53
2022-09-25 22:24:24
2022-10-25 11:00:06
2022-11-23 22:40:53
2022-12-23 09:52:10
Absolute:
2022-10-25 11:00:06

Metadata

Release files for bspice 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bspice 0.0.3
File Size Uploaded Provenance
bspice-0.0.3.tar.gz 5.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bspice 0.0.3
File Interpreter ABI Platform
bspice-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 kB

Release files / bspice-0.0.3.tar.gz

Download URL bspice-0.0.3.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7c40f935a0d3b560c6a1ba5c96acccdf252621756bcd54312b5958d4783db943
BLAKE2b-256 checksum
How to use checksums
bbfea959d8e096b145af223234039b9fb7eff2dbee7ff483274d6954a9e8f8e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.7

Release files / bspice-0.0.3-py3-none-any.whl

Download URL bspice-0.0.3-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a61ed937076e887e1b20bd2095d37901bde5a05c53560b158046b56e504a4818
BLAKE2b-256 checksum
How to use checksums
ef41f1c03771d1203d6c3ae609300f1faf718f3f4ab7de5716d75e84b2df4cf3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.7

Security for bspice 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page