Skip to main content

OrbitSystem.remove_body

remove_body(id)

Remove one or more bodies from a system.

Returns a copy of the system without the named bodies. The other bodies keep their positions and velocities, and G is unchanged. This is useful for “what if” experiments on a ready-made system, such as the solar system without Jupiter. Also available as orb.remove_body(system, ...).

Parameters

Name Type Description Default
id str or iterable of str The name of the body to remove, or a list of names. Names are matched exactly, including case. required

Returns

Name Type Description
OrbitSystem A new system without the named bodies. The original system is not modified.

Raises

Name Type Description
ValueError If id is an empty list or contains something that is not a string, or if any name is not in the system. The message lists the bodies that are present.

See Also

Notes

Removing a body does not adjust the others. A moon whose planet is removed keeps the velocity it had, and will no longer be in a closed orbit around anything.

Examples

The solar system without Jupiter.

import pyorbiter as orb

system = orb.load_solar_system().remove_body("Jupiter")
system
───────────────────────────────── orbit_system ─────────────────────────────────
G: 6.6743e-11 (standard)
Bodies: 10

     id         mass             x             y             z            vx            vy          vz
    Sun 1.989000e+30  0.000000e+00  0.000000e+00  0.000000e+00      0.000000      0.000000    0.000000
Mercury 3.301000e+23  1.012086e+10  4.479358e+10  2.728321e+09 -57286.619869  12561.113880 6279.625812
  Venus 4.867000e+24 -7.114253e+10  8.037591e+10  5.197731e+09 -26353.863664 -23403.981810 1199.695283
  Earth 5.972000e+24 -3.296559e+10  1.433603e+11  0.000000e+00 -29520.187051  -6788.143346    0.000000
   Mars 6.417000e+23  1.887900e+11 -8.370696e+10 -6.395443e+09  10749.771467  24226.116460  243.021783
 Saturn 5.683000e+26 -7.381497e+10  1.350805e+12 -2.069093e+10 -10158.213515   -548.755373  414.022983
 Uranus 8.681000e+25 -2.707453e+12  4.181380e+11  3.654544e+10  -1086.589920  -7034.677635  -11.641166
Neptune 1.024000e+26  3.145881e+12  3.136179e+12 -1.370573e+11  -3880.187319   3892.602856    9.446879
   Moon 7.342000e+22 -3.292356e+10  1.437205e+11 -2.175733e+07 -30585.853990  -6659.462622   71.933632
  Pluto 1.309000e+22 -3.014974e+12 -3.026468e+12  1.197383e+12   4153.180664  -4425.697169 -728.672130

Remove several bodies at once.

import pyorbiter as orb

inner = orb.load_solar_system(moon=False, pluto=False).remove_body(
    ["Jupiter", "Saturn", "Uranus", "Neptune"]
)
inner.bodies["id"].tolist()
['Sun', 'Mercury', 'Venus', 'Earth', 'Mars']