diff --git a/rebound/horizons.py b/rebound/horizons.py index 5de6013ee..0f1aea5f9 100644 --- a/rebound/horizons.py +++ b/rebound/horizons.py @@ -7,6 +7,7 @@ import re import warnings import sys +from .units import convert_mass HORIZONSBASEURL = "https://ssd.jpl.nasa.gov/api/horizons.api?" @@ -65,7 +66,7 @@ def api_request(particle, datestart, dateend, plane): return body -def query_horizons_for_particle(particle=None, m=None, x=None, y=None, z=None, vx=None, vy=None, vz=None, primary=None, a=None, +def query_horizons_for_particle(mass_unit=None, particle=None, m=None, x=None, y=None, z=None, vx=None, vy=None, vz=None, primary=None, a=None, anom=None, e=None, omega=None, inc=None, Omega=None, MEAN=None, date=None, plane="ecliptic", hash=0): if plane not in ["ecliptic", "frame"]: raise AttributeError( @@ -152,7 +153,11 @@ def query_horizons_for_particle(particle=None, m=None, x=None, y=None, z=None, v else: print("Found body (Name could not be detected)") if m is not None: - p.m = m + if mass_unit is not None: + p.m = convert_mass(m, mass_unit, "kg") + else: + ## Assume kg + p.m = m elif idn is not None: try: p.m = float( diff --git a/rebound/simulation.py b/rebound/simulation.py index d194829da..7f03aab96 100644 --- a/rebound/simulation.py +++ b/rebound/simulation.py @@ -920,7 +920,8 @@ def add(self, particle=None, **kwargs): if "frame" not in kwargs: if hasattr(self, 'default_plane'): kwargs["plane"] = self.default_plane # allow ASSIST to set default plane - self.add(horizons.query_horizons_for_particle(particle, **kwargs), hash=particle) + mass_unit = hash_to_unit(self.python_unit_m) # For manually provided masses + self.add(horizons.query_horizons_for_particle(mass_unit, particle, **kwargs), hash=particle) units_convert_particle(self.particles[-1], 'km', 's', 'kg', hash_to_unit(self.python_unit_l), hash_to_unit(self.python_unit_t), hash_to_unit(self.python_unit_m)) else: raise ValueError("Argument passed to add() not supported.")