Check if mu is zero in OsculatingElements.__init__() (#259)

Raises a ValueError instead of having a mysterious numpy divide by zero warning later on
Be more specific and address the case of negative mu_km_s
This commit is contained in:
Josh Paterson 2019-06-25 15:18:42 -05:00 committed by Brandon Rhodes
parent 29022d041b
commit e80df46a59
1 changed files with 4 additions and 0 deletions

View File

@ -53,6 +53,10 @@ class OsculatingElements(object):
"""
def __init__(self, position, velocity, time, mu_km_s):
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