Пример #1
0
def test_invalid_body_creation():
    with pytest.raises(ValueError,
                       match='Body name "Not a body" not known by SPICE'):
        body = spice.Body('Not a body')

    with pytest.raises(ValueError, match='id "104857" not known by SPICE'):
        body = spice.Body(104857)

    with pytest.raises(ValueError, match="body must be an int or str"):
        body = spice.Body(1.0)
Пример #2
0
def test_body_creation():
    # Test creating by name
    body = spice.Body('Sun')
    assert body.name == 'Sun'
    assert body.id == 10

    # Test creating by ID
    body = spice.Body(10)
    assert body.name == 'SUN'
    assert body.id == 10
Пример #3
0
def test_kernel():
    kernel = spicedata.get_kernel('helios1')[0]
    solo = spice.Body('helios 1')
    assert len(kernel.bodies) == 1
    assert kernel.bodies[0] == solo

    assert kernel.coverage(solo) == [
        datetime.datetime(1974, 12, 10, 23, 50, 1, 662,
                          tzinfo=datetime.timezone.utc),
        datetime.datetime(1981, 9, 30, 1, 29, 54, 1651,
                          tzinfo=datetime.timezone.utc)
    ]
Пример #4
0
def test_kernel():
    kernel = spicedata.get_kernel('solo')[0]
    solo = spice.Body('solar orbiter')
    assert len(kernel.bodies) == 1
    assert kernel.bodies[0] == solo

    assert kernel.coverage(solo) == [
        datetime.datetime(2020,
                          2,
                          10,
                          4,
                          55,
                          49,
                          670002,
                          tzinfo=datetime.timezone.utc),
        datetime.datetime(2030,
                          11,
                          20,
                          10,
                          54,
                          51,
                          644258,
                          tzinfo=datetime.timezone.utc)
    ]
Пример #5
0
from datetime import datetime, timedelta

import matplotlib.pyplot as plt
import numpy as np

import astropy.units as u
import heliopy.data.spice as spicedata
import heliopy.spice as spice

###############################################################################
# Load the Solar Orbiter spice kernel. HelioPy will automatically fetch and
# load the latest kernel. We can then inspect the kernel to check what the
# date coverage is for Solar Orbiter.
kernels = spicedata.get_kernel('solo')
solo = spice.Trajectory('Solar Orbiter')
coverage = kernels[0].coverage(spice.Body('Solar Orbiter'))
print(coverage)

###############################################################################
# Next we define a set of times at which to sample the orbit.
starttime = coverage[0]
times = [starttime + timedelta(days=i) for i in range(1, 5 * 365)]

###############################################################################
# Generate positions. "IAU_SUN" is a Carrington frame of reference.
solo.generate_positions(times, 'Sun', 'IAU_SUN')
coords = solo.coords

###############################################################################
# Plot radial distance and elevation as a function of time
fig, axs = plt.subplots(3, 1, sharex=True)
Пример #6
0
def test_body_repr():
    assert 'Sun' in spice.Body('Sun').__repr__()
    assert '10' in spice.Body('Sun').__repr__()
Пример #7
0
def test_body_eq():
    assert spice.Body('Sun') == spice.Body(10)
    assert spice.Body(1) != spice.Body(10)