Fix osculating elements whitespace and formatting

This commit is contained in:
Brandon Rhodes 2019-11-08 10:04:22 -05:00
parent b95da28a4c
commit ee401630b6
2 changed files with 24 additions and 19 deletions

View File

@ -20,14 +20,14 @@ def osculating_elements_of(position, reference_frame=None):
"""
mu = GM_dict.get(position.center, 0) + GM_dict.get(position.target, 0)
if reference_frame is not None:
position_vec = Distance(reference_frame.dot(position.position.au))
velocity_vec = Velocity(reference_frame.dot(position.velocity.au_per_d))
else:
position_vec = position.position
velocity_vec = position.velocity
return OsculatingElements(position_vec,
velocity_vec,
position.t,
@ -35,12 +35,10 @@ def osculating_elements_of(position, reference_frame=None):
class OsculatingElements(object):
"""
Contains one or more sets of osculating orbital elements. Different
elements are accessed as attributes of the ``OsculatingElements`` object.
"""One or more sets of osculating orbital elements.
An ``OsculatingElements`` object can be initialized with the following
parameters:
An ``OsculatingElements`` object can be initialized with the
following parameters:
position : Distance object
Position vector with shape (3,) or (3, n)
@ -53,10 +51,10 @@ class OsculatingElements(object):
"""
def __init__(self, position, velocity, time, mu_km_s):
if mu_km_s <= 0:
if mu_km_s <= 0:
raise ValueError('`mu_km_s` (the standard gravitational parameter '
'in km^3/s^2) must be positive and non-zero')
self._pos_vec = position.km
self._vel_vec = velocity.km_per_s
self.time = time

View File

@ -7,8 +7,10 @@ from skyfield.elementslib import (
normpi,
osculating_elements_of,
)
from numpy import (array, sin, cos, pi, sqrt, ndarray, float64, repeat,
seterr, inf, linspace, arccos)
from numpy import (
array, sin, cos, pi, sqrt, ndarray, float64, repeat, seterr, inf,
linspace, arccos,
)
import os
def ts():
@ -51,8 +53,12 @@ def compare(value, expected_value, epsilon, mod=False):
def check_types(elements, length):
"""Checks that all of the attributes in the OsculatingElements object are
present, have the correct type, and have the expected size.
"""Raise an assertion error for any problems with orbital `elements`.
Checks that all of the attributes in the OsculatingElements object
`elements` are present, have the correct type, and have the expected
size.
"""
for item in ['inclination', 'longitude_of_ascending_node',
'argument_of_periapsis', 'true_anomaly',
@ -84,8 +90,7 @@ def check_types(elements, length):
def horizons_dict(elem, units='km_d', ):
"""
Outputs dictionary with keys that match labels used by Horizons.
"""Return a dictionary with keys that match labels used by Horizons.
The data from this method is exactly the same as the data in the
elements object and differs from it only in units.
@ -110,6 +115,7 @@ def horizons_dict(elem, units='km_d', ):
'km_s' for kilometers and seconds
'km_d' for kilometers and days
'au_d' for au and days
"""
data = {}
data['EC'] = elem.eccentricity
@ -148,8 +154,7 @@ def horizons_dict(elem, units='km_d', ):
def horizons_array(elem, units='km_d', ):
"""
Outputs numpy array containing data in the same order as horizons.
"""Return a numpy array containing data in the same order as horizons.
The data from this method is exactly the same as the data in the
elements object and differs from it only in units.
@ -161,8 +166,10 @@ def horizons_array(elem, units='km_d', ):
'km_d' for kilometers and days
'au_d' for au and days
The shape of the array is ``(12,)`` if the time used to construct the
position is a float, and ``(12, n)`` if the time is an array of length n.
The shape of the array is ``(12,)`` if the time used to construct
the position is a float, and ``(12, n)`` if the time is an array of
length n.
"""
dict_ = horizons_dict(elem, units=units)
array_ = array([dict_['EC'],