Skip to main content

Working with SPICE kernels

Project description

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

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

bspice-0.0.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

bspice-0.0.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file bspice-0.0.2.tar.gz.

File metadata

  • Download URL: bspice-0.0.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.0

File hashes

Hashes for bspice-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c4d74f0efba6457cbda940fad8c95b604093e60a785f8cb8317861650fb9158c
MD5 c48ae71016f6e735b3b9430c8d1553b4
BLAKE2b-256 6c5111a47f2200ac31207a59b880f8690dbb1962c32a883a0955a0f7a7cf3713

See more details on using hashes here.

File details

Details for the file bspice-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: bspice-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.0

File hashes

Hashes for bspice-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2dcf29e445750f75136df27d6e18b722539d5cd27bd04ee9b4af2bb54cd64069
MD5 f150175ffccf8f626c5ac8388a54cf03
BLAKE2b-256 4c8f63d58ef50abbf27fcc76a2b285db5b91b9be1e41539a46ca05e628fff598

See more details on using hashes here.

Supported by

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